当前位置: 首页>>代码示例>>Java>>正文


Java JCasUtil.indexCovered方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:uhh-lt,项目名称:LT-ABSA,代码行数:48,代码来源:AspectTermWriter.java

示例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);

	});
}
 
开发者ID:tenode,项目名称:baleen-extras,代码行数:20,代码来源:OpenNLPParser.java


注:本文中的org.apache.uima.fit.util.JCasUtil.indexCovered方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。