本文整理汇总了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();
}
}
}
示例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();
}
}
示例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);
}
}
示例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);
}
}
示例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;
}