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


Java IWordID类代码示例

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


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

示例1: extractLastHypernym

import edu.mit.jwi.item.IWordID; //导入依赖的package包/类
private String extractLastHypernym(Token token) throws IOException {
  String result = token.getCoveredText();
  String path = "wordnet" + File.separator + "dict";
  URL url = new URL("file", null, path);
  IDictionary dict = new Dictionary(url);
  dict.open();
  IIndexWord idxWord = dict.getIndexWord(token.getCoveredText().toLowerCase(), getCorrectPOS(token.getPos()));
  if (idxWord != null && idxWord.getWordIDs().size() > 0) {
    IWordID wordID = idxWord.getWordIDs().get(0);
    IWord word = dict.getWord(wordID);
    ISynset synset = word.getSynset();
    List<ISynsetID> hypernyms = synset.getRelatedSynsets(Pointer.HYPERNYM);
    List<IWord> words;
    for (ISynsetID sid : hypernyms) {
      words = dict.getSynset(sid).getWords();
      for (Iterator<IWord> i = words.iterator(); i.hasNext();) {
        result = i.next().getLemma();
      }
    }
  }
  dict.close();
  return result;
}
 
开发者ID:utk4rsh,项目名称:question-classifier,代码行数:24,代码来源:HeadWordExtractor.java

示例2: getT

import edu.mit.jwi.item.IWordID; //导入依赖的package包/类
public String getT(){
	if(wordName==null)return "";
	String ret = "<html><body>";
	ret+= "<center><h1><b>"+wordName.replaceAll("_", " ")+"</b></h1></center>";
	for(int i=0;i<4;++i){
		if(wordIndexArray[i]==null)continue;
		ret+="<h2><b>"+POfS[i]+".</h2><b>";
		List<IWordID> temp = wordIndexArray[i].getWordIDs();
		for(int j=0;j<temp.size();++j){
			IWordID wordID = temp.get(j);
		ISynset synset = dict.getWord(wordID).getSynset();
		String gloss = synset.getGloss();
		ret+="<li>"+parseMean(gloss)+parseSynset(synset)+parseExample(gloss,i,j)+"</li>";
		}
	}
	ret+="</body></html>";
	return ret;
}
 
开发者ID:MusicCraftor,项目名称:WordNet-Explorer,代码行数:19,代码来源:WordDic.java

示例3: fillList

import edu.mit.jwi.item.IWordID; //导入依赖的package包/类
Set<String> fillList(Pointer ptype,Map<IPointer, List<IWordID>> wordMap,Map<IPointer, List<ISynsetID>> synMap){
	Set<String> ts;
	List<IWordID> tw;
	List<ISynsetID> tsy;
	ts  = new TreeSet<String>();
	tw = wordMap.get(ptype);
	if(tw!=null){
		for(IWordID wid:tw){
			String tempString = wid.getLemma();
			if(tempString!=null)ts.add(tempString);
		}
	}
	tsy = synMap.get(ptype);
	if(tsy!=null){
		for(ISynsetID sid:tsy){
			List<IWord> t = dict.getSynset(sid).getWords();
			if(t!=null)
				for(IWord w:t){
					ts.add(w.getLemma());
				}
		}
	}
	if(!ts.isEmpty())return ts;
	return null;
}
 
开发者ID:MusicCraftor,项目名称:WordNet-Explorer,代码行数:26,代码来源:WordDic.java

示例4: runWord

import edu.mit.jwi.item.IWordID; //导入依赖的package包/类
public static void runWord(WordnetRulesSource wns, IIndexWord iw1,
		StringBuilder bs) {

	for (int i = 0; i < iw1.getWordIDs().size(); i++) {
		ISynsetID synsetID = iw1.getWordIDs().get(i).getSynsetID();
		ISynset synset = wns.dictionary().getSynset(synsetID);
		List<ISynsetID> hypernymsSynset = synset
				.getRelatedSynsets(Pointer.HYPONYM);

		for (ISynsetID sid : hypernymsSynset) {
			List<IWord> iws = wns.dictionary().getSynset(sid).getWords();
			for (IWord iw : iws) {
				List<IWordID> x = iw.getRelatedWords();
				for (IWordID xx : x)
					bs.append(xx.getLemma().replace("_", " ") + "\n");
				bs.append(iw.getLemma().replace("_", " ") + "\n");
			}
		}
	}
}
 
开发者ID:kouylekov,项目名称:edits,代码行数:21,代码来源:WordnetRulesSource.java

示例5: getAllGlosses

import edu.mit.jwi.item.IWordID; //导入依赖的package包/类
public String getAllGlosses(String search_word) {

		int i = 1;
		for (POS p : POS_ARR) {
			IIndexWord idxWord = dict.getIndexWord(search_word, p);
			if (idxWord == null)
				continue;
			List<IWordID> wordIDs = idxWord.getWordIDs();
			for (IWordID wordID : wordIDs) {
				IWord iword = dict.getWord(wordID);
				m.append(String.format(Locale.getDefault(), "%d. (%s) %s\n",
						i, shorten(iword.getPOS().toString()), iword.getSynset()
						.getGloss()));
				++i;
			}
		}
		return m.toString();
	}
 
