我是斯坦福NLP的新宝宝,在过去的几天里一直在使用这个,现在坚持我的最后一步。当我使用PTBTokenizer时,它将句子拆分成单词,但我想要的是它应该将句子拆分成NamedEntities或动词,这样我就可以使用某种依存关系树从整个句子中使用直接的结论来重建句子,而且它还应该从实体中理解相同的实体。有没有可能定制标记器来实现这一点?你的帮助是恰当的。提前谢谢。
try{
// Properties props = StringUtils.argsToProperties(args);
Properties props = new Properties();
props.put("annotators", "tokenize,ssplit");
props.setProperty("annotators", "tokenize,ssplit,lemma,pos,parse,ner");
StanfordCoreNLP pipeline = new StanfordCoreNLP();
String sentence = "Kapil Puri, original promoter of Sparsh BPO, now owned by Blackstone controlled Intelenet, has decided to sell his residual stake of 12%.";
Annotation doc = new Annotation(sentence);
pipeline.annotate(doc);
RelationExtractorAnnotator r = new RelationExtractorAnnotator(props);
r.annotate(doc);
for(CoreMap s: doc.get(CoreAnnotations.SentencesAnnotation.class)){
System.out.println("For sentence :=>" + s.get(CoreAnnotations.TextAnnotation.class));
List<RelationMention> rls = s.get(RelationMentionsAnnotation.class);
for(RelationMention rl: rls){
System.out.println(rl.toString());
}
}
}catch(Exception e){
e.printStackTrace();
}
发布于 2018-09-17 00:45:51
我希望你不能直接做到这一点,即使我遇到了类似的问题。在这里,我尝试使用以下过程:我最初应用了PTBTokenizer,然后在其上使用了NER和RegexNER,然后使用结果,在连续NER标签的帮助下开始合并数据。
如果两个或两个以上的连续单词有相同的标签,那么我就合并成一个单词。
https://stackoverflow.com/questions/28756992
复制相似问题