Search in sources :

Example 1 with Synset

use of net.didion.jwnl.data.Synset in project lucida by claritylab.

the class WordNetAnswerTypeMapping method findWnMapMatch.

private static AnswerType findWnMapMatch(Synset synset, int level) throws Exception {
    AnswerType type = null;
    String synsetId = buildSynsetString(synset);
    String typeStr = wnAtypeMap.get(synsetId);
    if (typeStr != null) {
        type = AnswerType.constructFromString(typeStr);
        type.setConfidence(1.0 - ((double) level / 100.0));
        return type;
    }
    PointerTargetNodeList ptNodeList = null;
    ptNodeList = pUtils.getDirectHypernyms(synset);
    for (int i = 0; i < ptNodeList.size(); i++) {
        Synset parent = (Synset) ((PointerTargetNode) ptNodeList.get(i)).getPointerTarget();
        type = findWnMapMatch(parent, level + 1);
        if (type != null)
            return type;
    }
    return type;
}
Also used : Synset(net.didion.jwnl.data.Synset) PointerTargetNodeList(net.didion.jwnl.data.list.PointerTargetNodeList)

Example 2 with Synset

use of net.didion.jwnl.data.Synset in project lucida by claritylab.

the class WordNet method getSubstancesOf.

/**
	 * Looks up substance holonyms of the given noun, assuming that it is used in
	 * its most common sense.
	 * 
	 * @param noun a noun
	 * @return substance holonyms or <code>null</code> if lookup failed
	 */
public static String[] getSubstancesOf(String noun) {
    Synset synset = getCommonSynset(noun, NOUN);
    if (synset == null)
        return null;
    Synset[] substancesOf = getSubstanceOfSynsets(synset);
    if (substancesOf == null)
        return null;
    return getLemmas(substancesOf);
}
Also used : Synset(net.didion.jwnl.data.Synset)

Example 3 with Synset

use of net.didion.jwnl.data.Synset in project lucida by claritylab.

the class WordNet method getCausing.

/**
	 * Looks up verbs that cause the given verb, assuming that it is used in its
	 * most common sense.
	 * 
	 * @param verb a verb
	 * @return causing verbs or <code>null</code> if lookup failed
	 */
public static String[] getCausing(String verb) {
    Synset synset = getCommonSynset(verb, VERB);
    if (synset == null)
        return null;
    Synset[] causing = getCausingSynsets(synset);
    if (causing == null)
        return null;
    return getLemmas(causing);
}
Also used : Synset(net.didion.jwnl.data.Synset)

Example 4 with Synset

use of net.didion.jwnl.data.Synset in project lucida by claritylab.

the class WordNet method getHyponyms.

/**
	 * Looks up hyponyms of the synset with the given POS and offset.
	 * 
	 * @param pos POS of the synset
	 * @param offset offset of the synset
	 * @return hyponyms or <code>null</code> if lookup failed
	 */
public static String[] getHyponyms(POS pos, long offset) {
    Synset synset = null;
    try {
        synset = dict.getSynsetAt(pos, offset);
    } catch (JWNLException e) {
    }
    if (synset == null)
        return null;
    Synset[] hyponyms = getHyponymSynsets(synset);
    if (hyponyms == null)
        return null;
    return getLemmas(hyponyms);
}
Also used : Synset(net.didion.jwnl.data.Synset) JWNLException(net.didion.jwnl.JWNLException)

Example 5 with Synset

use of net.didion.jwnl.data.Synset in project lucida by claritylab.

the class WordNet method getCommonSynset.

/**
	 * Looks up the most common synset of a word.
	 * 
	 * @param word a word
	 * @param pos its part of speech
	 * @return synset or <code>null</code> if lookup failed
	 */
private static Synset getCommonSynset(String word, POS pos) {
    if (dict == null)
        return null;
    Synset synset = null;
    try {
        IndexWord indexWord = dict.lookupIndexWord(pos, word);
        if (indexWord == null)
            return null;
        synset = indexWord.getSense(1);
    } catch (JWNLException e) {
    }
    return synset;
}
Also used : Synset(net.didion.jwnl.data.Synset) JWNLException(net.didion.jwnl.JWNLException) 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