【发布时间】:2015-06-30 00:18:49
【问题描述】:
String prop = "austen.prop";
Properties props = StringUtils.propFileToProperties(prop);
String to = props.getProperty("serializeTo");
props.setProperty("serializeTo", "C:\\ner-jxy-model.ser.gz");
SeqClassifierFlags flags = new SeqClassifierFlags(props);
CRFClassifier<CoreLabel> crf = new CRFClassifier<CoreLabel>(flags);
crf.train();
这是我的 austen.prop
#location of the training file
trainFile = train.tsv
#location where you would like to save (serialize to) your
#classifier; adding .gz at the end automatically gzips the file,
#making it faster and smaller
serializeTo = ner-model.ser.gz
#structure of your training file; this tells the classifier
#that the word is in column 0 and the correct answer is in
#column 1
map = word=0,answer=1
#these are the features we'd like to train with
#some are discussed below, the rest can be
#understood by looking at NERFeatureFactory
useClassFeature=true
useWord=true
useNGrams=true
#no ngrams will be included that do not contain either the
#beginning or end of the word
noMidNGrams=true
useDisjunctive=true
maxNGramLeng=6
usePrev=true
useNext=true
useSequences=true
usePrevSequences=true
maxLeft=1
#the next 4 deal with word shape features
useTypeSeqs=true
useTypeSeqs2=true
useTypeySequences=true
wordShape=chris2useLC
我以编程方式训练了 stanford NER,但没有得到模型文件 ner-model.ser.gz。
但是当我直接使用crf进行分类时,它会起作用。
【问题讨论】:
-
我遇到了完全相同的问题。你发现什么问题了吗?我在文档中找不到任何线索。
-
在你的 prop 文件中,我可以看到你想序列化到某个文件,然后你以编程方式给它起了其他名字......这是为什么?
标签: stanford-nlp