当前位置: 首页>>代码示例>>Java>>正文


Java Synset类代码示例

本文整理汇总了Java中edu.smu.tspell.wordnet.Synset的典型用法代码示例。如果您正苦于以下问题:Java Synset类的具体用法?Java Synset怎么用?Java Synset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Synset类属于edu.smu.tspell.wordnet包,在下文中一共展示了Synset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSenseBag

import edu.smu.tspell.wordnet.Synset; //导入依赖的package包/类
public static String[] getSenseBag(Synset synset) {
    String senseBag = "";

    VerbSynset verbSynset = (VerbSynset) synset;
    senseBag += getSynsetBag(verbSynset);

    VerbSynset[] troponyms = verbSynset.getTroponyms();
    for (VerbSynset troponym : troponyms)
        senseBag += getSynsetBag(troponym);

    VerbSynset[] entailments = verbSynset.getEntailments();
    for (VerbSynset entailment : entailments)
        senseBag += getSynsetBag(entailment);

    VerbSynset[] outcomes = verbSynset.getOutcomes();
    for (VerbSynset outcome : outcomes)
        senseBag += getSynsetBag(outcome);

    VerbSynset[] hypernyms = verbSynset.getHypernyms();
    for (VerbSynset hypernym : hypernyms)
        senseBag += getSynsetBag(hypernym);

    return extractWordsFromSenseBag(senseBag);
}
 
开发者ID:butnaruandrei,项目名称:ShotgunWSD,代码行数:25,代码来源:VerbSenseBag.java

示例2: getSenseBag

import edu.smu.tspell.wordnet.Synset; //导入依赖的package包/类
public static String[] getSenseBag(Synset synset, String word) {
    String senseBag = "";

    AdverbSynset adverbSynset = (AdverbSynset) synset;
    senseBag += getSynsetBag(adverbSynset);

    NounSynset[] topics = adverbSynset.getTopics();
    for (NounSynset topic : topics)
        senseBag += getSynsetBag(topic);

    WordSense[] pertainyms = adverbSynset.getPertainyms(word);
    for (WordSense pertainym : pertainyms)
        senseBag += getSynsetBag(pertainym.getSynset());

    WordSense[] antonyms = adverbSynset.getAntonyms(word);
    for (WordSense antonym : antonyms)
        senseBag += getSynsetBag(antonym.getSynset());

    return extractWordsFromSenseBag(senseBag);
}
 
开发者ID:butnaruandrei,项目名称:ShotgunWSD,代码行数:21,代码来源:AdverbSenseBag.java

示例3: getSenseBag

import edu.smu.tspell.wordnet.Synset; //导入依赖的package包/类
public static String[] getSenseBag(Synset synset) {
    String senseBag = "";

    NounSynset nounSynset = (NounSynset) synset;
    senseBag += getSynsetBag(nounSynset);

    NounSynset[] hyponyms = nounSynset.getHyponyms();
    for (NounSynset hyponym : hyponyms)
        senseBag += getSynsetBag(hyponym);

    NounSynset[] meronyms = nounSynset.getMemberMeronyms();
    for (NounSynset meronym : meronyms)
        senseBag += getSynsetBag(meronym);

    return extractWordsFromSenseBag(senseBag);
}
 
开发者ID:butnaruandrei,项目名称:ShotgunWSD,代码行数:17,代码来源:NounSenseBag.java

示例4: getSenseBag

import edu.smu.tspell.wordnet.Synset; //导入依赖的package包/类
private static String[] getSenseBag(Synset synset, String word) {
    if(synset == null)
        return new String[0];

    SynsetType pos = synset.getType();

    if(pos == SynsetType.NOUN) {
        return NounSenseBag.getSenseBag(synset);
    } else if (pos == SynsetType.VERB) {
        return VerbSenseBag.getSenseBag(synset);
    } else if(pos == SynsetType.ADJECTIVE) {
        return AdjectiveSenseBag.getSenseBag(synset, word);
    } else if(pos == SynsetType.ADJECTIVE_SATELLITE) {
        return AdjectiveSenseBag.getSenseBag(synset, word);
    } else if(pos == SynsetType.ADVERB) {
        return AdverbSenseBag.getSenseBag(synset, word);
    }

    return new String[0];
}
 
开发者ID:butnaruandrei,项目名称:ShotgunWSD,代码行数:21,代码来源:SenseEmbedding.java

示例5: computeSimilarity

