K
Kevin
Hello there,
I am justing thinking of how can we do this in a faster way, if any.
Suppose we are required to count the frequency of each different word
in a large text documents, the way I currently using is like:
//////////////////
Hashtable ht = new Hashtable();
Read each word in the text in its order, for each of them:
if (ht.contains(oneWord))
{
Integer I = (Integer) ht.get(oneWord));
ht.put(oneWord, new Integer(I.intValue()+1));
}
else
{
ht.put(oneWord, new Integer(1));
};
//////////////////
Since we can not apply I++ since I is an Object, I am thinking we have
to new a new Integer each time we use it.
Is there any other way to do this process faster? Or any other data
structure we can use for this purpose?
Thanks a lot and happy weekend!
I am justing thinking of how can we do this in a faster way, if any.
Suppose we are required to count the frequency of each different word
in a large text documents, the way I currently using is like:
//////////////////
Hashtable ht = new Hashtable();
Read each word in the text in its order, for each of them:
if (ht.contains(oneWord))
{
Integer I = (Integer) ht.get(oneWord));
ht.put(oneWord, new Integer(I.intValue()+1));
}
else
{
ht.put(oneWord, new Integer(1));
};
//////////////////
Since we can not apply I++ since I is an Object, I am thinking we have
to new a new Integer each time we use it.
Is there any other way to do this process faster? Or any other data
structure we can use for this purpose?
Thanks a lot and happy weekend!