我已标记的一个简单的句子,这是我的代码:编辑配置文件
package tagger;
import edu.stanford.nlp.tagger.maxent.MaxentTagger;
public class myTag {
public static void main(String[] args) {
MaxentTagger tagger = new MaxentTagger("D:/tagger/english-bidirectional-distsim.tagger");
String sample = "i go to school by bus";
String tagged = tagger.tagString(sample);
System.out.println(tagged);
}
}
这是输出:
Reading POS tagger model from D:/tagger/english-bidirectional-distsim.tagger ... done [3.0 sec].
i_LS go_VB to_TO school_NN by_IN bus_NN
编辑属性文件后它不完全有效果。 例如我已经将标记分隔符更改为(*),但在输出中它仍然打印(_)。
如何在eclipse中使用模型配置文件?在直接props
对象
Properties props = new Properties();
props.load(new FileReader("path/to/properties"));
MaxentTagger tagger = new MaxentTagger("D:/tagger/english-bidirectional-distsim.tagger", props);
您还可以设置属性:
props.setProperty("tagSeparator", "*");
NB:
请注意,双向模型[通常不是在实际应用中使用的最佳模型](http://nlp.stanford.edu/software/pos-tagger-faq.shtml#h)。还有其他一些模型为了大幅提高速度而牺牲了少量精度。 – 2015-04-03 12:46:17