2017-05-12 13 views
0

教授Mannings教授のコードサンプルをhereに変更し、ファイル、トークン化、品詞タグを読み込み、lemmatizeするようにしました。スタンフォードCoreNLPトークナイザのオプションを設定する

今、私は無効化不可能な文字の問題に出くわしました。私は "untokenizable"オプションを使用して "noneKeep"に設定したいと思います。

StackOverflowに関するその他の質問では、自分でトークナイザをインスタンス化する必要があると説明しています。しかし、私はそれを行う方法がわからないので、必要に応じて以下のタスク(POSタギングなど)が実行されます。誰かが私を正しい方向に向けることができますか?

// expects two command line parameters: one file to be read, one to write to 

import java.io.*; 
import java.util.*; 

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

public class StanfordCoreNlpDemo { 

    public static void main(String[] args) throws IOException { 
    PrintWriter out; 
    out = new PrintWriter(args[1]); 

    Properties props = new Properties(); 
    props.setProperty("annotators", "tokenize, ssplit, pos, lemma"); 
    StanfordCoreNLP pipeline = new StanfordCoreNLP(props); 
    Annotation annotation; 
    annotation = new Annotation(IOUtils.slurpFileNoExceptions(args[0])); 

    pipeline.annotate(annotation); 
    pipeline.prettyPrint(annotation, out); 
    } 
} 

答えて

1

あなたのコードにこれを追加します。untokenizableため

props.setProperty("tokenize.options", "untokenizable=allKeep");

6オプションは次のとおりです。ほとんどがっかりするほど簡単だった

noneDelete, firstDelete, allDelete, noneKeep, firstKeep, allKeep

+0

。どうもありがとうございました! – user1769925

関連する問題