2016-06-24 5 views
0

私はスタンフォードコアNLPで遊んでいます。自分のNERモデルを訓練したいと思っています。 SOと公式ウェブサイトのフォーラムから、そうするためにプロパティファイルを使うことが記述されています。私はAPIを介してどのようにしますか?私はプロップのファイルを追加しますスタンフォードnlpでのNERモデルのトレーニング

Properties props = new Properties(); 
props.setProperty("annotators", "tokenize, ssplit, pos, lemma, ner, parse, sentiment, regexner"); 
props.setProperty("regexner.mapping", "resources/customRegexNER.txt"); 

StanfordCoreNLP pipeline = new StanfordCoreNLP(props);  

String processedQuestion = "Who is the prime minister of Australia?" 

//Annotation annotation = pipeline.process(processedQuestion); 
Annotation document = new Annotation(processedQuestion); 
pipeline.annotate(document); 
List<CoreMap> sentences = document.get(SentencesAnnotation.class); 
for (CoreMap sentence : sentences) { 

    // To get the tokens for the parsed sentence 
    for (CoreMap tokens : sentence.get(TokensAnnotation.class)) {   
     String token = tokens.get(TextAnnotation.class); 
     String POS = tokens.get(PartOfSpeechAnnotation.class);  
     String NER = tokens.get(NamedEntityTagAnnotation.class);    
     String Sentiment = tokens.get(SentimentClass.class);    
     String lemma = tokens.get(LemmaAnnotation.class); 
  1. どう&?
  2. Nグラムのトークン化(例えば、単一のトークンとみなされる首相、後でこのトークンは2つのトークンが渡される(首相と大臣)の代わりにPOS、NERに渡される)?

答えて

1

私はそれがそのコードで仕事ができると思う:

val props = new Properties() 
    props.put("annotators", "tokenize, ssplit, pos, lemma, ner, regexner") 
    props.put("ner.model", "/your/path/ner-model.ser.gz"); 
    val pipeline = new StanfordCoreNLP(props) 
関連する問題