import edu.smu.tspell.wordnet.Synset; //导入依赖的package包/类
public double computeSimilarity(Synset synset1, String word1, Synset synset2, String word2){
    SynsetType pos1 = null, pos2 = null;

    try {
        pos1 = synset1.getType();
        pos2 = synset2.getType();
    } catch(Exception e){
        System.out.printf("ok");
    }

    if(pos1 == SynsetType.NOUN && pos2 == SynsetType.NOUN) {
        return NounSimilarity.similarity(synset1, synset2);
    } else if(pos1 == SynsetType.VERB && pos2 == SynsetType.VERB) {
        return VerbSimilarity.similarity(synset1, synset2);
    } else if(AdjectiveSimilarity.synsetTypeAdjective(pos1, pos2)) {
        return AdjectiveSimilarity.similarity(synset1, word1, synset2, word2);
    } else if(pos1 == SynsetType.ADVERB && pos2 == SynsetType.ADVERB) {
        return AdverbSimilarity.similarity(synset1, word1, synset2, word2);
    } else {
        return SynsetSimilarity.similarity(synset1, synset2);
    }
}
 
开发者ID:butnaruandrei,项目名称:ShotgunWSD,代码行数:23,代码来源:LeskRelatedness.java

示例6: getSynsetsFromWord

import edu.smu.tspell.wordnet.Synset; //导入依赖的package包/类
/**
 * Extract from WordNet Database the synsets of a word
 * @param wnDatabase WordNet Database
 * @param word The word that we want to extract its synsets
 * @param synsetType POS Tag of the word
 * @return Array of Synsets
 */
public static Synset[] getSynsetsFromWord(WordNetDatabase wnDatabase, String word, SynsetType synsetType) {
    Synset[] tmpSynsets;

    if(synsetType == null)
        tmpSynsets = wnDatabase.getSynsets(word);
    else {
        tmpSynsets = wnDatabase.getSynsets(word, synsetType);

        // If the synset type is an adjective, check for adjective satellite too
        if (synsetType == SynsetType.ADJECTIVE) {
            tmpSynsets = (Synset[])ArrayUtils.addAll(tmpSynsets, wnDatabase.getSynsets(word, SynsetType.ADJECTIVE_SATELLITE));
        }
    }

    return tmpSynsets;
}
 
开发者ID:butnaruandrei,项目名称:ShotgunWSD,代码行数:24,代码来源:WordUtils.java

示例7: convertFinalSynsets

import edu.smu.tspell.wordnet.Synset; //导入依赖的package包/类
public Synset[] convertFinalSynsets(String[] finalSenses){
    int wordIndex, senseIndex;
    String[] split;
    Synset[] synsets = new Synset[finalSenses.length];

    for (int i = 0; i < finalSenses.length; i++) {
        if(finalSenses[i] == null){
            synsets[i] = null;
        } else {
            split = finalSenses[i].split("-");

            wordIndex = Integer.parseInt(split[0]);
            senseIndex = Integer.parseInt(split[1]);

            synsets[i] = getSynset(wordIndex, senseIndex);
        }
    }

    return synsets;
}
 
开发者ID:butnaruandrei,项目名称:ShotgunWSD,代码行数:21,代码来源:ShotgunWSDRunner.java

示例8: isMostlyNounInWordNet

import edu.smu.tspell.wordnet.Synset; //导入依赖的package包/类
public static boolean isMostlyNounInWordNet(String word) {
	Synset[] synsets = database.getSynsets(word);
	if (synsets.length == 0) {
		return true;
	}
	Synset[] n_synsets = database.getSynsets(word, SynsetType.NOUN);
	Synset[] v_synsets = database.getSynsets(word, SynsetType.VERB);
	Synset[] a_synsets = database.getSynsets(word, SynsetType.ADJECTIVE);
	Synset[] ad_synsets = database.getSynsets(word, SynsetType.ADVERB);
	//		System.out.println(word + " " + n_synsets.length + " " + a_synsets.length + ad_synsets.length);
	if (n_synsets.length != 0 && n_synsets.length > a_synsets.length && 
			n_synsets.length > ad_synsets.length) {// && n_synsets.length > v_synsets.length) {
		return true;
	}
	return false;
}
 
开发者ID:uwnlp,项目名称:recipe-interpretation,代码行数:17,代码来源:Utils.java

示例9: isMostlyAdjectiveInWordNet

import edu.smu.tspell.wordnet.Synset; //导入依赖的package包/类
public static boolean isMostlyAdjectiveInWordNet(String word) {
	Synset[] synsets = database.getSynsets(word);
	if (synsets.length == 0) {
		return true;
	}
	Synset[] n_synsets = database.getSynsets(word, SynsetType.NOUN);
	Synset[] v_synsets = database.getSynsets(word, SynsetType.VERB);
	Synset[] a_synsets = database.getSynsets(word, SynsetType.ADJECTIVE);
	Synset[] ad_synsets = database.getSynsets(word, SynsetType.ADVERB);
	//		System.out.println(word + " " + n_synsets.length + " " + a_synsets.length + ad_synsets.length);
	if (a_synsets.length != 0 && a_synsets.length > n_synsets.length && 
			a_synsets.length > ad_synsets.length && a_synsets.length > v_synsets.length) {
		return true;
	}
	return false;
}
 
开发者ID:uwnlp,项目名称:recipe-interpretation,代码行数:17,代码来源:Utils.java

