我试图弄清楚为什么将-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
),其中仅包含我上周下载的 Stanford CoreNLP 发行版:/Users/dduhaime/Desktop/everett/wiki_facts/stanford-corenlp-full-2015-12-09/*: