![]() ![]() What i mean by this is once the values have been stored in the vector, i'd like the dictionaries frequency values to reset back to 0, ready for the next text document to be compared with the dictionary, then output that to a different vector - this process will be repeated 10-12 times. Everything works, but as i said i'm looking to make it reusable. The code then loads in another text file, compares it with the dictionary, updates its frequency values and outputs to a vector. This code reads in a dictionary object created in another class (that i made), as well as read in a text file to put in said dictionary object. Is that just Java or does my code need touching up? import java.io.I've made a program that works, but i want to make it reusable. I saw a Python script of this that does the same thing but in half the lines of code. To count up the occurrences of a given word, you can use Multiset: Multiset countOfEachWord HashMultiset.create () countOfEachWord.addAll (wordsInFile) You could build on these two pieces to create some kind of object like a WordLookupTable.![]() A word is nothing but a non-space character in String, which is separated by one or. I'm also wondering if I should break up my code in main into more methods. You can count words in Java String by using the split() method of String. In this app, we will count the word in the text area
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |