有沒有辦法在停用詞(例如,''''''等)使用基於JAVA的文檔分類器(如OpenNLP)等。或者如果您自己(使用JAVA)做什麼可能是最有效的方法(假定字符串比較效率低下)。另外,鑑於每個文件本身並不那麼大,即平均大約100個字,但假定文件數量很大。什麼是使用Java從文本中刪除停用詞(例如,等)的有效方式
E.g.,
// Populate the stop words to a list
List<String> stopWordsList = ArrayList<>();
// Iterate through a list of documents
String currentDoc = getCurrentDoc();
String[] wordsArray = currentDoc.split(" ");
for (String word : wordsArray) {
if (stopWordsList.contains(word)){
// Drop it
}
}
恩,不,這不是一個好主意。 「a」是一個停用詞。簡單地做一個替換就會把「apple」變成「pple」,這顯然不是你想要的。 – dhg