I'm reading an Arabic file using Scanner and storing the text file in an ArrayList
and I have a Dictionary that contains some words, Positive and Negative words with thier rates.
for Example: سعيد +5 -4 سيء
then I check for each word in the text file with Dictionary if the word is negative rise the negative counter and if it is positive rise the positive counter and finally make a comparison to determine if the file is positive or negative
it works perfectly for English but not for Arabic, for some reason it skips the first word on the array even if its on Dictionary with exact match and if I pressed Enter at the beginning of the text file (new line) it works perfectly I tried to Add a new Line to ArrayList and files as alternate to the new line but it doesn't work It has to be added by pressing Enter Button
for (String word: wordsList) { // loop through user file
try { // compare words with dictionary
String line;
// read from the Dictionary file
File fileDir = new File("C:\\Users\\Ameera\\Desktop\\Dictionary.txt");
BufferedReader inDict = new BufferedReader(new InputStreamReader(
new FileInputStream(fileDir), "utf-8"));
while ((line = inDict()) != null) {
String strSplit[] = line.split("\t"); // Split Dictionary line after each tab to get the word only without its rate
// example will get (سعيد, سيد) only
/* سعيد +5
سيء -4
*/
if (strSplit[0].equals(word)) {
int rate2 = Integer.parseInt(strSplit[1]); // get word rate
sent += rate2; // add word rate to file totoal rate
}
}
} catch (Exception e) {
e.printStackTrace();
}
}