本文介绍了在stanford pos tagger中编辑配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经标记了一个简单的句子,这是我的代码:
i have tagged a simple sentence and this is my code:
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
在编辑属性文件后,它根本没有任何作用.例如,我已将标签分隔符更改为(*),但在输出中仍会打印(_).
after editing the properties file it doesn't have any effect at all.for example i have changed the tag separator to ( * ) but in the output it still prints ( _ ).
我该如何在Eclipse中使用模型配置文件?
how could i use the model config file in eclipse?
推荐答案
您可以加载属性文件并将其传递给MaxEnt的构造函数,如下所示:
You can load Properties file and pass it to the constructor of MaxEnt, something like this:
Properties props = new Properties();
props.load(new FileReader("path/to/properties"));
MaxentTagger tagger = new MaxentTagger("D:/tagger/english-bidirectional-distsim.tagger", props);
您还可以直接在props
对象中设置属性:
You can also set properties in props
object directly:
props.setProperty("tagSeparator", "*");
注意:如果您使用原始属性文件,则该文件会失败,并出现
NB: if you use the original properties file and it fails with exception like
java.io.FileNotFoundException: /u/nl
p/data/pos_tags_are_useless/egw4-reut.512.clusters (No such file or directory)
然后删除arch
和trainFile
属性.
这篇关于在stanford pos tagger中编辑配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!