开发者ID:vin-ivar,项目名称:XDictionary,代码行数:19,代码来源:DictSearch.java

示例6: getTopGlosses

import edu.mit.jwi.item.IWordID; //导入依赖的package包/类
public String getTopGlosses(String search_word) {

		int i = 1;
		for (POS p : POS_ARR) {
			IIndexWord idxWord = dict.getIndexWord(search_word, p);
			if (idxWord == null)
				continue;
			List<IWordID> wordIDs = idxWord.getWordIDs();
			IWordID wordID = wordIDs.get(0);
			IWord iword = dict.getWord(wordID);
			m.append(String.format(Locale.getDefault(), "%d. (%s) %s\n",
					i, shorten(iword.getPOS().toString()), iword.getSynset()
					.getGloss()));
			++i;
		}
		return m.toString();
	}
 
开发者ID:vin-ivar,项目名称:XDictionary,代码行数:18,代码来源:DictSearch.java

示例7: getAll

import edu.mit.jwi.item.IWordID; //导入依赖的package包/类
public static List<WordParse> getAll(String wordString, POS pos) {
    if (dict == null) {
        return null;            
    }
    
    IIndexWord idxWord = dict.getIndexWord(wordString, pos);
    if (idxWord == null)
        return null;
    
    List<IWordID> words = idxWord.getWordIDs();
    if (words == null)
        return null;
    
    List<WordParse> parsed = new ArrayList(words.size());        
    for (IWordID iw : words) {
    
        IWordID wordID = idxWord.getWordIDs().get(0);
        IWord word = dict.getWord(wordID);
        parsed.add(new WordParse(wordString, word));
    }
    return parsed;
    
}
 
开发者ID:automenta,项目名称:netentionj-desktop,代码行数:24,代码来源:WordParse.java

示例8: getSortedSynsetsOf

import edu.mit.jwi.item.IWordID; //导入依赖的package包/类
public List<Synset> getSortedSynsetsOf(String lemma, WordNetPartOfSpeech partOfSpeech) throws WordNetException
{
	List<Synset> synsets = new ArrayList<Synset>();
	IIndexWord idxWord = jwiRealDictionary.getIndexWord (lemma, JwiUtils.getJwiPartOfSpeec(partOfSpeech));
	if (idxWord != null)
	{
		List<IWordID> wordIDs = idxWord.getWordIDs();
		for (IWordID wordID :  wordIDs)
		{
			IWord word = jwiRealDictionary.getWord(wordID);
			if (word == null)
				throw new WordNetException("Internal error: got this wordID " + wordID + " from the JWI dictionary, but the dictionary didn't find a word for it");
			ISynset jwiRealSynset = word.getSynset ();
			synsets.add(getSynset(jwiRealSynset));
		}
	}
	
	return synsets;
}
 
开发者ID:hltfbk,项目名称:Excitement-TDMLEDA,代码行数:20,代码来源:JwiDictionary.java

示例9: getRealSynsets

import edu.mit.jwi.item.IWordID; //导入依赖的package包/类
/**
 * @param lemma
 * @param pos
 * @return
 * @throws WordNetException 
 */
protected ISynset[] getRealSynsets(String lemma, WordNetPartOfSpeech pos) throws WordNetException  {
	IIndexWord idxWord = jwiRealDictionary.getIndexWord (lemma, JwiUtils.getJwiPartOfSpeec(pos));
	ISynset[] realSynsets ;
	if (idxWord != null)
	{
		List<IWordID> wordIDs = idxWord.getWordIDs();
		realSynsets = new ISynset[wordIDs.size()];
		int i = 0;
		for (IWordID wordID :  wordIDs)
		{
			IWord iWord = jwiRealDictionary.getWord(wordID);
			if (iWord == null)
				throw new WordNetException("Internal error: got this wordID " + wordID + " from the JWI dictionary, but the dictionary didn't find a word for it");
			ISynset jwiRealSynset = iWord.getSynset ();
			realSynsets[i++] = jwiRealSynset;
		}
	}
	else	// there is no synset matching <lemma, pos>
		realSynsets = new ISynset[0];
	return realSynsets;
}
 
开发者ID:hltfbk,项目名称:Excitement-TDMLEDA,代码行数:28,代码来源:JwiDictionary.java

示例10: trek

import edu.mit.jwi.item.IWordID; //导入依赖的package包/类
/**
 * Treking across Wordnet for performance measurements
 * 
 */
private void trek() {
  int tickNext = 0;
  int tickSize = 20000;
  int seen = 0;
  System.out.print("Treking across Wordnet");
  long t = System.currentTimeMillis();
  for (POS pos : POS.values()) {
    for (Iterator<IIndexWord> i = m_dict.getIndexWordIterator(pos); i
        .hasNext();) {
      for (IWordID wid : i.next().getWordIDs()) {
        seen += m_dict.getWord(wid).getSynset().getWords().size();
        if (seen > tickNext) {
          System.out.print(".");
          tickNext = seen + tickSize;
        }
      }
    }
  }
  System.out.printf("done (%1d msec)\n", System.currentTimeMillis() - t);
  System.out.println("In my trek I saw " + seen + " words");
}
 
