/** * A utility method that annotates a given range. */ protected void annotateRange(JCas jcas, String text, int rangeBegin, int rangeEnd) throws AnalysisEngineProcessException { JFSIndexRepository indexes = jcas.getJFSIndexRepository(); Iterator<?> wordItr = indexes.getAnnotationIndex(WordToken.type) .iterator(); while (wordItr.hasNext()) { WordToken wordAnnotation = (WordToken) wordItr.next(); if (wordAnnotation.getBegin() >= rangeBegin && wordAnnotation.getEnd() <= rangeEnd) { String word = text.substring(wordAnnotation.getBegin(), wordAnnotation.getEnd()); // if the original word was misspelled, use the spell correction String suggestion = wordAnnotation.getSuggestion(); if ((suggestion != null) && (suggestion.length() > 0)) { word = suggestion; } // skip past words that are part of the exclusion set if (exclusionSet.contains(word)) continue; setCanonicalForm(wordAnnotation, word); if (postLemmas) setLemma(wordAnnotation, word, jcas); } } }
/** * A utility method that annotates a given range. */ protected void annotateRange(JCas jcas, String text, int rangeBegin, int rangeEnd) throws AnalysisEngineProcessException { JFSIndexRepository indexes = jcas.getJFSIndexRepository(); Iterator<?> wordItr = indexes.getAnnotationIndex(WordToken.type) .iterator(); while (wordItr.hasNext()) { WordToken wordAnnotation = (WordToken) wordItr.next(); if (wordAnnotation.getBegin() >= rangeBegin && wordAnnotation.getEnd() <= rangeEnd) { String word = text.substring(wordAnnotation.getBegin(), wordAnnotation.getEnd()); // if the original word was misspelled, use the spell correction String suggestion = wordAnnotation.getSuggestion(); if ((suggestion != null) && (suggestion.length() > 0)) { word = suggestion; } // skip past words that are part of the exclusion set if (exclusionSet.contains(word)) continue; setCanonicalForm(wordAnnotation, word); if (postLemmas) setLemma(wordAnnotation, word, jcas); } } }