我有一个包含大量单词的字符串,我有一个文本文件,其中包含一些需要从我的字符串中删除的停用词.假设我有一个字符串
s="I love this phone, its super fast and there's so much new and cool things with jelly bean....but of recently I've seen some bugs."
Run Code Online (Sandbox Code Playgroud)
删除停用词后,字符串应为:
"love phone, super fast much cool jelly bean....but recently bugs."
Run Code Online (Sandbox Code Playgroud)
我已经能够实现这一点,但我面临的问题是,当字符串中有相邻的停用词时,它只删除第一个,我得到的结果如下:
"love phone, super fast there's much and cool with jelly bean....but recently seen bugs"
Run Code Online (Sandbox Code Playgroud)
这是我的stopwordslist.txt文件:停用词
我怎么解决这个问题.这是我到目前为止所做的:
int k=0,i,j;
ArrayList<String> wordsList = new ArrayList<String>();
String sCurrentLine;
String[] stopwords = new String[2000];
try{
FileReader fr=new FileReader("F:\\stopwordslist.txt");
BufferedReader br= new BufferedReader(fr);
while ((sCurrentLine = …Run Code Online (Sandbox Code Playgroud)