private void DoOneSentenceNew(IList <CoreLabel> words, Annotation doc, ICoreMap sentence) { IList <CoreLabel> newWords = NumberSequenceClassifier.CopyTokens(words, sentence); nsc.ClassifyWithGlobalInformation(newWords, doc, sentence); IEnumerator <CoreLabel> newFLIter = newWords.GetEnumerator(); foreach (CoreLabel origWord in words) { CoreLabel newWord = newFLIter.Current; string before = origWord.Ner(); string newGuess = newWord.Get(typeof(CoreAnnotations.AnswerAnnotation)); // log.info(origWord.word()); // log.info(origWord.ner()); if (Verbose) { log.Info(newWord); } // log.info("-------------------------------------"); if ((before == null || before.Equals(BackgroundSymbol) || before.Equals("MISC")) && !newGuess.Equals(BackgroundSymbol)) { origWord.SetNER(newGuess); } // transfer other annotations generated by SUTime or NumberNormalizer NumberSequenceClassifier.TransferAnnotations(newWord, origWord); } }
private void RecognizeNumberSequences(IList <CoreLabel> words, ICoreMap document, ICoreMap sentence) { // we need to copy here because NumberSequenceClassifier overwrites the AnswerAnnotation IList <CoreLabel> newWords = NumberSequenceClassifier.CopyTokens(words, sentence); nsc.ClassifyWithGlobalInformation(newWords, document, sentence); // copy AnswerAnnotation back. Do not overwrite! // also, copy all the additional annotations generated by SUTime and NumberNormalizer for (int i = 0; i < sz; i++) { CoreLabel origWord = words[i]; CoreLabel newWord = newWords[i]; // log.info(newWord.word() + " => " + newWord.get(CoreAnnotations.AnswerAnnotation.class) + " " + origWord.ner()); string before = origWord.Get(typeof(CoreAnnotations.AnswerAnnotation)); string newGuess = newWord.Get(typeof(CoreAnnotations.AnswerAnnotation)); if ((before == null || before.Equals(nsc.flags.backgroundSymbol) || before.Equals("MISC")) && !newGuess.Equals(nsc.flags.backgroundSymbol)) { origWord.Set(typeof(CoreAnnotations.AnswerAnnotation), newGuess); } // transfer other annotations generated by SUTime or NumberNormalizer NumberSequenceClassifier.TransferAnnotations(newWord, origWord); } }