本文整理匯總了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));
}