use of net.didion.jwnl.data.Synset in project lucida by claritylab.
the class WordNet method getSynsets.
/**
* Looks up the synsets that correspond to the nodes in a node list.
*
* @param nodes node list
* @return synsets
*/
private static Synset[] getSynsets(PointerTargetNodeList nodes) {
Synset[] synsets = new Synset[nodes.size()];
for (int i = 0; i < nodes.size(); i++) {
PointerTargetNode node = (PointerTargetNode) nodes.get(i);
synsets[i] = node.getSynset();
}
return synsets;
}
use of net.didion.jwnl.data.Synset in project lucida by claritylab.
the class WordNet method getMembersOf.
// relations for nouns
/**
* Looks up member holonyms of the given noun, assuming that it is used in
* its most common sense.
*
* @param noun a noun
* @return member holonyms or <code>null</code> if lookup failed
*/
public static String[] getMembersOf(String noun) {
Synset synset = getCommonSynset(noun, NOUN);
if (synset == null)
return null;
Synset[] membersOf = getMemberOfSynsets(synset);
if (membersOf == null)
return null;
return getLemmas(membersOf);
}
use of net.didion.jwnl.data.Synset in project lucida by claritylab.
the class WordNetAnswerTypeMapping method getAnswerType.
public static String getAnswerType(Term focusTerm) {
if (focusTerm == null) {
return null;
}
String focusText = focusTerm.getText();
List<AnswerType> focusTypes = new ArrayList<AnswerType>();
try {
IndexWord indexWord = Dictionary.getInstance().lookupIndexWord(POS.NOUN, focusText);
if (indexWord == null)
throw new Exception("Failed to get index word");
Synset[] senses = indexWord.getSenses();
if (senses == null)
throw new Exception("Failed to get synsets");
for (Synset sense : senses) {
AnswerType type = findWnMapMatch(sense, 0);
if (type != null) {
focusTypes.add(type);
}
}
} catch (Exception e) {
log.warn("Failed to get hypernyms for noun '" + focusText + "'");
}
if (focusTypes.size() == 0)
return focusText.toLowerCase().replaceAll(" ", "_");
Collections.sort(focusTypes, atypeComparator);
return focusTypes.get(0).getType();
}
Aggregations