Java Code Examples for edu.mit.jwi.item.POS#values()

The following examples show how to use edu.mit.jwi.item.POS#values() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WordNet.java    From senti-storm with Apache License 2.0 5 votes vote down vote up
public boolean contains(String word) {
  for (POS pos : POS.values()) {
    for (String stem : m_wordnetStemmer.findStems(word, pos)) {
      IIndexWord indexWord = m_dict.getIndexWord(stem, pos);
      if (indexWord != null)
        return true;
    }
  }
  return false;
}
 
Example 2
Source File: WordNet.java    From senti-storm with Apache License 2.0 5 votes vote down vote up
public synchronized POS findPOS(String word) {
  int maxCount = 0;
  POS mostLikelyPOS = null;
  for (POS pos : POS.values()) {
    // From JavaDoc: The surface form may or may not contain whitespace or
    // underscores, and may be in mixed case.
    word = word.replaceAll("\\s", "").replaceAll("_", "");

    List<String> stems = m_wordnetStemmer.findStems(word, pos);
    for (String stem : stems) {
      IIndexWord indexWord = m_dict.getIndexWord(stem, pos);
      if (indexWord != null) {
        int count = 0;
        for (IWordID wordId : indexWord.getWordIDs()) {
          IWord aWord = m_dict.getWord(wordId);
          ISenseEntry senseEntry = m_dict.getSenseEntry(aWord.getSenseKey());
          count += senseEntry.getTagCount();
        }

        if (count > maxCount) {
          maxCount = count;
          mostLikelyPOS = pos;
        }
      }
    }
  }

  return mostLikelyPOS;
}
 
Example 3
Source File: WordNetUtils.java    From ADW with GNU General Public License v3.0 5 votes vote down vote up
public IWord getSenseFromSenseKey(final String sensekey)
{
	final String lemma = sensekey.split("%")[0];
	final Set<IWord> senses = new HashSet<IWord>();
	for (POS pos : POS.values())
		senses.addAll(getSenses(lemma, pos));

	for (IWord sense : senses)
		if (sense.getSenseKey().toString().equals(sensekey))
			return sense;

	return null;
}
 
Example 4
Source File: WordNetUtils.java    From ADW with GNU General Public License v3.0 5 votes vote down vote up
public Set<String> getWordNetStems(String word)
{
 Set<String> stems = new HashSet<String>();

 for (POS pos : POS.values())
	 stems.addAll(wnStemmer.findStems(word, pos));

 return stems;
}