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;
}
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);
}
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);
}
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);
}
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;
}
Aggregations