Question:
HOW TO IDENTIFY EACH WORD SEPARATELY FROM A TEXTUAL DOCUMENT AND SORT THOSE WORDS BY FREQUENCY IN Java?
ru m
2010-12-28 21:49:53 UTC
HERE I want to identify all the words of a textual document separately and then i want to sort those words according to their occurring frequency in another text file by Java programming.In the second text file(where the words are written in the sorted order) the words will be written in the root form.e.g shutting will be converted to shut, and there will also be no punctuation marks and no stop words(to,from,and,the,by,for,into etc) in the second file.please help me with the Java code.please.please.please.
Three answers:
anonymous
2010-12-29 12:37:48 UTC
what is the logic to find find the root form of a word quoting your example

of shutting to shut.



can you mention some sample input file content

along with output file content for that input.
severn
2016-10-27 03:18:15 UTC
I forgot my call - a lot a lot hate on blood on the dance floor only for there look and there message about Sexual issues. i imagine there ok. they have a high-quality message that there sending out to actual everyone. i'm now going to get a gaggle of dislikes. the first ingredient that contains my ideas is my call. Jesse
deonejuan
2010-12-29 06:25:55 UTC
Learn how to unlock the CAPs Lock on your keyboard. Either search online, ask your colleagues or a teacher on how to unlock the caps_lock.



//================

import java.io.FileReader;

import java.io.FileWriter;

import java.io.IOException;

import java.util.Scanner;

import java.util.*;



public class UniqueWordsFromFile {

public static void main( String [] args ) throws IOException {

FileReader fin = new FileReader("Text.txt");

List data = new ArrayList();

Scanner src = new Scanner(fin);

while( src.hasNext() ) {

data.add( src.readLine() );

}

src.close();



Map m = new HashMap();





for (String d : data) {

Integer freq = m.get(a);

m.put(a, (freq == null) ? 1 : freq + 1);

}



System.out.println(m.size() + " distinct words:");

System.out.println(m);

}


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...