import java.io.IOException;
import edu.stanford.nlp.tagger.maxent.MaxentTagger;
public class TagText {
public static void main(String[] args) throws IOException, ClassNotFoundException {
// Initialize the tagger
MaxentTagger tagger = new MaxentTagger("taggers/models/wsj-0-18-bidirectional distsim.tagger");
// The sample string
String sample = "This is a sample text.";
// The tagged string
String tagged = tagger.tagString(sample);
// Output the result
System.out.println(tagged);
}
}
这是我的代码和JCreator>配置>选项> JDK工具
在“选择工具类型:编译器”
中我已将参数设置为-g -source 1.5 -classpath "$[ClassPath]" -d "$[OutputPath]" -classpath stanford-postagger.jar $[JavaFiles]
在运行应用程序中,参数I设置为-classpath "$[ClassPath]" -classpath stanford-postagger.jar edu.stanford.nlp.tagger.maxent.MaxentTagger $[JavaClass]
stanford-postagger
文件位于C:\prototype
位置。
当我运行程序时,它会显示结果:
Exception in thread "main" java.lang.RuntimeException: unknown argument(s): "TagText"
at edu.stanford.nlp.tagger.maxent.TaggerConfig.<init>(TaggerConfig.java:139)
at edu.stanford.nlp.tagger.maxent.TaggerConfig.<init>(TaggerConfig.java:133)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.main(MaxentTagger.java:1603)
Process completed.
我做错了什么?
答案 0 :(得分:0)
在“运行应用程序”中删除参数:
edu.stanford.nlp.tagger.maxent.MaxentTagger