开发者ID:millecker,项目名称:storm-apps,代码行数:26,代码来源:WordNet.java

示例11: getMeanings

import edu.mit.jwi.item.IWordID; //导入依赖的package包/类
private String getMeanings(String word, POS pos){
	String result = "";
	IIndexWord idxWord = dict.getIndexWord (word , pos) ;
	if(idxWord == null) return "";
	
	int i= 1;
	
	for (IWordID iwordid: idxWord.getWordIDs()){
		result += i + " - ";
		result += "(" + iwordid.getSynsetID().getOffset() + ") ";
		IWord iword = dict.getWord(iwordid);
		result += ": ";
		for(IWord iword2 : iword.getSynset().getWords())
			result += iword2.getLemma() + ", ";
		result += "\n==> " + iword.getSynset().getGloss() + "\n\n";
		i++;
	}
	return result;
}
 
开发者ID:kariminf,项目名称:langpi,代码行数:20,代码来源:WNsearchWords.java

示例12: getWord

import edu.mit.jwi.item.IWordID; //导入依赖的package包/类
@Override
public String getWord(int synset, String pos) {
	try {
		dict.open();
	} catch (IOException e) {
		return "";
	}
	IWordID wordID1 = new WordID(synset,POS.valueOf(pos),1);
	IWord word1 = dict.getWord(wordID1);
	
	String lemma = word1.getLemma();
	
	dict.close();
	
	return lemma;
}
 
开发者ID:kariminf,项目名称:langpi,代码行数:17,代码来源:JWIRequestor.java

示例13: getWords

import edu.mit.jwi.item.IWordID; //导入依赖的package包/类
@Override
public List<String> getWords(int synset, String pos) {
	ArrayList<String> words = new ArrayList<String>();
	
	try {
		dict.open();
	} catch (IOException e) {
		return words;
	}
	
	IWordID wordID1 = new WordID(synset,POS.valueOf(pos),1);
	IWord word1 = dict.getWord(wordID1);
	ISynset isynset = word1.getSynset() ;
	
	for( IWord word : isynset.getWords () )
		words.add(word.getLemma());
		
	return words;
}
 
开发者ID:kariminf,项目名称:langpi,代码行数:20,代码来源:JWIRequestor.java

示例14: testWordSearch

import edu.mit.jwi.item.IWordID; //导入依赖的package包/类
public static void testWordSearch() throws IOException{

		// construct the URL to the Wordnet dictionary directory
		File file =new File("wordnetDB/dict/");
		// construct the dictionary object and open it
		IDictionary dict = new Dictionary(file) ;
		dict.open();
		
		IIndexWord idxWord = dict.getIndexWord ("midnight" , POS.NOUN) ;
		if(idxWord == null) System.out.println("no word\n--------\n");
		
		for (IWordID iword: idxWord.getWordIDs()){
			System.out.println("offset: " + iword.getSynsetID().getOffset());
			IWord word = dict.getWord(iword);
			System.out.println("gloss: " + word.getSynset().getGloss());
		}
		
		//System.out.println("offset: " + idxWord.getWordIDs().get(0).getSynsetID().getOffset());

		dict.close();
	}
 
开发者ID:kariminf,项目名称:langpi,代码行数:22,代码来源:WordNetTest.java

示例15: ExtractSynsetsSentence

import edu.mit.jwi.item.IWordID; //导入依赖的package包/类
public List<SynonymDomain> ExtractSynsetsSentence(String Sentence,File englishStopwordsFilePath) throws IOException, Exception
{
    List<SynonymDomain> lstSynset=new ArrayList<>();
    String sentenceKeyWords=EX.ExtractKeyword(Sentence, englishStopwordsFilePath);
    for(String str:sentenceKeyWords.split(","))
    {
    String strSynset="";
    File dicFile=new File(path);
    IDictionary dict=new Dictionary(dicFile);
    dict.open();
    WordnetStemmer stemmer=new WordnetStemmer(dict);
     try
     {
        List<String> lstStem=stemmer.findStems(str, POS.NOUN);
        IIndexWord idxWord = dict . getIndexWord (lstStem.get(0), POS.NOUN);
        IWordID wordID = idxWord . getWordIDs ().get(0);
        IWord word = dict.getWord(wordID);
        ISynset sen=word.getSynset();
         for(IWord w:sen.getWords())
         {
           strSynset+=w.getLemma()+",";
           
         }
        lstSynset.add(new SynonymDomain(str, strSynset));
     }
     catch(Exception ex)
     {
        
     }
    }
    return lstSynset;
}
 
开发者ID:unsw-cse-soc,项目名称:Data-curation-API,代码行数:33,代码来源:Synonyms.java


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