List<String> annoPerFeatures = new ArrayList<>(); featurePerLayer.putIfAbsent(aType.getName(), new LinkedHashSet<>()); int ref = getRefId(aType, aFs, aUnit); if(ambigUnits.get(aType.getName()).get(getFirstUnit(aUnit))!=null && ambigUnits.get(aType.getName()).get(getFirstUnit(aUnit)).equals(false)){ ref = 0; if(ambigUnits.get(aType.getName()).get(getFirstUnit(aUnit))== null && ambigUnits.get(aType.getName()).get(aUnit).equals(false)){ ref = 0; Type tType = targetFs.getType(); AnnotationUnit firstUnit = getFirstUnit(targetFs); ref = getRefId(tType, targetFs, firstUnit); } else { role = replaceEscapeChars(role); } else { annotation = replaceEscapeChars(annotation); setAnnoFeature(aIsMultiToken, aIsFirst, annoPerFeatures, annotation); setAnnoFeature(aIsMultiToken, aIsFirst, annoPerFeatures, "*"+ (ref > 0 ? "[" + ref + "]" : ""));
throws AnalysisEngineProcessException try (OutputStream docOS = getOutputStream(aJCas, filenameSuffix)) { resetVariables(); setSlotLinkTypes(); setLinkMaps(aJCas); setTokenSentenceAddress(aJCas); setAmbiguity(aJCas); setSpanAnnotation(aJCas); setChainAnnotation(aJCas); setRelationAnnotation(aJCas); writeHeader(docOS); for (AnnotationUnit unit : units) { if (sentenceUnits.containsKey(unit)) { String[] sentWithNl = sentenceUnits.get(unit).split("\n"); IOUtils.write(LF + "#Text=" + escapeSpecial(sentWithNl[0]) + LF, docOS, encoding); IOUtils.write("#Text=" + escapeSpecial(sentWithNl[i + 1]) + LF, docOS, encoding);
setChainAnnoPerFeature(aAnnotationsPertype, aType, aFs, aUnit, aLinkNo, achainNo, false, false); sta.setEnd(aFs.getEnd()); sta.setText(aFs.getCoveredText()); boolean isMultiToken = isMultiToken(aFs); boolean isFirst = true; Set<AnnotationUnit> sus = new LinkedHashSet<>(); for (AnnotationUnit newUnit : getSubUnits(sta, sus)) { setChainAnnoPerFeature(aAnnotationsPertype, aType, aFs, newUnit, aLinkNo, achainNo, isMultiToken, isFirst); isFirst = false;
continue; int ref = getRefId(type, fs, depUnit); String annotation = fs.getFeatureValueAsString(feature); if (annotation == null) { annotation = replaceEscapeChars(annotation);
ambigUnits.putIfAbsent(type.getName(), new HashMap<>()); for (AnnotationFS fs : CasUtil.select(aJCas.getCas(), type)) { AnnotationUnit unit = getFirstUnit(fs); if (isMultipleTokenAnnotation(fs.getBegin(), fs.getEnd())) { SubTokenAnno sta = new SubTokenAnno(); sta.setBegin(fs.getBegin()); sta.setText(fs.getCoveredText()); Set<AnnotationUnit> sus = new LinkedHashSet<>(); for (AnnotationUnit newUnit : getSubUnits(sta, sus)) { ambigUnits.get(type.getName()).put(newUnit, true);
setSpanAnnoPerFeature(annotationsPertype, type, fs, unit, false, false); sta.setEnd(fs.getEnd()); sta.setText(fs.getCoveredText()); boolean isMultiToken = isMultiToken(fs); boolean isFirst = true; Set<AnnotationUnit> sus = new LinkedHashSet<>(); for (AnnotationUnit newUnit : getSubUnits(sta, sus)) { setSpanAnnoPerFeature(annotationsPertype, type, fs, newUnit, isMultiToken, isFirst); isFirst = false;
for (AnnotationUnit unit : units) { if (unit.begin >= newUnit.begin && unit.end >= newUnit.end) { updateUnitLists(tmpUnits, unit, newUnit); aSubUnits.add(newUnit); units = new ArrayList<>(tmpUnits); AnnotationUnit newUnit = new AnnotationUnit(aSTA.getBegin(), aSTA.getEnd(), false, aSTA.getText()); updateUnitLists(tmpUnits, unit, newUnit); aSTA.getText()); updateUnitLists(tmpUnits, unit, newUnit); aSubUnits.add(newUnit); updateUnitLists(tmpUnits, unit, newUnit); aSTA.setBegin(getNextUnitBegin(aSTA.getBegin())); getSubUnits(aSTA, aSubUnits); aSubUnits.add(newUnit); updateUnitLists(tmpUnits, prevUnit, newUnit); getSubUnits(aSTA, aSubUnits);
AnnotationUnit govUnit = getFirstUnit( getUnit(govFs.getBegin(), govFs.getEnd(), govFs.getCoveredText())); if(ambigUnits.get(govType.getName()).get(govUnit)==null){ govUnit = getUnit(govFs.getBegin(), govFs.getEnd(), govFs.getCoveredText()); AnnotationUnit depUnit = getFirstUnit( getUnit(depFs.getBegin(), depFs.getEnd(), depFs.getCoveredText())); if(ambigUnits.get(govType.getName()).get(depUnit)==null){ depUnit = getUnit(depFs.getBegin(), depFs.getEnd(), depFs.getCoveredText()); setRelationAnnoPerFeature(annotationsPertype, type, fs, depUnit, govUnit, govRef, depRef, govType);
for (FeatureStructure chainFs : selectFS(aJCas.getCas(), type)) { AnnotationFS linkFs = (AnnotationFS) chainFs.getFeatureValue(chainFirst); AnnotationUnit unit = getUnit(linkFs.getBegin(), linkFs.getEnd(), linkFs.getCoveredText()); Type lType = linkFs.getType(); AnnotationFS nextLinkFs = (AnnotationFS) linkFs.getFeatureValue(linkNext); if (nextLinkFs != null) { addChinFeatureAnno(annotationsPertype, lType, linkFs, unit, linkNo, chainNo); } else { addChinFeatureAnno(annotationsPertype, lType, linkFs, unit, linkNo, chainNo); unit = getUnit(linkFs.getBegin(), linkFs.getEnd(), linkFs.getCoveredText());
annotation = replaceEscapeChars(annotation);
private AnnotationUnit getFirstUnit(AnnotationUnit aUnit) { SubTokenAnno sta = new SubTokenAnno(); sta.setBegin(aUnit.begin); sta.setEnd(aUnit.end); sta.setText(aUnit.token); Set<AnnotationUnit> sus = new LinkedHashSet<>(); AnnotationUnit firstUnit = null; for (AnnotationUnit u : getSubUnits(sta, sus)) { firstUnit = u; break; } return firstUnit; }
ambigUnits.putIfAbsent(type.getName(), new HashMap<>()); for (AnnotationFS fs : CasUtil.select(aJCas.getCas(), type)) { AnnotationUnit unit = getFirstUnit(fs); if (isMultipleTokenAnnotation(fs.getBegin(), fs.getEnd())) { SubTokenAnno sta = new SubTokenAnno(); sta.setBegin(fs.getBegin()); sta.setText(fs.getCoveredText()); Set<AnnotationUnit> sus = new LinkedHashSet<>(); for (AnnotationUnit newUnit : getSubUnits(sta, sus)) { ambigUnits.get(type.getName()).put(newUnit, true);
setSpanAnnoPerFeature(annotationsPertype, type, fs, unit, false, false); sta.setEnd(fs.getEnd()); sta.setText(fs.getCoveredText()); boolean isMultiToken = isMultiToken(fs); boolean isFirst = true; Set<AnnotationUnit> sus = new LinkedHashSet<>(); for (AnnotationUnit newUnit : getSubUnits(sta, sus)) { setSpanAnnoPerFeature(annotationsPertype, type, fs, newUnit, isMultiToken, isFirst); isFirst = false;
for(AnnotationUnit unit: units){ if(unit.begin>=newUnit.begin && unit.end>=newUnit.end){ updateUnitLists(tmpUnits, unit, newUnit); aSubUnits.add(newUnit); units = new ArrayList<>(tmpUnits); if(unit.begin==aSTA.begin){ AnnotationUnit newUnit = new AnnotationUnit(aSTA.getBegin(), aSTA.getEnd(), false, aSTA.getText()); updateUnitLists(tmpUnits, unit, newUnit); AnnotationUnit newUnit = new AnnotationUnit(aSTA.getBegin(), aSTA.getEnd(), false, aSTA.getText()); updateUnitLists(tmpUnits, unit, newUnit); aSubUnits.add(newUnit); updateUnitLists(tmpUnits, unit, newUnit); aSTA.setBegin(getNextUnitBegin(aSTA.getBegin())); getSubUnits(aSTA, aSubUnits); aSubUnits.add(newUnit); updateUnitLists(tmpUnits, prevUnit, newUnit); getSubUnits(aSTA, aSubUnits);
AnnotationUnit govUnit = getFirstUnit( getUnit(govFs.getBegin(), govFs.getEnd(), govFs.getCoveredText())); if (ambigUnits.get(govType.getName()).get(govUnit) == null) { govUnit = getUnit(govFs.getBegin(), govFs.getEnd(), govFs.getCoveredText()); AnnotationUnit depUnit = getFirstUnit( getUnit(depFs.getBegin(), depFs.getEnd(), depFs.getCoveredText())); if (ambigUnits.get(govType.getName()).get(depUnit) == null) { depUnit = getUnit(depFs.getBegin(), depFs.getEnd(), depFs.getCoveredText()); setRelationAnnoPerFeature(annotationsPertype, type, fs, depUnit, govUnit, govRef, depRef, govType);
continue; int ref = getRefId(type, fs, depUnit); String annotation = fs.getFeatureValueAsString(feature); if (annotation == null) { annotation = replaceEscapeChars(annotation);
for (FeatureStructure chainFs : selectFS(aJCas.getCas(), type)) { AnnotationFS linkFs = (AnnotationFS) chainFs.getFeatureValue(chainFirst); AnnotationUnit unit = getUnit(linkFs.getBegin(), linkFs.getEnd(), linkFs.getCoveredText()); Type lType = linkFs.getType(); AnnotationFS nextLinkFs = (AnnotationFS) linkFs.getFeatureValue(linkNext); if (nextLinkFs != null) { addChinFeatureAnno(annotationsPertype, lType, linkFs, unit, linkNo, chainNo); addChinFeatureAnno(annotationsPertype, lType, linkFs, unit, linkNo, chainNo); linkNo++; if (nextLinkFs != null) { unit = getUnit(linkFs.getBegin(), linkFs.getEnd(), linkFs.getCoveredText());
annotation = replaceEscapeChars(annotation);
private AnnotationUnit getFirstUnit(AnnotationUnit aUnit) { SubTokenAnno sta = new SubTokenAnno(); sta.setBegin(aUnit.begin); sta.setEnd(aUnit.end); sta.setText(aUnit.token); Set<AnnotationUnit> sus = new LinkedHashSet<>(); AnnotationUnit firstUnit = null; for (AnnotationUnit u : getSubUnits(sta, sus)) { firstUnit = u; break; } return firstUnit; }
throws AnalysisEngineProcessException try (OutputStream docOS = getOutputStream(aJCas, filenameSuffix)) { resetVariables(); setSlotLinkTypes(); setLinkMaps(aJCas); setTokenSentenceAddress(aJCas); setAmbiguity(aJCas); setSpanAnnotation(aJCas); setChainAnnotation(aJCas); setRelationAnnotation(aJCas); writeHeader(docOS); for (AnnotationUnit unit : units) { if (sentenceUnits.containsKey(unit)) { String[] sentWithNl = sentenceUnits.get(unit).split("\n"); IOUtils.write(LF + "#Text=" + escapeSpecial(sentWithNl[0]) + LF, docOS, encoding); IOUtils.write("#Text=" + escapeSpecial(sentWithNl[i + 1]) + LF, docOS, encoding);