-1
HashSet
에 저장중인 파일에서 정지 단어를 읽습니다. 난 String
로 HashSet
을 말하면 정지 단어를 확인합니다. 문자열이 중지 단어에 대해 올바르게 검사되지 않음
String
-variable에, 내 출력이 "예"와 같이, 하나의 중지 단어를 넣어합니다. 내가 좋아하는 뭔가를 넣어 경우, 또는 두 가지 모두
String
-variables가 중지 단어가 포함되어 있다는 사실에도 불구하고, 출력은 "아니오"이다 "는 사과이다" "애플은입니다". 내가 제대로 질문을 읽어 아니에요 느낌이
private static HashSet<String> readFile(){
Scanner x = null;
HashSet<String> hset = new HashSet<String>();
try {
x = new Scanner(new File("StopWordsEnglish"));
while(x.hasNext()){
hset.add(x.next());
}
} catch(Exception e) {
e.printStackTrace();
} finally {
x.close();
}
return hset;
}
public static void removeStopWords(){
HashSet<String> hset = readFile();
System.out.println(hset.size());
System.out.println("Enter a word to search for: ");
String search = "is";
String s = search.toLowerCase();
System.out.println(s);
if (hset.contains(s)) {
System.out.println("Yes");
} else {
System.out.println("No");
}
}
디버거를 사용하여이 경우에 할 수있는 좋은 적절한 것 같은 소리 공간에 – Jens