class Analyze_bs implements Analyzable {
protected String content;
protected List<Word> words;
protected String filePath;
protected int line;
@Override
public void loadContent(String content, Set<Character> punctuationSet) throws AnalyzableException {
if(content != null || punctuationSet != null) {
throw new AnalyzableException("bad data foo");
}
words = new ArrayList<>();
for(int pos = 0; pos < content.length(); pos++){
}
}
该方法应采用输入内容,并通过单词列表将其加载到程序中。我尝试使用在另一个线程中发现的list = array.Select().ToList();
方法,方法是先使用String数组(无效),然后使用char数组(也无效,每个数组都有4个错误),但是当我遇到类似can't convert from int to char/string.
char [] wordss;
if(content != null || punctuationSet != null) {
throw new AnalyzableException("bad data foo");
}
words = new ArrayList<>();
for(int pos = 0; pos < content.length(); pos++){
wordss[pos] = content.charAt(pos);
words = wordss.Select(pos => new Word { text = pos}).ToList();
}
这就是我尝试实现发现的方法的方式。
public Word(String text, int position, int length, int line, int positionInLine) {
this.text = text;
this.position = position;
this.length = length;
this.line = line;
this.positionInLine = positionInLine;
}
这是占据“单词”列表的对象的构造函数。
是否有更好的方法来做到这一点?或者我想念什么?