本文整理汇总了Java中opennlp.tools.util.StringList类的典型用法代码示例。如果您正苦于以下问题:Java StringList类的具体用法?Java StringList怎么用?Java StringList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringList类属于opennlp.tools.util包,在下文中一共展示了StringList类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: workAroundToSaveNGramModel
import opennlp.tools.util.StringList; //导入依赖的package包/类
private static void workAroundToSaveNGramModel(OutputStream out, NGramModel ngm) {
PrintWriter pw = new PrintWriter(out);
Iterator<StringList> iterator = ngm.iterator();
while (iterator.hasNext()) {
StringList sl = iterator.next();
int count = ngm.getCount(sl);
pw.print(sl.toString());
pw.print(' ');
pw.print(count);
pw.println();
}
pw.flush();
}
示例2: updateOOV
import opennlp.tools.util.StringList; //导入依赖的package包/类
public void updateOOV(String[] s) {
for(int i = 0; i < s.length; i++) {
if(ngram[0].contains(new StringList(s[i]))) {
numberOfTokensInVocabulary++;
} else {
numberOfTokensOutOfVocabulary++;
}
}
}
示例3: updateCoverage
import opennlp.tools.util.StringList; //导入依赖的package包/类
public void updateCoverage(String[] s) {
for(int i = s.length-1; i >= nGramLength; i--) {
if(ngram[ngram.length-1].contains(new StringList(Arrays.copyOfRange(s, i-nGramLength, i)))) {
numberOfNGramsInCoverage++;
} else {
numberOfNGramsOutofCoverage++;
}
}
}
示例4: getNumberOfNGrams
import opennlp.tools.util.StringList; //导入依赖的package包/类
private int getNumberOfNGrams(NGramModel ngm) {
Iterator<StringList> iterator = ngm.iterator();
int count = 0;
while(iterator.hasNext()) {
iterator.next();
count++;
}
return count;
}
示例5: addNGrams
import opennlp.tools.util.StringList; //导入依赖的package包/类
private void addNGrams(String string, int length, NGramModel ngm) {
String input[] = string.split("( )+");
numberOfTokens += input.length;
for(int i = 0; i < input.length-length+1; i++) {
String[] ngram = new String[length];
for(int j = 0; j < length; j++) {
ngram[j] = input[i+j];
}
ngm.add(new StringList(ngram));
}
}
示例6: exists
import opennlp.tools.util.StringList; //导入依赖的package包/类
public boolean exists(String[] s) {
return ngram[s.length-1].contains(new StringList(s));
}
示例7: counts
import opennlp.tools.util.StringList; //导入依赖的package包/类
public int counts(String[] s) {
return ngram[s.length-1].getCount(new StringList(s));
}