/** * {@inheritDoc} */ @Override public String getText() { return _jcasAnnotation.getCoveredText(); } }
public static boolean isFamilyTerm(Annotation arg) { return arg.getCoveredText().toLowerCase() .matches("(father|dad|mother|mom|bro|sis|sib|cousin|aunt|uncle|grandm|grandp|grandf|" + "wife|spouse|husband|child|offspring|progeny|son|daughter|nephew|niece|kin|family).*"); }
private boolean findCoveredTextInSpan(JCas jcas, int annotationType, int beginOffset, int endOffset, String[] searchStrs) { boolean foundCoveredText = false; Iterator coveredTextIter = FSUtil.getAnnotationsIteratorInSpan(jcas, annotationType, beginOffset, endOffset); while (coveredTextIter.hasNext() && !foundCoveredText) { Annotation ann= (Annotation) coveredTextIter.next(); for(int i=0; i<searchStrs.length && !foundCoveredText; i++) foundCoveredText = searchStrs[i].equals(ann.getCoveredText()); } return foundCoveredText; }
public List<Feature> extract(JCas view, T focusAnnotation) throws CleartkExtractorException { String surf = focusAnnotation.getCoveredText(); boolean b = Character.isUpperCase(surf.charAt(0)) && surf.endsWith(suf); return Arrays.asList(new Feature("Suffix_" + suf, String.valueOf(b))); } }
/** * Given an annotation, retrieve its last word. */ public static String getLastWord(JCas systemView, Annotation annotation) { List<WordToken> tokens = JCasUtil.selectCovered(systemView, WordToken.class, annotation); if(tokens.size() == 0) { return annotation.getCoveredText(); } WordToken lastToken = tokens.get(tokens.size() - 1); return lastToken.getCoveredText(); }
private String toString(Annotation a) { return String.format("%s[%d,%d]{%s}", a.getClass().getSimpleName(), a.getBegin(), a.getEnd(), a.getCoveredText()); }
/** Equality expressions to aid in converting between DepNodes and CAS objects */ public static boolean equalCoverage(Annotation annot1,Annotation annot2) { if (annot1==null || annot2==null) return false; return annot1.getBegin()==annot2.getBegin() && annot1.getEnd()==annot2.getEnd() && annot1.getCoveredText().equals(annot2.getCoveredText()); }
/** Checks if one annotation subsumes another */ public static boolean doesSubsume(Annotation annot1,Annotation annot2) { if (annot1==null || annot2==null) return false; return annot1.getBegin()<=annot2.getBegin() && annot1.getEnd()>=annot2.getEnd() && annot1.getCoveredText().contains(annot2.getCoveredText()); }
@Override public String text() { if (getItem() == null) { return ""; } else { return getItem().getCoveredText(); } }
/** Equality expressions to aid in converting between DepNodes and CAS objects */ public static boolean equalCoverage(Annotation annot1,Annotation annot2) { return annot1.getBegin()==annot2.getBegin() && annot1.getEnd()==annot2.getEnd() && annot1.getCoveredText()==annot2.getCoveredText(); } // public static boolean equalCoverage(Annotation annot,UimaDepNode udNode) {
static String format(Annotation ann) { String result; if (ann.getEnd() == Integer.MIN_VALUE || ann.getBegin() == Integer.MAX_VALUE) { result = "<no-spanned-text>"; } else { result = String.format("\"%s\"[%d,%d]", ann.getCoveredText(), ann.getBegin(), ann.getEnd()); } return String.format("%s(%s)", ann.getClass().getSimpleName(), result); }
@Override protected Map<String, Double> getDisambiguation(JCas aJCas, WSDItem wsdItem, Annotation context) throws SenseInventoryException { // TODO: Currently this just passes the covered text as the context. // It might be better to pass a collection of annotations (for example, // lemmas) return wsdMethod.getDisambiguation( wsdItem.getSubjectOfDisambiguation(), context.getCoveredText()); }
static String format(Annotation ann) { String result; if (ann.getEnd() == Integer.MIN_VALUE || ann.getBegin() == Integer.MAX_VALUE) { result = "<no-spanned-text>"; } else { result = String.format("\"%s\"[%d,%d]", ann.getCoveredText(), ann.getBegin(), ann.getEnd()); } return String.format("%s(%s)", ann.getClass().getSimpleName(), result); }
@Override public List<Feature> extract(JCas view, Annotation focusAnnotation) throws CleartkExtractorException { String text = focusAnnotation.getCoveredText(); return ccpf.apply(new Feature(null, text)); }
public FastLookupToken( final Annotation jcasAnnotation ) { _textSpan = new DefaultTextSpan( jcasAnnotation.getBegin(), jcasAnnotation.getEnd() ); _text = jcasAnnotation.getCoveredText().toLowerCase(); if ( jcasAnnotation instanceof WordToken ) { final String canonicalForm = ((WordToken)jcasAnnotation).getCanonicalForm(); // If canonical is not null AND not the same as the plain text then it is a valid variant for lookup if ( canonicalForm != null && !canonicalForm.equals( _text ) ) { _variant = canonicalForm; } } }
public PairAttributeCalculator (JCas jcas, Markable m1, Markable m2) { super(jcas); this.m1 = m1; this.m2 = m2; this.a1 = m1.getContent(); this.a2 = m2.getContent(); ms1 = m1.getCoveredText(); ms2 = m2.getCoveredText(); es1 = a1.getCoveredText(); es2 = a2.getCoveredText(); alias = isAlias(); }
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { if (windowClass != null) { for (Annotation window : JCasUtil.select(jCas, windowClass)) { String text = window.getCoveredText(); createParentheticals(jCas, text, window.getBegin()); } } else { String text = jCas.getDocumentText(); createParentheticals(jCas, text, 0); } }
@Override protected Map<String, Double> getDisambiguation(JCas aJCas, WSDItem wsdItem, Annotation context) throws SenseInventoryException { // TODO: Currently this just passes the covered text as the context. // It might be better to pass a collection of annotations (for example, // lemmas) return wsdMethod.getDisambiguation( wsdItem.getSubjectOfDisambiguation(), POS.valueOf(wsdItem.getPos()), context.getCoveredText()); }
public CasAssert doesNotContainAnnotation(Type annotationType, int begin, int end) { for(Annotation a:getAnnotationList(annotationType)) if(a.getBegin() == begin && a.getEnd() == end) failWithMessage("Expected to not contain annotation <%s[%s,%s]> but actually contains it: <%s>", annotationType.getShortName(),begin, end, a.getCoveredText() ); return this; }
@Override public ImmutableSpanTextLabel apply(final Annotation annotation) { final ImmutableSpan span = new ImmutableSpan(annotation.getBegin(), annotation.getEnd()); final ImmutableSpanText spanText = new ImmutableSpanText(span, annotation.getCoveredText()); final Map<Attribute, Object> attrs = createAttrMap(annotation); return new ImmutableSpanTextLabel(spanText, annotation.getType().getShortName(), attrs); }