I want to get NN or NNS from a sample text as given within the script below. To this end, when I use the code below, the output is:
types
synchronization
phase
synchronization
-RSB-
synchronization
-LSB-
-RSB-
projection
synchronization
Here why am I getting [-RSB-]
or [-LSB-]
? Should I use a different pattern to get NN or NNS at the same time?
atic = "So far, many different types of synchronization have been investigated, such as complete synchronization [8], generalized synchronization [9], phase synchronization [10], lag synchronization [11], projection synchronization [12, 13], and so forth.";
Reader reader = new StringReader(atic);
DocumentPreprocessor dp = new DocumentPreprocessor(reader);
docs_terms_unq.put(rs.getString("u"), new ArrayList<String>());
docs_terms.put(rs.getString("u"), new ArrayList<String>());
for (List<HasWord> sentence : dp) {
List<TaggedWord> tagged = tagger.tagSentence(sentence);
GrammaticalStructure gs = parser.predict(tagged);
Tree x = parserr.parse(sentence);
System.out.println(x);
TregexPattern NPpattern = TregexPattern.compile("@NN|NNS");
TregexMatcher matcher = NPpattern.matcher(x);
while (matcher.findNextMatchingNode()) {
Tree match = matcher.getMatch();
ArrayList hh = match.yield();
Boolean b = false;
System.out.println(hh.toString());}
I do not know why those are coming up. But you will get more accurate POS tags if you use the part of speech tagger. I would suggest just looking directly at the Annotation. Here is some sample code.
And the output I get.
Here is an example of getting the NP's from a sentence: