2016-03-31 4 views
0

スタンフォードパーサー(http://nlp.stanford.edu/software/lex-parser.html)、バージョン3.6.0には、英語、ドイツ語およびその他の言語用の訓練された文法が付属しています。スタンフォードパーサーはドイツ語のウムラウトを読むことができません

[email protected]:stanford-parser-full-2015-12-09$ ./lexparser-lang.sh German 500 edu/stanford/nlp/models/lexparser/germanFactored.ser.gz factored german_test.txt 

入力ファイルgerman_test.txtは、単一のドイツ語の文章が含まれています:ドイツ語のテキストを解析するにはスタンフォードパーサは

./lexparser-lang.sh 
Usage: lexparser-lang.sh lang len grammar out_file FILE... 

    lang  : Language to parse (Arabic, English, Chinese, German, French) 
    len  : Maximum length of the sentences to parse 
    grammar : Serialized grammar file (look in the models jar) 
    out_file : Prefix for the output filename 
    FILE  : List of files to parse 

は、だから私は、これらのオプションでそれを呼び出すlexparser-lang.shツールを提供

Fußball findet um 8 Uhr in der Halle statt. 

しかし、 "ß"は警告と間違った結果を招きます。 "ä"、 "ö"、 "ü"と同じです。さて、lexparser-lang.shは、ドイツ語のテキストを入力として扱うように設計されています。私は行方不明のオプションがありますか?

それはどのように:がらくたのように見える解析ツリーで

[main] INFO edu.stanford.nlp.parser.lexparser.LexicalizedParser - Loading parser from serialized file edu/stanford/nlp/models/lexparser/germanFactored.ser.gz ... 
done [3.8 sec]. 
Parsing file: german_test.txt 
Apr 01, 2016 12:48:45 AM edu.stanford.nlp.process.PTBLexer next 
WARNING: Untokenizable: (U+9F, decimal: 159) 
Parsing [sent. 1 len. 11]: Fuà ball findet um 8 Uhr in der Halle statt . 
Parsed file: german_test.txt [1 sentences]. 
Parsed 11 words in 1 sentences (32.07 wds/sec; 2.92 sents/sec). 

(S (ADV FuÃ) (ADV ball) (VVFIN findet) 
    (PP (APPR um) (CARD 8) (NN Uhr)) 
    (PP (APPR in) (ART der) (NN Halle)) 
    (PTKVZ statt) ($. .)) 

は、それがどうあるべきかが "Fussball" 書かれ

、問題ありません(不正確な正書法を除く)

[main] INFO edu.stanford.nlp.parser.lexparser.LexicalizedParser - Loading parser from serialized file edu/stanford/nlp/models/lexparser/germanFactored.ser.gz ... 
    done [3.5 sec]. 
    Parsing file: german_test.txt 
    Parsing [sent. 1 len. 10]: Fussball findet um 8 Uhr in der Halle statt . 
    Parsed file: german_test.txt [1 sentences]. 
    Parsed 10 words in 1 sentences (40.98 wds/sec; 4.10 sents/sec). 

正しいツリー:

(S (NN Fussball) (VVFIN findet) 
    (PP (APPR um) (CARD 8) (NN Uhr)) 
    (PP (APPR in) (ART der) (NN Halle)) 
    (PTKVZ statt) ($. .)) 

答えて

1

デモスクリプトが正しい文字セットでトークナイザを実行していません。テキストがプリトークン化されている場合は、オプション "-tokenized"を追加することができます。トークンデリミタとしてスペースを使用します。

また、ドイツ語で「-encoding ISO-8859-1」を使用するようにパーサーに伝えたいとします。ここで

は(.SHスクリプトで見つかったものを変える)フルjavaコマンドです:

java -Xmx2g -cp "./*" edu.stanford.nlp.parser.lexparser.LexicalizedParser -maxLength 500 -tLPP edu.stanford.nlp.parser.lexparser.NegraPennTreebankParserParams -hMarkov 1 -vMarkov 2 -vSelSplitCutOff 300 -uwm 1 -unknownSuffixSize 2 -nodeCleanup 2 -writeOutputFiles -outputFilesExtension output.500.stp -outputFormat "penn" -outputFormatOptions "removeTopBracket,includePunctuationDependencies" -encoding ISO_8859-1 -tokenized -loadFromSerializedFile edu/stanford/nlp/models/lexparser/germanFactored.ser.gz german_example.txt 

私はこの出力を得る:

(NUR 
    (S (NN Fußball) (VVFIN findet) 
    (PP (APPR um) (CARD 8) (NN Uhr)) 
    (PP (APPR in) (ART der) (NN Halle) (ADJA statt.)))) 

が再び更新:

ていることを確認します「statt」を分離する。 "statt"に入れる。私たちはトークンが空白で区切られていると言っているからです。私たちは、この解析を取得し、この修正プログラム適用する場合:

(S (NN Fußball) (VVFIN findet) 
    (PP (APPR um) (CARD 8) (NN Uhr)) 
    (PP (APPR in) (ART der) (NN Halle)) 
    (PTKVZ statt) ($. .)) 

だから要約すると、基本的な問題は、私たちがISO_8859-1を使用するISO_8859-1とLexicalizedParserを使用するようにPTBTokenizerを指示する必要があります。

これを行うには、完全なパイプラインを使用することをお勧めします。

  1. ダウンロードStanford CoreNLP 3.6。ここから0:

    http://stanfordnlp.github.io/CoreNLP/

  2. はここからドイツ語モデルのjarファイルをダウンロードしてください:

    http://stanfordnlp.github.io/CoreNLP/download.html

  3. を実行し、このコマンド:

    java -Xmx3g -cp "stanford-corenlp-full-2015-12-09/*:stanford-corenlp-3.6.0-models-german.jar" edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,parse -props StanfordCoreNLP-german.properties -file german_example_file.txt -outputFormat text 
    

をこれはトークン化し、テキストを解析する正しい文字エンコーディングを使用してください。

+0

興味深いことに、結果が本当に良いわけではありません。実際には間違っています。最後の単語は(PTKVZ statt)にする必要があります。 – Sadik

+0

私は間違いました。更新された回答をご覧ください。 – StanfordNLPHelp

+0

ありがとうございます。私は次のアップデートを読むのを楽しみにしています! – Sadik

関連する問題