【问题标题】:Stanford Relationship training not working斯坦福关系培训不起作用
【发布时间】:2016-04-19 07:37:00
【问题描述】:

我正在尝试按照 URL http://nlp.stanford.edu/software/relationExtractor.shtml 指定的方式运行关系训练器。但是,尽管我在类路径中指定了 stanford-postagger.jar,但它无法找到标记器。任何指向正确方向的指针都会非常有帮助。

我在 Windows 上的命令提示符下运行,如下所示:

D:\01.Jars\Jars_Stanford\stanford-corenlp-full-2015-04-20>java -cp “stanford-ner .jar;stanford-corenlp-3.5.2.jar;stanford-postagger.jar” edu.stanford.nlp.ie.machinereading.MachineReading --arguments SuperAnnuation.properties PERCENTAGE OF TRAIN: 1.0 读者日志 级别设置为 SEVERE 在线程“main”中添加注释器 pos 异常 java.lang.RuntimeException: edu.stanford.nlp.io.Runti meIOException: 加载标记器模型时出现不可恢复的错误 在 edu.stanford.nlp.pipeline.AnnotatorFactories$4.create(AnnotatorFactor ies.java:292) 在 edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:85) 在 edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.j 艾娃:289) 在 edu.stanford.nlp.pipeline.StanfordCoreNLP.(S​​tanfordCoreNLP.java :126) 在 edu.stanford.nlp.ie.machinereading.MachineReading.makeMachineReading( MachineReading.java:228) 在 edu.stanford.nlp.ie.machinereading.MachineReading.main(MachineReading .java:106) 引起:edu.stanford.nlp.io.RuntimeIOException: 加载标注器模型时出现不可恢复的错误 在 edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTa gger.java:770) 在 edu.stanford.nlp.tagger.maxent.MaxentTagger.(MaxentTagger.java: 298) 在 edu.stanford.nlp.tagger.maxent.MaxentTagger.(MaxentTagger.java: 263) 在 edu.stanford.nlp.pipeline.POSTaggerAnnotator.loadModel(POSTaggerAnnot ator.java:97) 在 edu.stanford.nlp.pipeline.POSTaggerAnnotator.(POSTaggerAnnotato r.java:77) 在 edu.stanford.nlp.pipeline.AnnotatorImplementations.posTagger(Annotato rImplementations.java:59) 在 edu.stanford.nlp.pipeline.AnnotatorFactories$4.create(AnnotatorFactor ies.java:290) ... 5 更多原因:java.io.IOException: Unable to resolve "edu/stanford/nlp/models/post-t agger/english-left3words/english-left3words-distim.tagger" 作为 类路径、文件名或 URL 在 edu.stanford.nlp.io.IOUtils.getInputStreamFromURLOrClasspathOrFileSys TEM(IOUtils.java:481) 在 edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTa gger.java:765) ... 11 更多

下面给出了使用的退休金财产文件。这是网站上提供的默认属性文件:

#Below are some basic options. See edu.stanford.nlp.ie.machinereading.MachineReadingProperties class for more options.

# Pipeline options
annotators = pos, lemma, parse
parse.maxlen = 100

# MachineReading properties. You need one class to read the dataset into correct format. See edu.stanford.nlp.ie.machinereading.domains.ace.AceReader for another example.
datasetReaderClass = edu.stanford.nlp.ie.machinereading.domains.roth.RothCONLL04Reader

#Data directory for training. The datasetReaderClass reads data from this path and makes corresponding sentences and annotations.
trainPath = /u/nlp/data/RothCONLL04/conll04.corp

#Whether to crossValidate, that is evaluate, or just train.
crossValidate = false
kfold = 10

#Change this to true if you want to use CoreNLP pipeline generated NER tags. The default model generated with the relation extractor release uses the CoreNLP pipeline provided tags (option set to true).
trainUsePipelineNER=false

# where to save training sentences. uses the file if it exists, otherwise creates it.
serializedTrainingSentencesPath = tmp/roth_sentences.ser

serializedEntityExtractorPath = tmp/roth_entity_model.ser

# where to store the output of the extractor (sentence objects with relations generated by the model). This is what you will use as the model when using 'relation' annotator in the CoreNLP pipeline.
serializedRelationExtractorPath = tmp/roth_relation_model_pipeline.ser

# uncomment to load a serialized model instead of retraining
# loadModel = true

#relationResultsPrinters = edu.stanford.nlp.ie.machinereading.RelationExtractorResultsPrinter,edu.stanford.nlp.ie.machinereading.domains.roth.RothResultsByRelation. For printing output of the model.
relationResultsPrinters = edu.stanford.nlp.ie.machinereading.RelationExtractorResultsPrinter

#In this domain, this is trivial since all the entities are given (or set using CoreNLP NER tagger).
entityClassifier = edu.stanford.nlp.ie.machinereading.domains.roth.RothEntityExtractor

extractRelations = true
extractEvents = false

#We are setting the entities beforehand so the model does not learn how to extract entities etc.
extractEntities = false

#Opposite of crossValidate. 
trainOnly=true

# The set chosen by feature selection using RothCONLL04:
relationFeatures = arg_words,arg_type,dependency_path_lowlevel,dependency_path_words,surface_path_POS,entities_between_args,full_tree_path

# The above features plus the features used in Bjorne BioNLP09:
# relationFeatures = arg_words,arg_type,dependency_path_lowlevel,dependency_path_words,surface_path_POS,entities_between_args,full_tree_path,dependency_path_POS_unigrams,dependency_path_word_n_grams,dependency_path_POS_n_grams,dependency_path_edge_lowlevel_n_grams,dependency_path_edge-node-edge-grams_lowlevel,dependency_path_node-edge-node-grams_lowlevel,dependency_path_directed_bigrams,dependency_path_edge_unigrams,same_head,entity_counts

【问题讨论】:

    标签: stanford-nlp


    【解决方案1】:

    尝试使用完整的 Stanford CoreNLP jar 和相关模型 jar 运行。这些都可以从CoreNLP downloads page 下载。确保在您的类路径中同时包含代码 jar 和模型 jar!

    【讨论】:

    • 感谢您的回复。我正在使用全套代码和模型 jar 运行,但仍然出现错误。不知道我做错了什么。
    • 感谢@Gabor Angeli 的评论。我修改了命令,它现在可以工作了。 java -cp stanford-corenlp-3.5.2.jar;stanford-corenlp-3.5.2-models.jar;C:\jars\jars_stanford\stanford-postagger-full-2015-04-20\stanford-postagger-3.5.2.jar;C:\jars\jars_stanford\stanford-postagger-full-2015-04-20\models\english-left3words-distsim.tagger; edu.stanford.nlp.ie.machinereading.MachineReading --arguments roth.properties
    猜你喜欢
    • 2015-09-11
    • 2016-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多