本文整理汇总了Java中org.apache.uima.fit.util.JCasUtil.indexCovered方法的典型用法代码示例。如果您正苦于以下问题:Java JCasUtil.indexCovered方法的具体用法?Java JCasUtil.indexCovered怎么用?Java JCasUtil.indexCovered使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.uima.fit.util.JCasUtil
的用法示例。
在下文中一共展示了JCasUtil.indexCovered方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: process
import org.apache.uima.fit.util.JCasUtil; //导入方法依赖的package包/类
@Override
public void process(JCas jCas) throws AnalysisEngineProcessException {
try {
FileWriter outputWriter = new FileWriter(OutputFile);
Map<Sentence, Collection<AspectTarget>> sentencesAspect = JCasUtil.indexCovered(jCas,
Sentence.class, AspectTarget.class);
List<Sentence> sentences = new ArrayList<>(sentencesAspect.keySet());
// sort sentences by sentence
Collections.sort(sentences, new Comparator<Sentence>() {
@Override
public int compare(Sentence arg0, Sentence arg1)
{
return arg0.getBegin() - arg1.getBegin();
}
});
for (Sentence sentence : sentences) {
for (AspectTarget aspectAnnotation : sentencesAspect.get(sentence)) {
String text = aspectAnnotation.getCoveredText().replace(" ", "");
StringBuilder sb = new StringBuilder();
sb.append(text);
sb.append(TAB);
if (isGold) {
sb.append(JCasUtil.selectCovered(jCas, GoldAspectTarget.class, aspectAnnotation)
.get(0).getAspectTargetType());
}
sb.append(TAB);
sb.append(aspectAnnotation.getAspectTargetType());
sb.append(LF);
outputWriter.write(sb.toString());
}
outputWriter.write(LF);
}
outputWriter.close();
getContext().getLogger().log(Level.INFO,
"Output written to: " + OutputFile.getAbsolutePath());
}
catch (IOException e) {
e.printStackTrace();
}
}
示例2: doProcess
import org.apache.uima.fit.util.JCasUtil; //导入方法依赖的package包/类
@Override
public void doProcess(final JCas jCas) throws AnalysisEngineProcessException {
// For each sentence (in the JCas)e, we recreate the spans from our
// WordTokens.
final Map<Sentence, Collection<WordToken>> sentences = JCasUtil.indexCovered(jCas, Sentence.class,
WordToken.class);
sentences.entrySet().stream().filter(e -> !e.getValue().isEmpty()).forEach(e -> {
final Sentence sentence = e.getKey();
final Collection<WordToken> tokens = e.getValue();
final Parse parsed = parseSentence(sentence, tokens);
updatePhraseChunks(jCas, sentence, parsed);
});
}