本文整理汇总了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);
}
}
}