/**
  * return the list of WN POSs corresponding to the given generic POS. may return an empty list
  *
  * @param genericPos
  * @return
  * @throws LexicalResourceException
  */
 private WordNetPartOfSpeech[] toWordNetPartOfspeech(PartOfSpeech genericPos)
     throws LexicalResourceException {
   WordNetPartOfSpeech[] poss;
   if (genericPos == null) poss = WordNetPartOfSpeech.values(); // null is a wildcard POS
   else {
     WordNetPartOfSpeech wnPos = WordNetPartOfSpeech.toWordNetPartOfspeech(genericPos);
     if (wnPos != null) {
       poss = ARRAY_OF_ONE_POS;
       poss[0] = wnPos;
     } else poss = EMPTY_ARRAY_OF_POS;
   }
   return poss;
 }
コード例 #2
0
 /*
  * (non-Javadoc)
  * @see ac.biu.nlp.nlp.instruments.dictionary.wordnet.Dictionary#getSortedSynsetOf(java.lang.String)
  */
 public Map<WordNetPartOfSpeech, List<Synset>> getSortedSynsetOf(String lemma)
     throws WordNetException {
   Map<WordNetPartOfSpeech, List<Synset>> ret =
       new LinkedHashMap<WordNetPartOfSpeech, List<Synset>>();
   if (doNotProcessThisWord(lemma)) ;
   else {
     try {
       IndexWordSet indexWordSet = extJwnlRealDictionary.lookupAllIndexWords(lemma);
       if (indexWordSet != null) {
         for (WordNetPartOfSpeech partOfSpeech : WordNetPartOfSpeech.values()) {
           POS pos = ExtJwnlUtils.getJwnlPartOfSpeec(partOfSpeech);
           if (indexWordSet.getIndexWord(pos) != null)
             ret.put(partOfSpeech, indexWordToList(indexWordSet.getIndexWord(pos)));
         }
       }
     } catch (JWNLException e) {
       throw new WordNetException(
           "looking for lemma <" + lemma + "> failed. See nested exception", e);
     }
   }
   return ret;
 }