【发布时间】:2013-09-17 06:05:36
【问题描述】:
public class Sample {
public static void main(String[] args) throws IOException,
ClassNotFoundException {
// Initialize the tagger
MaxentTagger tagger = new MaxentTagger("taggers/wsj-0-18-bidirectional-nodistsim.tagger");
// The sample string
String sample = "I am a good boy";
String[] tokens = sample.split(" ");
for(int i=0;i<tokens.length;i++){
String tagged = tagger.tagString(tokens[i]);
System.out.println(tagged);
}
// The tagged string
//String tagged = tagger.tagTokenizedString(sample);
// Output the result
//System.out.println(tagged.startsWith("N"));
}
}
输出:
I_PRP
am_VB
a_DT
good_JJ
boy_NN
问:我需要在上面的程序中打印男孩作为输出,因为它被标记为单数名词(NN)
【问题讨论】:
-
问题中存在少量混淆。问题要求NN,但是问题的代码显示了一种以N开头的任何词性的方法,其中有4个。然后,有以P开头的代词,那些重要的名词吗?我尽我所能编辑。
标签: java tagging stanford-nlp pos-tagger