Android: counting occurrence of words on file on SD Card -
It should be straight forward, but for some reason when I downloaded it on my SD card after the words in the file I try to count, the number starts closing. There are more incidents than this, and my results start to stop. I use Microsoft Word to verify the number of incidents (using only the undiscovered case and whole word). To check the number of events, I use the "the_counter" variable below. I also verified that there is nothing wrong with the download & amp; The whole file is downloaded to my SD card. It's driving me crazy - I'm thinking that the word can not be wrong here, then maybe what's wrong in my code below?
Due to this problem the file may contain white space or special characters - is there a way to clear the file to verify it?
// Find directory using sdcard = Environment.getExternalStorageDirectory () to the API file for SD card; // Get the text file file file = new file (SDCard, TEMP_FILE); // Read the text from the file / stringbinder text = new stringbuilder (); M_tree = New tree (); Int i = 0; Buffettarder BRL = Faucet; Long Koggan = 0; Try {br = new BufferedReader (new FileReader (file)); String line; String [] Arline; While ((line = br.readline ())! = Null) {// get every word in the line if (line.length () == 0) continues; Arline = line.split ("\\ s +"); // Now (i = 0; i & lt; arLine.length; ++ i) {m_tree.insert (arLine [i]) Add every word to search for the tree; If (ariline [i] .equalsIgnoreCase ("a")) ++ the_counter; }} M_sTest = long.trustring (the_counter); Br.close (); I've edited my code to read each character in each row and manually create words. And I still can get the same results.
br = new buffford reader (new FileReader (file)); String line; String [] Arline; Stringbirder = new stringbilder (); {(Line = br.readline ()) = null) {// Check the word at the end of the last line if (word lang ()> gt; 0) {m_tree.insert (word.toString ()) ; Word.setLength (0); } Four [] lineschairs = new four [line.line ()]; Line.getChars (0, line.length (), lineChars, 0); (Four C: line chairs) {if (c == '') {// If we have a word then store and clear, then go to (word.length ()> gt; {m_tree. Insert (word.toString ()); Word.setLength (0); }} And {word.append (c); }}
The issue was that I do not have special characters in the middle of words Used to: i.e.: this four-word is not one and I do not even know that there is proper grammar or writing, but it was in this file and it definitely threw my calculation.
Comments
Post a Comment