a.addToIndexes(); Abbreviation abr = new Abbreviation(aJCas, shortStart, shortStart + shortF.length()); abr.setDefinedHere(true); // TODO abr.setExpan(longF); abr.setTextReference(a); abr.setConfidence(abrev[2]); abr.setComponentId(BioAdiAbreviationAnnotator.class .getName()); abr.addToIndexes();
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { String txt = jCas.getDocumentText(); Collection<Acronym> all_predictions = model.predict(txt); Map<String, Acronym> final_predictions = model .acronymsArrayToMap(all_predictions); for (String k : final_predictions.keySet()) { Acronym acro = final_predictions.get(k); LOG.debug("Acronym: {} start:{}", acro._shortForm + " :: " + acro._longForm, acro._start); int occurence = acro._start; Abbreviation abrev = new Abbreviation(jCas, occurence, occurence + acro._shortForm.length()); abrev.setExpan(acro._longForm); abrev.setDefinedHere(true); abrev.addToIndexes(); } } }
public static void expandAbbreviations(JCas jCas) { String pmId = getHeaderDocId(jCas); // otherwise was very slow Map<Abbreviation, List<Annotation>> cache = newHashMap(); List<Abbreviation> tmp = newLinkedList(select(jCas, Abbreviation.class)); for (Abbreviation abrev : tmp) { Annotation reference = abrev.getTextReference(); if (reference != null && reference instanceof Abbreviation) { Abbreviation aRef = (Abbreviation) reference; List<Annotation> covereds; if (cache.containsKey(aRef)) covereds = cache.get(aRef); else { covereds = getCovered(jCas, aRef, pmId); cache.put(aRef, covereds); } // copy them to the other abbreviation short-forms for (Annotation covered : covereds) { Annotation clone = (Annotation) covered.clone(); clone.setBegin(abrev.getBegin()); clone.setEnd(abrev.getEnd()); clone.addToIndexes(jCas); if (!clone.getCoveredText().equals(aRef.getCoveredText())) LOG.warn("'{}' not matching2 '{}' in " + pmId, clone.getCoveredText(), aRef.getCoveredText()); } } } }
} else if (o instanceof Abbreviation) { Abbreviation a = (Abbreviation) o; return "Abbrev[" + a.getCoveredText() + "]expan:" + a.getExpan() + "; defhere:" + a.getDefinedHere(); } else if (o instanceof Cooccurrence) { Cooccurrence c = (Cooccurrence) o; return "Abbreviation[" + a.getCoveredText() + "] expan:" + a.getExpan() + " textRef:" + a.getTextReference();
public FeatureStructure createFS(int addr, CASImpl cas) { if (Abbreviation_Type.this.useExistingInstance) { // Return eq fs instance if already created FeatureStructure fs = Abbreviation_Type.this.jcas.getJfsFromCaddr(addr); if (null == fs) { fs = new Abbreviation(addr, Abbreviation_Type.this); Abbreviation_Type.this.jcas.putJfsFromCaddr(addr, fs); return fs; } return fs; } else return new Abbreviation(addr, Abbreviation_Type.this); } };
Abbreviation abbrev = new Abbreviation(jCas, occurence, occurence + acro._shortForm.length()); abbrev.setExpan(acro._longForm); abbrev.setDefinedHere(true); } else { abbrev.setTextReference(reference); abbrev.setDefinedHere(false); abbrev.addToIndexes();