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


Java CasCopier类代码示例

本文整理汇总了Java中org.apache.uima.util.CasCopier的典型用法代码示例。如果您正苦于以下问题:Java CasCopier类的具体用法?Java CasCopier怎么用?Java CasCopier使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CasCopier类属于org.apache.uima.util包,在下文中一共展示了CasCopier类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import org.apache.uima.util.CasCopier; //导入依赖的package包/类
@Override
public void process(JCas jCas) throws AnalysisEngineProcessException {
  JCas sourceView;
  try {
    sourceView = jCas.getView(this.sourceViewName);
  } catch (CASException e) {
    throw new AnalysisEngineProcessException(e);
  }
  CasCopier copier = new CasCopier(sourceView.getCas(), jCas.getCas());
  Feature sofaFeature = jCas.getTypeSystem().getFeatureByFullName(CAS.FEATURE_FULL_NAME_SOFA);
  for (Event sourceEvent : JCasUtil.select(sourceView, Event.class)) {
    Event event = (Event) copier.copyFs(sourceEvent);
    event.setFeatureValue(sofaFeature, jCas.getSofa());
    if (event.getEventInstanceID() ==  null) {
      event.setEventInstanceID(event.getId().replaceAll("^e", "ei"));
    }
    event.addToIndexes();
  }
  for (Time sourceTime : JCasUtil.select(sourceView, Time.class)) {
    if (!(sourceTime instanceof DocumentCreationTime)) {
      Time time = (Time) copier.copyFs(sourceTime);
      time.setFeatureValue(sofaFeature, jCas.getSofa());
      time.addToIndexes();
    }
  }
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:27,代码来源:TempEval2013Evaluation.java

示例2: process

import org.apache.uima.util.CasCopier; //导入依赖的package包/类
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
  try {
    JCas copied = JCasFactory.createJCas(typesystem);
    CasCopier.copyCas(jcas.getCas(), copied.getCas(), true, true);
    String id = Strings.padStart(ProcessingStepUtils.getSequenceId(jcas), 4, '0');
    CasIOUtil.writeXmi(copied, new File(dir, id + ".xmi"));
  } catch (IOException | UIMAException e) {
    e.printStackTrace();
  }
}
 
开发者ID:oaqa,项目名称:bioasq,代码行数:12,代码来源:CasSerializer.java

示例3: next

import org.apache.uima.util.CasCopier; //导入依赖的package包/类
@Override
public AbstractCas next() throws AnalysisEngineProcessException {
	this.enableHasNext(false);
	JCas cas = this.getEmptyJCas();
	try {
		CasCopier.copyCas(this.cas.getCas(), cas.getCas(), false);
		StringBuilder builder = new StringBuilder();
		int begin = 0;
		int end = 0;
		for (Token token : this.getTokens()) {
			begin = builder.length();
			builder.append(token.word());
			end = builder.length();
			builder.append(' ');
			WordAnnotation annotation = new WordAnnotation(cas, begin, end);
			annotation.setTag(token.tag());
			annotation.setLemma(token.lemma());
			annotation.addToIndexes();
		}
		cas.setDocumentText(builder.toString());
		cas.setDocumentLanguage("lv");
		this.getTokens().clear();
		return cas;
	} catch (Exception e) {
		cas.release();
		throw new AnalysisEngineProcessException(e);
	}
}
 
开发者ID:termsuite,项目名称:termsuite-core,代码行数:29,代码来源:TildeTokenizer.java

示例4: process

import org.apache.uima.util.CasCopier; //导入依赖的package包/类
@Override
public void process(JCas jCas) throws AnalysisEngineProcessException {

    // because of later evaluation, copy annotation to view_gold (later used
    // by AnnotationEvaluator) and remove it from view_system.
    Collection<? extends Annotation> goldsFromInitialView = select(jCas,
            goldAnnotation);
    JCas goldView = null;
    try {
        goldView = jCas.createView(VIEW_GOLD);
    } catch (Throwable e) {
        throw new AnalysisEngineProcessException(
                NO_RESOURCE_FOR_PARAMETERS, new Object[] { VIEW_GOLD }, e);
    }

    CasCopier casCopier = new CasCopier(jCas.getCas(), goldView.getCas());

    goldView.setDocumentText(jCas.getDocumentText());
    // view_system annot. stored in List for later delete
    // (conccurentModifExeption)
    List<Annotation> toDelete = new ArrayList<Annotation>();
    for (Annotation g : goldsFromInitialView) {
        goldView.addFsToIndexes(casCopier.copyFs(g));
        if (deleteFrom) {
            toDelete.add(g);
        }
    }
    Annotation[] arr = toDelete.toArray(new Annotation[toDelete.size()]);
    for (int i = 0; i < arr.length; i++) {
        arr[i].removeFromIndexes(jCas);
    }
}
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:33,代码来源:EvaluationPreprocessorAnnotator.java

示例5: next

import org.apache.uima.util.CasCopier; //导入依赖的package包/类
public AbstractCas next() throws AnalysisEngineProcessException {
  JCas jCasDst = getEmptyJCas();
  
  jCasDst.setDocumentLanguage(mBaseJcas.getDocumentLanguage());
  
  //logger.info("*** NEXT! ***");

  CasCopier   copier = new CasCopier(mBaseJcas.getCas(), jCasDst.getCas());                  
  
  if (mAnswId < 0) {
    Question yaq = JCasUtil.selectSingle(mBaseJcas, Question.class);
  
    jCasDst.setDocumentText(mQuestJCas.getDocumentText());
    // Copy tags produced by the sentence splitter, tagger, and tokenizer
    copyAnnotations(mQuestJCas, jCasDst);
    
    // After copying attributes, correct start/end 
    Question dstQuest = (Question)copier.copyFs(yaq);
    dstQuest.setBegin(0);
    dstQuest.setEnd(yaq.getCoveredText().length());
    // start/end are corrected, can now index 
    dstQuest.addToIndexes();                 
    
    mAnswId = 0;
    
    PrintInfoHelper.printInfo1(logger, jCasDst);
    
    return jCasDst;
  }
  
  JCas    answJCas = mAnswerJCas.get(mAnswId);
  Answer  yan      = mAnswerAnnot.get(mAnswId);
  
  jCasDst.setDocumentText(answJCas.getDocumentText());
  
  // After copying attributes, correct start/end indices
  Answer dstAnsw = (Answer)copier.copyFs(yan);
  dstAnsw.setBegin(0);
  dstAnsw.setEnd(yan.getCoveredText().length());
  // start/end are corrected, can now index 
  dstAnsw.addToIndexes();
  
  // Copy tags produced by the sentence splitter, tagger, and tokenizer
  copyAnnotations(answJCas, jCasDst);
  
  ++mAnswId; 
  
  PrintInfoHelper.printInfo1(logger, jCasDst);
  
  return jCasDst;
}
 
开发者ID:oaqa,项目名称:knn4qa,代码行数:52,代码来源:InputSplitterClearAnnot1.java


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