Search in sources :

Example 16 with Synset

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;
}
Also used : Synset(net.didion.jwnl.data.Synset) PointerTargetNode(net.didion.jwnl.data.list.PointerTargetNode)

Example 17 with Synset

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);
}
Also used : Synset(net.didion.jwnl.data.Synset)

Example 18 with Synset

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();
}
Also used : Synset(net.didion.jwnl.data.Synset) ArrayList(java.util.ArrayList) IndexWord(net.didion.jwnl.data.IndexWord)

Aggregations

Synset (net.didion.jwnl.data.Synset)18 ArrayList (java.util.ArrayList)4 Hashtable (java.util.Hashtable)3 JWNLException (net.didion.jwnl.JWNLException)2 IndexWord (net.didion.jwnl.data.IndexWord)2 PointerTargetNode (net.didion.jwnl.data.list.PointerTargetNode)1 PointerTargetNodeList (net.didion.jwnl.data.list.PointerTargetNodeList)1