/** * 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; }
/** * Find the ordinal of targetSynset, among the lemma's synsets * * @param lemma * @param pos * @param targetSynset * @return * @throws LexicalResourceException * @throws WordNetException */ private int getSynsetNo(String lemma, PartOfSpeech pos, Synset targetSynset) throws LexicalResourceException { int synsetNo = 1; WordNetPartOfSpeech wnPos = null; try { wnPos = WordNetPartOfSpeech.toWordNetPartOfspeech(pos); if (wnPos != null) for (Synset synset : dictionary.getSortedSynsetsOf(lemma, wnPos)) if (synset.equals(targetSynset)) return synsetNo; else synsetNo++; } catch (WordNetException e) { throw new LexicalResourceException( "Error pulling the synsets of <" + lemma + ", " + pos + ">", e); } throw new LexicalResourceException( "Internal error. could not find the following synset in the synset-set of <" + lemma + ", " + wnPos + ">: " + targetSynset); }