-nthreads {int}
引数をスタンフォード CoreNLP (バージョンstanford-corenlp-full-2015-12-09
) に追加すると、すべてのトークンの出力 NER 値が O (= 名前付きエンティティではない)になる理由を理解しようとしています。
簡単な例として、 というファイルを作成し、sample-file.txt
その内容をSamuel Huntington
. 次に実行します。
java -Xmx6g edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner -file sample-file.txt -outputFormat json
これにより、期待される出力が生成され、「Samuel」が人として認識されます。
{
"sentences": [
{
"index": 0,
"parse": "SENTENCE_SKIPPED_OR_UNPARSABLE",
"tokens": [
{
"index": 1,
"word": "Samuel",
"originalText": "Samuel",
"lemma": "Samuel",
"characterOffsetBegin": 0,
"characterOffsetEnd": 6,
"pos": "NNP",
"ner": "PERSON",
"before": "",
"after": " "
}, ...
ただし、上記のコマンドに追加-nthreads 8
すると、出力は Samuel が人であることを示しません。完全なコマンド:
java -Xmx6g edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner -file sample-file.txt -outputFormat json -nthreads 8
生成するもの:
{
"sentences": [
{
"index": 0,
"parse": "SENTENCE_SKIPPED_OR_UNPARSABLE",
"tokens": [
{
"index": 1,
"word": "Samuel",
"originalText": "Samuel",
"lemma": "Samuel",
"characterOffsetBegin": 0,
"characterOffsetEnd": 6,
"pos": "NNP",
"ner": "O",
"before": "",
"after": " "
},
価値があるのは、-nthread {int}
(つまり、s のないスレッド) が問題を解決するので、このコマンドを使用するだけです。ただし、他の人が -nthreads フラグを使用しようとする場合に備えて、この質問はここに残します。
PS これが私の CLASSPATH (から取得echo $CLASSPATH
) で、先週ダウンロードしたスタンフォード CoreNLP ディストリビューションのみが含まれています。/Users/dduhaime/Desktop/everett/wiki_facts/stanford-corenlp-full-2015-12-09/*: