/** * To be called from {@link #match(AnalyzedSentence)} for rules that want * {@link #getAntiPatterns()} to be considered. * @since 3.1 */ protected AnalyzedSentence getSentenceWithImmunization(AnalyzedSentence sentence) { if (!getAntiPatterns().isEmpty()) { //we need a copy of the sentence, not reference to the old one AnalyzedSentence immunizedSentence = sentence.copy(sentence); for (DisambiguationPatternRule patternRule : getAntiPatterns()) { try { immunizedSentence = patternRule.replace(immunizedSentence); } catch (IOException e) { throw new RuntimeException(e); } } return immunizedSentence; } return sentence; }
/** * To be called from {@link #match(AnalyzedSentence)} for rules that want * {@link #getAntiPatterns()} to be considered. * @since 3.1 */ protected AnalyzedSentence getSentenceWithImmunization(AnalyzedSentence sentence) { if (!getAntiPatterns().isEmpty()) { //we need a copy of the sentence, not reference to the old one AnalyzedSentence immunizedSentence = sentence.copy(sentence); for (DisambiguationPatternRule patternRule : getAntiPatterns()) { try { immunizedSentence = patternRule.replace(immunizedSentence); } catch (IOException e) { throw new RuntimeException(e); } } return immunizedSentence; } return sentence; }