本文整理汇总了Java中opennlp.tools.namefind.NameFinderME.clearAdaptiveData方法的典型用法代码示例。如果您正苦于以下问题:Java NameFinderME.clearAdaptiveData方法的具体用法?Java NameFinderME.clearAdaptiveData怎么用?Java NameFinderME.clearAdaptiveData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opennlp.tools.namefind.NameFinderME
的用法示例。
在下文中一共展示了NameFinderME.clearAdaptiveData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: nameMatches
import opennlp.tools.namefind.NameFinderME; //导入方法依赖的package包/类
private Set<String> nameMatches(String text) {
Set<String> names = new HashSet<String>();
NameFinderME nameFinder = new NameFinderME(personModel);
String tokens[];
Span matches[];
for (String sentence : convertToSentences(text)) {
tokens = convertToTokens(sentence);
matches = nameFinder.find(tokens);
List<String> s = Arrays
.asList(Span.spansToStrings(matches, tokens));
names.addAll(s);
}
nameFinder.clearAdaptiveData();
return names;
}
示例2: clearRecognizers
import opennlp.tools.namefind.NameFinderME; //导入方法依赖的package包/类
public void clearRecognizers() {
for (NameFinderME recognizer : recognizers)
recognizer.clearAdaptiveData();
}
示例3: retrieve
import opennlp.tools.namefind.NameFinderME; //导入方法依赖的package包/类
@Override
public List<Entity> retrieve(final String input) {
LOG.info("retrieve ...");
final List<Entity> list = new ArrayList<>();
final String[] sentences = FoxTextUtil.getSentences(input);
LOG.debug("sentences: " + sentences.length);
for (int i = 0; i < tokenNameFinderModels.length; i++) {
if (tokenNameFinderModels[i] != null) {
final NameFinderME nameFinder = new NameFinderME(tokenNameFinderModels[i]);
for (final String sentence : sentences) {
final String[] tokens = FoxTextUtil.getSentenceToken(sentence);
LOG.debug("tokens: " + tokens.length);
if ((tokens.length > 0) && tokens[tokens.length - 1].trim().isEmpty()) {
tokens[tokens.length - 1] = ".";
}
final Span[] nameSpans = nameFinder.find(tokens);
nameFinder.probs(nameSpans);
for (int ii = 0; ii < nameSpans.length; ii++) {
final Span span = nameSpans[ii];
String word = "";
for (int j = 0; j < (span.getEnd() - span.getStart()); j++) {
word += tokens[span.getStart() + j] + " ";
}
word = word.trim();
final float p = Entity.DEFAULT_RELEVANCE;
// if ((FoxCfg.get("openNLPDefaultRelevance") != null)
// && !Boolean.valueOf(FoxCfg.get("openNLPDefaultRelevance"))) {
// p = Double.valueOf(probs[ii]).floatValue();
// }
final String cl = mapTypeToSupportedType(span.getType());
if (cl != EntityClassMap.getNullCategory()) {
list.add(getEntity(word, cl, p, getToolName()));
}
}
}
nameFinder.clearAdaptiveData();
}
}
// TRACE
if (LOG.isTraceEnabled()) {
LOG.trace(list);
} // TRACE
return list;
}