示例10: canWordBeNounOrAdjInWordNet

import edu.smu.tspell.wordnet.Synset; //导入依赖的package包/类
public static boolean canWordBeNounOrAdjInWordNet(String word) {
	Synset[] synsets = database.getSynsets(word, SynsetType.NOUN);
	if (synsets.length == 0) {
		synsets = database.getSynsets(word, SynsetType.ADJECTIVE);
		if (synsets.length == 0) {
			synsets = database.getSynsets(word);
			if (synsets.length == 0 && word.length() > 3) {
				return true;
			}
			return false;
		} else {
			return true;
		}
	} else {
		return true;
	}
}
 
开发者ID:uwnlp,项目名称:recipe-interpretation,代码行数:18,代码来源:Utils.java

示例11: resolvePointers

import edu.smu.tspell.wordnet.Synset; //导入依赖的package包/类
/**
 * Converts unresolved pointers of a particular type to resolved
 * references to the corresponding synsets.
 * <br><p>
 * Note that on successful completion of this method that the pointers
 * that were resolved will be removed. This is done to reduce memory
 * usage since the pointers are presumed to no longer be needed given
 * that their sole purpose was to provide eventual access to their
 * corresponding synsets.
 * 
 * @param  type Type of relationships to resolve and return.
 * @return Synsets that were referenced by pointers or <code>null</code>
 *         if no pointers existed for the specified type.
 * @throws WordNetException An error occurred retrieving data.
 */
private Synset[] resolvePointers(RelationshipType type)
		throws WordNetException
{
	Synset[] synsets = null;
	SynsetPointer[] pointers = getPointers(type);
	if (pointers != null)
	{
		SynsetFactory factory = SynsetFactory.getInstance();
		synsets = new Synset[pointers.length];
		for (int i = 0; i < synsets.length; i++)
		{
			synsets[i] = factory.getSynset(pointers[i]);
		}
		clearPointers(type);
	}
	return synsets;
}
 
开发者ID:jaytaylor,项目名称:jaws,代码行数:33,代码来源:ReferenceSynset.java

示例12: getSenseKeysBag

import edu.smu.tspell.wordnet.Synset; //导入依赖的package包/类
protected static String getSenseKeysBag(Synset synset) {
    String senseBag = "";

    String[] senseKeys = synset.getSenseKeys();
    for(String senseKey : senseKeys) {
        senseBag += senseKey.split("%")[0] + " ";
    }

    return senseBag;
}
 
开发者ID:butnaruandrei,项目名称:ShotgunWSD,代码行数:11,代码来源:SynsetSenseBag.java

示例13: getSynsetBag

import edu.smu.tspell.wordnet.Synset; //导入依赖的package包/类
protected static String getSynsetBag(Synset synset) {
    String senseBag = " ";
    String[] examples;

    senseBag += getSenseKeysBag(synset);
    senseBag += synset.getDefinition();
    examples = synset.getUsageExamples();

    for (String example1 : examples)
        senseBag += " " + example1;

    return senseBag;
}
 
开发者ID:butnaruandrei,项目名称:ShotgunWSD,代码行数:14,代码来源:SynsetSenseBag.java

示例14: computeSimilarity

import edu.smu.tspell.wordnet.Synset; //导入依赖的package包/类
public double computeSimilarity(Synset synset1, String word1, Synset synset2, String word2){
    INDArray[] senseEmbeddings = new INDArray[2];
    senseEmbeddings[0] = Nd4j.create(SenseEmbedding.getSenseEmbedding(wordVectors, synset1, word1, senseComputation));
    senseEmbeddings[1] = Nd4j.create(SenseEmbedding.getSenseEmbedding(wordVectors, synset2, word2, senseComputation));

    return computeSimilarity(senseEmbeddings, null, null, 0, 1);
}
 
开发者ID:butnaruandrei,项目名称:ShotgunWSD,代码行数:8,代码来源:WordEmbeddingRelatedness.java

示例15: computeSynsetRepresentations

import edu.smu.tspell.wordnet.Synset; //导入依赖的package包/类
/**
 * Generates the sense embedding for each synset of every word from the context window
 */
public Object[] computeSynsetRepresentations(Synset[] windowWordsSynsets, String[] windowWords, int[] synset2WordIndex) {
    Object[] windowWordsSenseEmbeddings = new INDArray[windowWordsSynsets.length];
    for (int k = 0; k < windowWordsSynsets.length; k++) {
        windowWordsSenseEmbeddings[k] = Nd4j.create(SenseEmbedding.getSenseEmbedding(wordVectors, windowWordsSynsets[k], windowWords[synset2WordIndex[k]], senseComputation));
    }

    return windowWordsSenseEmbeddings;
}
 
开发者ID:butnaruandrei,项目名称:ShotgunWSD,代码行数:12,代码来源:WordEmbeddingRelatedness.java


注:本文中的edu.smu.tspell.wordnet.Synset类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。