@Override public void annotate(Annotation annotation) { if (verbose) { log.info("Adding true-case annotation..."); } if (annotation.containsKey(CoreAnnotations.SentencesAnnotation.class)) { // classify tokens for each sentence for (CoreMap sentence: annotation.get(CoreAnnotations.SentencesAnnotation.class)) { List<CoreLabel> tokens = sentence.get(CoreAnnotations.TokensAnnotation.class); List<CoreLabel> output = this.trueCaser.classifySentence(tokens); for (int i = 0, size = tokens.size(); i < size; i++) { // add the truecaser tag to each token String neTag = output.get(i).get(CoreAnnotations.AnswerAnnotation.class); tokens.get(i).set(CoreAnnotations.TrueCaseAnnotation.class, neTag); setTrueCaseText(tokens.get(i)); } } } else { throw new RuntimeException("unable to find sentences in: " + annotation); } }
@SuppressWarnings("unchecked") public void annotate(Annotation annotation) { if (VERBOSE) { System.err.print("Adding true-case annotation..."); } if (annotation.containsKey(CoreAnnotations.SentencesAnnotation.class)) { // classify tokens for each sentence for (CoreMap sentence: annotation.get(CoreAnnotations.SentencesAnnotation.class)) { List<CoreLabel> tokens = sentence.get(CoreAnnotations.TokensAnnotation.class); List<CoreLabel> output = this.trueCaser.classifySentence(tokens); for (int i = 0; i < tokens.size(); ++i) { // add the named entity tag to each token String neTag = output.get(i).get(CoreAnnotations.AnswerAnnotation.class); tokens.get(i).set(CoreAnnotations.TrueCaseAnnotation.class, neTag); setTrueCaseText(tokens.get(i)); } } } else { throw new RuntimeException("unable to find sentences in: " + annotation); } }
@SuppressWarnings("unchecked") public void annotate(Annotation annotation) { if (VERBOSE) { System.err.print("Adding true-case annotation..."); } if (annotation.containsKey(CoreAnnotations.SentencesAnnotation.class)) { // classify tokens for each sentence for (CoreMap sentence: annotation.get(CoreAnnotations.SentencesAnnotation.class)) { List<CoreLabel> tokens = sentence.get(CoreAnnotations.TokensAnnotation.class); List<CoreLabel> output = this.trueCaser.classifySentence(tokens); for (int i = 0; i < tokens.size(); ++i) { // add the named entity tag to each token String neTag = output.get(i).get(AnswerAnnotation.class); tokens.get(i).set(CoreAnnotations.TrueCaseAnnotation.class, neTag); setTrueCaseText(tokens.get(i)); } } } else { throw new RuntimeException("unable to find sentences in: " + annotation); } }
@Override public void annotate(Annotation annotation) { if (verbose) { log.info("Adding true-case annotation..."); } if (annotation.containsKey(CoreAnnotations.SentencesAnnotation.class)) { // classify tokens for each sentence for (CoreMap sentence: annotation.get(CoreAnnotations.SentencesAnnotation.class)) { List<CoreLabel> tokens = sentence.get(CoreAnnotations.TokensAnnotation.class); List<CoreLabel> output = this.trueCaser.classifySentence(tokens); for (int i = 0, size = tokens.size(); i < size; i++) { // add the truecaser tag to each token String neTag = output.get(i).get(CoreAnnotations.AnswerAnnotation.class); tokens.get(i).set(CoreAnnotations.TrueCaseAnnotation.class, neTag); setTrueCaseText(tokens.get(i)); } } } else { throw new RuntimeException("unable to find sentences in: " + annotation); } }