本文整理匯總了Java中edu.stanford.nlp.pipeline.Annotation.containsKey方法的典型用法代碼示例。如果您正苦於以下問題:Java Annotation.containsKey方法的具體用法?Java Annotation.containsKey怎麽用?Java Annotation.containsKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類edu.stanford.nlp.pipeline.Annotation
的用法示例。
在下文中一共展示了Annotation.containsKey方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: annotate
import edu.stanford.nlp.pipeline.Annotation; //導入方法依賴的package包/類
@Override
public void annotate(Annotation annotation) {
if (annotation.containsKey(CoreAnnotations.SentencesAnnotation.class)) {
for (CoreMap sentence : annotation.get(CoreAnnotations.SentencesAnnotation.class)) {
List<CoreLabel> tokens = sentence.get(CoreAnnotations.TokensAnnotation.class);
for (CoreLabel c : tokens) {
String[] morph_fatures = c.get(DigiMorphAnnotations.MorphoAnnotation.class).split(" ");
String lemma = c.get(CoreAnnotations.LemmaAnnotation.class);
if (morph_fatures.length > 1) {
List<String> comps = new ArrayList<>();
for (String m : morph_fatures) {
if (m.startsWith(lemma + "+") || m.startsWith(lemma + "~")) {
comps.add(m);
}
}
c.set(DigiMorphAnnotations.MorphoCompAnnotation.class, comps);
} else {
if (morph_fatures[0].startsWith(lemma + "+") || morph_fatures[0].startsWith(lemma + "~")) {
c.set(DigiMorphAnnotations.MorphoCompAnnotation.class,
new ArrayList<String>(Arrays.asList(morph_fatures[0])));
}
}
}
}
}
}
示例2: annotate
import edu.stanford.nlp.pipeline.Annotation; //導入方法依賴的package包/類
public void annotate(Annotation annotation) {
if (annotation.containsKey(CoreAnnotations.SentencesAnnotation.class)) {
for (CoreMap sentence : annotation.get(CoreAnnotations.SentencesAnnotation.class)) {
List<CoreLabel> tokens = sentence.get(CoreAnnotations.TokensAnnotation.class);
for (CoreLabel c : tokens) {
String[] morph_features = c.get(DigiMorphAnnotations.MorphoAnnotation.class).split(" ");
c.set(DigiInverseMorphAnnotations.InverseMorphoAnnotation.class, morph_features[0]);
}
}
}
}
示例3: annotate
import edu.stanford.nlp.pipeline.Annotation; //導入方法依賴的package包/類
@Override public void annotate(Annotation annotation) {
if (annotation.containsKey(CoreAnnotations.SentencesAnnotation.class)) {
for (CoreMap sentence : annotation.get(CoreAnnotations.SentencesAnnotation.class)) {
List<CoreLabel> lastVerb = new ArrayList<>();
List<CoreLabel> tokens = sentence.get(CoreAnnotations.TokensAnnotation.class);
boolean followedByExMark = tokens.get(tokens.size() - 1).word().equals("!");
// boolean preceededByNot = false;
List<VerbMultiToken> verbs = new ArrayList<>();
for (int i = 0; i < tokens.size(); i++) {
CoreLabel token = tokens.get(i);
String pos = token.get(CoreAnnotations.PartOfSpeechAnnotation.class);
// System.out.println(token);
// System.out.println(pos);
// System.out.println();
// String form = token.word().toLowerCase();
// if (noWords.contains(form)) {
// preceededByNot = true;
// }
if (isSatisfied(pos, verbTags, usePrefix) || isSatisfied(pos, modalTags, modalUsePrefix)) {
lastVerb.add(token);
}
if (isSatisfied(pos, skipTags, usePrefix)) {
continue;
}
if (isSatisfied(pos, auxTags, auxUsePrefix)) {
continue;
}
if (lastVerb.size() > 0) {
addVerbs(lastVerb, verbs, followedByExMark);
lastVerb = new ArrayList<>();
}
}
if (lastVerb.size() > 0) {
addVerbs(lastVerb, verbs, followedByExMark);
}
sentence.set(VerbAnnotations.VerbsAnnotation.class, verbs);
}
}
}