我制作了一个数组列表,用于存储文本文件中的单词。但现在我需要创建一个单独的数组列表,它只从文件中的单词中获取字母,将它们恢复为小写,并删除单词中或其周围的所有标点符号。所以基本上它会恢复所有单词,并从中删除所有提到的元素。
List<String> grams = new ArrayList<String>();
for(String gram : words){
gram = gram.trim();
for(int i=0,int l=gram.size();i<l;++i){ //this line is wrong
const String punChars = ",[]:'-!_().?\/~"; //this line is wrong
if(gram.indexOf(i) != -1){ //this line is wrong
gram.remove(i); //this line is wrong
}
gram.add(gram.remove(0).toLowerCase()); //this line is wrong
}
}
我基本上是在尝试读取数组中选择字符串中的每个字符,因为我将它放入新的数组列表中,然后如果它周围或其中有任何标点符号,我将其删除:我尝试使用 const 来存储标点符号值,然后我使用 if 语句检查字符串以删除字符串中的该位置。
接下来我尝试添加单词,但删除大写并将其更改为小写。
我有点迷茫,不确定我在这里用这个位做什么......