私は、American National Corpus を使用して、英語の単語の頻度を取得しています。ファイル構造は次のとおりです (これは大きなファイルで、~8 MB です)。
Word1 Lemma1 Pos1 Frequency1
Word2 Lemma2 Pos2 Frequency2
Word3 Lemma3 Pos3 Frequency3
これが私のJavaクラスですが、非常に遅いです...どうすれば速度を上げることができますか? (特定の単語に関連する頻度を知りたい)
public static int frequency (String word) throws Exception {
int ft=0;
int fc=0;
int exit=0;
String frow;
String[] separated = new String[10];
String fwordC = "...";
String fwordP = "...";
Scanner fscan = new Scanner(new File("./ANC-all-lemma.data"));
fscan.useDelimiter("\n");
while(fscan.hasNext()){
frow = fscan.next();
separated = frow.split(" ");
separated[0]= separated[0].replaceAll("(\\r|\\n)", "");
fwordC = separated[0]; //set current word
if (fwordC.equalsIgnoreCase(word)) {
System.out.println("Found!!!");
return(separated[3]);
}
}
}
本当にありがとう!