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"));
}
}
OUTPUT:
I_PRP
am_VB
a_DT
good_JJ
boy_NN
Q: I need to print boy as output in the above program as it is tagged as singular nouns(NN)