How to discard stopwords contained in class and do word count?

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2007
Posts: 7
Reputation: umadas is an unknown quantity at this point 
Solved Threads: 0
umadas umadas is offline Offline
Newbie Poster

How to discard stopwords contained in class and do word count?

 
0
  #1
Jan 30th, 2007
package umadas.examples;import java.io.*;import java.util.*;class Counters{int iCount = 1;} public class Wordfreq { public static Reader r; private static String str=""; public static void main(String args[]) { try { r = new BufferedReader(new FileReader(args[0])); fnWordFrequency(); r.close(); } catch (IOException e) { System.err.println(e); } } public static void fnWordFrequency() { HashMap map = new HashMap(); try { StreamTokenizer st = new StreamTokenizer(r); int iToken = st.nextToken(); while (iToken != StreamTokenizer.TT_EOF) { if (iToken == StreamTokenizer.TT_WORD) { if (map.containsKey(st.sval)) { ((Counters)map.get(st.sval)).iCount++; } else { map.put(st.sval, new Counters()); } } iToken = st.nextToken(); } } catch (IOException e) { System.err.println(e); return; } Collection entries = map.entrySet(); Vector vTor = new Vector(entries); Iterator it = vTor.iterator(); Map.Entry ent; String sWord; int iCounter; while(it.hasNext()) { ent = (Map.Entry)it.next(); sWord = ((String)ent.getKey()); iCounter = ((Counters)ent.getValue()).iCount; str+=sWord+"\t"+iCounter+"\t"; System.out.println(sWord + "\t" + iCounter); } try { OutputStream f1=new FileOutputStream("C:/trial/umadas.txt"); byte buf[]=str.getBytes(); f1.write(buf); System.out.println("\n"); } catch(IOException io) { System.out.println(io.getMessage()); } } }THIS PROGRAM TOKENIZES THE WORD READ FROM A FILE IN COMMAND LINE AND PRINTS THE FREQUENCY OF EACH WORD.EX PROGRAM 25.NOW I HAVE A CLASS CONTAINING STOPWORDS LIKE( A ,AN) CONTAINED IN A HASHTABLE.I WANT TO READ THIS STOPWORDS FILEAND DISCARD THOSE AND PRINT THE ABOVE OUTPUT(DISCARDING THIS STOPWORDS).KINDLY HELP
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 353
Reputation: aniseed is an unknown quantity at this point 
Solved Threads: 6
aniseed's Avatar
aniseed aniseed is offline Offline
Posting Whiz

Re: How to discard stopwords contained in class and do word count?

 
0
  #2
Jan 30th, 2007
Wow! How do you expect someone to read that message? Please make use of code tags and line breaks.
Last edited by aniseed; Jan 30th, 2007 at 2:27 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: How to discard stopwords contained in class and do word count?

 
0
  #3
Jan 30th, 2007
and stop the SHOUTING.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC