/** * if this is a word, return the stemmed word, if available - i.e. canonicalForm not null and not empty. * else return the covered text. * @see SetupAuiFirstWord */ public String getText() { if (iv_jcasAnnotObj instanceof WordToken) { WordToken wt = (WordToken) iv_jcasAnnotObj; if (wt.getCanonicalForm() != null && wt.getCanonicalForm().length() > 0) return wt.getCanonicalForm(); } return iv_jcasAnnotObj.getCoveredText(); }
/** * if this is a word, return the stemmed word, if available - i.e. canonicalForm not null and not empty. * else return the covered text. * @see SetupAuiFirstWord */ public String getText() { if (iv_jcasAnnotObj instanceof WordToken) { WordToken wt = (WordToken) iv_jcasAnnotObj; if (wt.getCanonicalForm() != null && wt.getCanonicalForm().length() > 0) return wt.getCanonicalForm(); } return iv_jcasAnnotObj.getCoveredText(); }
/** * In some pipelines LVG is not run, hence a canonical form does not exist. * In order to prevent NPEs, this method checks for null values of canonical form and covered text * * @param wordToken of interest * @return The first non-null of the word token's canonical form, covered text or {@link #MISSING_WORDTOKEN_TEXT}. */ static public String getCanonicalForm( final WordToken wordToken ) { final String canonicalForm = wordToken.getCanonicalForm(); if ( canonicalForm != null && !canonicalForm.isEmpty() ) { return canonicalForm; } final String coveredText = wordToken.getCoveredText(); if ( coveredText == null ) { return MISSING_WORDTOKEN_TEXT; } return coveredText; }
/** * In some pipelines LVG is not run, hence a canonical form does not exist. * In order to prevent NPEs, this method checks for null values of canonical form and covered text * * @param wordToken of interest * @return The first non-null of the word token's canonical form, covered text or {@link #MISSING_WORDTOKEN_TEXT}. */ static public String getCanonicalForm( final WordToken wordToken ) { final String canonicalForm = wordToken.getCanonicalForm(); if ( canonicalForm != null && !canonicalForm.isEmpty() ) { return canonicalForm; } final String coveredText = wordToken.getCoveredText(); if ( coveredText == null ) { return MISSING_WORDTOKEN_TEXT; } return coveredText; }
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 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; } } }
if ( bta instanceof WordToken ) { final WordToken wta = (WordToken) bta; final String canonicalForm = wta.getCanonicalForm(); if ( canonicalForm != null ) { lt.addStringAttribute( CANONICAL_VARIANT_ATTR, canonicalForm );
if ( bta instanceof WordToken ) { final WordToken wta = (WordToken) bta; final String canonicalForm = wta.getCanonicalForm(); if ( canonicalForm != null ) { lt.addStringAttribute( CANONICAL_VARIANT_ATTR, canonicalForm );
/** * {@inheritDoc} */ @Override public List<LookupToken> getSortedLookupTokens( final JCas jcas, final Annotation annotation ) throws AnnotatorInitializationException { final List<LookupToken> ltList = new ArrayList<LookupToken>(); final List<BaseToken> inList = JCasUtil.selectCovered( jcas, BaseToken.class, annotation ); for ( BaseToken bta : inList ) { final boolean isNonLookup = bta instanceof NewlineToken || bta instanceof PunctuationToken || bta instanceof ContractionToken || bta instanceof SymbolToken; if ( isNonLookup ) { continue; } final LookupToken lt = new LookupAnnotationToJCasAdapter( bta ); if ( bta instanceof WordToken ) { WordToken wta = (WordToken) bta; String canonicalForm = wta.getCanonicalForm(); if ( canonicalForm != null ) { lt.addStringAttribute( CANONICAL_VARIANT_ATTR, canonicalForm ); } } ltList.add( lt ); } return ltList; }
/** * {@inheritDoc} */ @Override public List<LookupToken> getSortedLookupTokens( final JCas jcas, final Annotation annotation ) throws AnnotatorInitializationException { final List<LookupToken> ltList = new ArrayList<LookupToken>(); final List<BaseToken> inList = JCasUtil.selectCovered( jcas, BaseToken.class, annotation ); for ( BaseToken bta : inList ) { final boolean isNonLookup = bta instanceof NewlineToken || bta instanceof PunctuationToken || bta instanceof ContractionToken || bta instanceof SymbolToken; if ( isNonLookup ) { continue; } final LookupToken lt = new LookupAnnotationToJCasAdapter( bta ); if ( bta instanceof WordToken ) { WordToken wta = (WordToken) bta; String canonicalForm = wta.getCanonicalForm(); if ( canonicalForm != null ) { lt.addStringAttribute( CANONICAL_VARIANT_ATTR, canonicalForm ); } } ltList.add( lt ); } return ltList; }
final String canonicalForm = wta.getCanonicalForm(); if ( canonicalForm != null ) { lt.addStringAttribute( CANONICAL_VARIANT_ATTR, canonicalForm );
final String canonicalForm = wta.getCanonicalForm(); if ( canonicalForm != null ) { lt.addStringAttribute( CANONICAL_VARIANT_ATTR, canonicalForm );
final String canonicalForm = wta.getCanonicalForm(); if ( canonicalForm != null ) { lt.addStringAttribute( CANONICAL_VARIANT_ATTR, canonicalForm );
final String canonicalForm = wta.getCanonicalForm(); if ( canonicalForm != null ) { lt.addStringAttribute( CANONICAL_VARIANT_ATTR, canonicalForm );
final String canonicalForm = wta.getCanonicalForm(); if ( canonicalForm != null ) { lt.addStringAttribute( CANONICAL_VARIANT_ATTR, canonicalForm );
final String canonicalForm = wta.getCanonicalForm(); if ( canonicalForm != null ) { lt.addStringAttribute( CANONICAL_VARIANT_ATTR, canonicalForm );
final String canonicalForm = wta.getCanonicalForm(); if ( canonicalForm != null ) { lt.addStringAttribute( CANONICAL_VARIANT_ATTR, canonicalForm );
final String canonicalForm = wta.getCanonicalForm(); if ( canonicalForm != null ) { lt.addStringAttribute( CANONICAL_VARIANT_ATTR, canonicalForm );