Example #1
0
 private static List<TaggedWord> cleanTags(List twList, TreebankLanguagePack tlp) {
   int sz = twList.size();
   List<TaggedWord> l = new ArrayList<TaggedWord>(sz);
   for (int i = 0; i < sz; i++) {
     TaggedWord tw = (TaggedWord) twList.get(i);
     TaggedWord tw2 = new TaggedWord(tw.word(), tlp.basicCategory(tw.tag()));
     l.add(tw2);
   }
   return l;
 }
  public ArrayList<String> getNounsFromSentence(String sentence) {
    ArrayList<TaggedWord> tw = parseSentenceTD(sentence);
    ArrayList<String> nouns = new ArrayList<String>();

    for (TaggedWord t : tw) {
      if (t.tag().startsWith("N")) {
        nouns.add(t.value());
      }
    }

    return nouns;
  }