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


Java IndexWordSet类代码示例

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


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

示例1: isCompoundWord

import net.didion.jwnl.data.IndexWordSet; //导入依赖的package包/类
/**
 * Checks if the word exists in WordNet. Supports multi-token terms.
 * 
 * @param word a word
 * @return <code>true</code> iff the word is in WordNet
 */
public static boolean isCompoundWord(String word) {
	if (dict == null) return false;
	
	// do not look up words with special characters other than '.'
	if (word.matches(".*?[^\\w\\s\\.].*+")) return false;
	
	IndexWordSet indexWordSet = null;
	try {
		indexWordSet = dict.lookupAllIndexWords(word);
	} catch (JWNLException e) {}
	
	// ensure that the word, and not just a substring, was found in WordNet
	int wordTokens = word.split("\\s", -1).length;
	int wordDots = word.split("\\.", -1).length;
	for (IndexWord indexWord : indexWordSet.getIndexWordArray()) {
		String lemma = indexWord.getLemma();
		int lemmaTokens = lemma.split("\\s", -1).length;
		int lemmaDots = lemma.split("\\.", -1).length;
		if (wordTokens == lemmaTokens && wordDots == lemmaDots) return true;
	}
	return false;
}
 
开发者ID:claritylab,项目名称:lucida,代码行数:29,代码来源:WordNet.java

示例2: _loadWordSenses

import net.didion.jwnl.data.IndexWordSet; //导入依赖的package包/类
private void _loadWordSenses() throws WordNetException {

//    Dictionary dict = this.wnMain.getJWNLDictionary();

    try {
      IndexWordSet iwSet = this.wnDictionary.lookupAllIndexWords(this.lemma);
      IndexWord[] arrIndexWords = iwSet.getIndexWordArray();

      for (int i=0; i< arrIndexWords.length; i++) {
        IndexWord iWord = arrIndexWords[i];
        net.didion.jwnl.data.Synset[] synsets = iWord.getSenses();
        for (int j=0; j< synsets.length; j++) {
          net.didion.jwnl.data.Synset currSynset = synsets[j];
        }
      }

//      this.
    }
    catch(JWNLException jwne) {
      throw new WordNetException(jwne);
    }

  }
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:24,代码来源:WordImpl.java

示例3: isWord

import net.didion.jwnl.data.IndexWordSet; //导入依赖的package包/类
/**
 * Checks if the word exists in WordNet.
 * 
 * @param word a word
 * @return <code>true</code> iff the word is in WordNet
 */
public static boolean isWord(String word) {
	if (dict == null) return false;
	
	IndexWordSet indexWordSet = null;
	try {
		indexWordSet = dict.lookupAllIndexWords(word);
	} catch (JWNLException e) {}
	
	return indexWordSet.size() > 0;
}
 
开发者ID:claritylab,项目名称:lucida,代码行数:17,代码来源:WordNet.java

示例4: lookupAllIndexWords

import net.didion.jwnl.data.IndexWordSet; //导入依赖的package包/类
/**
 * Return a set of <code>IndexWord</code>s, with each element in the set
 * corresponding to a part-of-speech of <var>word</var>.
 * @param lemma the word for which to lookup senses
 * @return An array of IndexWords, each of which is a sense of <var>word</var>
 */
public IndexWordSet lookupAllIndexWords(String lemma) throws JWNLException {
	lemma = prepareQueryString(lemma);
	IndexWordSet set = new IndexWordSet(lemma);
	for (Iterator itr = POS.getAllPOS().iterator(); itr.hasNext();) {
		IndexWord current = lookupIndexWord((POS)itr.next(), lemma);
		if (current != null) set.add(current);
	}
	return set;
}
 
开发者ID:duguyue100,项目名称:chomsky,代码行数:16,代码来源:Dictionary.java

示例5: getAllSenses

import net.didion.jwnl.data.IndexWordSet; //导入依赖的package包/类
/**
    * Retrieve all WordNet senses of a term
    * @param term
    * @return the set of senses of term
    */

   @SuppressWarnings("unchecked") // WordNet non-1.5
   Set<Synset> getAllSenses( String term ) throws OntoSimException {
Set<Synset> res = new HashSet<Synset>();
IndexWordSet iws = null;
try {
    iws = dictionary.lookupAllIndexWords( term );
} catch ( JWNLException ex ) {
    throw new OntoSimException( "Wordnet exception", ex );
       }
if ( iws != null ) {
    // not iterable...
    for ( IndexWord idx : (Collection<IndexWord>)iws.getIndexWordCollection() ) {
	Synset Syno[] = null;
	try {
	    // get the synsets for each sense
	    Syno = idx.getSenses();
	} catch ( JWNLException jwnlex ) {
	    throw new OntoSimException( "Wordnet exception", jwnlex );
	    //jwnlex.printStackTrace();
	}
	// number of senses for the word s1
	int synonymNb = idx.getSenseCount();
	// for each sense
	for ( int k = 0; k < synonymNb; k++ ) {
	    res.add( Syno[k] );
	}
    }
}
return res;
   }
 
开发者ID:dozed,项目名称:align-api-project,代码行数:37,代码来源:JWNLDistances.java


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