2017-04-22 119 views
0

我注意到corenlp.run可以识别“明天上午10点”并将其解析为时间。但培训教程和我见过的文档只允许每行一个字。我如何理解一个短语。 在相关说明中,是否有标记复合实体的方法?斯坦福NER短语或复合实体

回答

1

类似这样的时间相关短语被SUTime库识别。更多细节可以在这里找到:https://nlp.stanford.edu/software/sutime.html

有一个功能可以在ner标记完成后提取实体。

例如,如果您已经标记了一个句子:Joe Smith went to Hawaii .PERSON PERSON O O LOCATION O您可以提取出Joe SmithHawaii。这需要entitymentions注释器。

下面是一些示例代码:java.io.IOException异常:无法打开“EDU /斯坦福/ NLP /型号

package edu.stanford.nlp.examples; 

import edu.stanford.nlp.pipeline.*; 
import edu.stanford.nlp.ling.*; 
import edu.stanford.nlp.util.*; 

import java.util.*; 

public class EntityMentionsExample { 

    public static void main(String[] args) { 
    Annotation document = 
     new Annotation("John Smith visited Los Angeles on Tuesday."); 
    Properties props = new Properties(); 
    //props.setProperty("regexner.mapping", "small-names.rules"); 
    props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,entitymentions"); 
    StanfordCoreNLP pipeline = new StanfordCoreNLP(props); 
    pipeline.annotate(document); 

    for (CoreMap entityMention : document.get(CoreAnnotations.MentionsAnnotation.class)) { 
     System.out.println(entityMention); 
     //System.out.println(entityMention.get(CoreAnnotations.TextAnnotation.class)); 
     System.out.println(entityMention.get(CoreAnnotations.EntityTypeAnnotation.class)); 
    } 
    } 
} 
+0

我从GitHub的源代码运行这一点,并运行到'所致/pos-tagger/english-left3words/english-left3words-distsim.tagger“作为类路径,文件名或URL' – user1170883

+1

您需要在CLASSPATH中使用lib和liblocal中的模型jar和所有jar ...您可以下载来自主GitHub页面的最新模型jar以及lib和liblocal文件夹也可以在GitHub中访问。 – StanfordNLPHelp

相关问题