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


Java WordnetStemmer.findStems方法代码示例

本文整理汇总了Java中edu.mit.jwi.morph.WordnetStemmer.findStems方法的典型用法代码示例。如果您正苦于以下问题:Java WordnetStemmer.findStems方法的具体用法?Java WordnetStemmer.findStems怎么用?Java WordnetStemmer.findStems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.mit.jwi.morph.WordnetStemmer的用法示例。


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

示例1: ExtractSynsetsSentence

import edu.mit.jwi.morph.WordnetStemmer; //导入方法依赖的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

示例2: ExtractSynonymWord

import edu.mit.jwi.morph.WordnetStemmer; //导入方法依赖的package包/类
@Override
public List<String> ExtractSynonymWord(String word) throws URISyntaxException, IOException 
{
	List<String> lstSynonym=new ArrayList<>();
	java.net.URL url = getClass().getClassLoader().getResource("dict\\");
    //File dicFile = new File(url.toURI());
    String strSynset="";
       IDictionary dict=new Dictionary(new File(path));
       dict.open();
       WordnetStemmer stemmer=new WordnetStemmer(dict);
        try
        {
           List<String> lstStem=stemmer.findStems(word, POS.NOUN);
           for(int i=0;i<1000;i++)
           {
           IIndexWord idxWord = dict . getIndexWord (lstStem.get(0), POS.NOUN);
           IWordID wordID = idxWord . getWordIDs ().get(i);
           IWord words = dict.getWord(wordID);
           ISynset sen=words.getSynset();
            for(IWord w:sen.getWords())
            {
           	 
           	 lstSynonym.add(w.getLemma());
            }
            
           }
        }
        catch(Exception ex)
        {
        }
       return lstSynonym;
}
 
开发者ID:unsw-cse-soc,项目名称:Data-curation-API,代码行数:33,代码来源:WordNetFile.java

示例3: ExtractHypernymWord

import edu.mit.jwi.morph.WordnetStemmer; //导入方法依赖的package包/类
@Override
public List<String> ExtractHypernymWord(String word) {
	 //String strHypernym="";
	 List<String> lstHypernym=new ArrayList<>();
      try
        {
    	   // java.net.URL url = getClass().getClassLoader().getResource("dict\\");
  	       // File dicFile = new File(url.toURI());
            IDictionary dict=new Dictionary(new File(path));
            dict.open();
            WordnetStemmer stemmer=new WordnetStemmer(dict);
            List<String> lstStem=stemmer.findStems(word, POS.NOUN);
            for(int j=0;j<1000;j++)
            {
            IIndexWord idxWord = dict.getIndexWord(lstStem.get(0),POS.NOUN);
            IWordID wordID = idxWord.getWordIDs().get (j) ;
            IWord mywords = dict . getWord (wordID);
            ISynset sen=mywords.getSynset();
            List <ISynsetID> hypernyms = sen.getRelatedSynsets (Pointer.HYPERNYM);
            List<IWord> words;
            for(ISynsetID sid : hypernyms)
            {
                words = dict . getSynset (sid). getWords ();
                for( Iterator <IWord > i = words . iterator (); i. hasNext () ;)
                {
                	
                	lstHypernym.add((i. next (). getLemma ()));
                //if(i. hasNext ())
                 //  strHypernym+=",";
                }
            }
            }
         }
       catch(Exception ex)
       {
       }
        return lstHypernym;
}
 
开发者ID:unsw-cse-soc,项目名称:Data-curation-API,代码行数:39,代码来源:WordNetFile.java

示例4: ExtractSynonymSentence

import edu.mit.jwi.morph.WordnetStemmer; //导入方法依赖的package包/类
public List<ExtractSynonym> ExtractSynonymSentence(String inputSentence) throws MalformedURLException, IOException
{
    List<ExtractSynonym> lstSynset=new ArrayList<>();
        for(String str:inputSentence.split(" "))
        {
            String strSynset="";
            File dicFile=new File(path);
            IDictionary dict=new Dictionary(dicFile);
            dict.open();
            WordnetStemmer stemmer=new WordnetStemmer(dict);
            for(int j=0;j<10;j++)
         {
              try
              {
                List<String> lstStem=stemmer.findStems(str, POS.NOUN);
                IIndexWord idxWord = dict . getIndexWord (lstStem.get(0), POS.NOUN);
                IWordID wordID = idxWord . getWordIDs ().get(j);
                IWord word = dict.getWord(wordID);
                ISynset sen=word.getSynset();
                 for(IWord w:sen.getWords())
                 {
                   strSynset+=w.getLemma()+",";
                 }
                
              }
              
              catch(Exception ex)
              {

              }
              
         }
            lstSynset.add(new ExtractSynonym(str, strSynset));
        }
    return lstSynset;
}
 
开发者ID:unsw-cse-soc,项目名称:Data-curation-API,代码行数:37,代码来源:WordNetFile.java

示例5: getStems

import edu.mit.jwi.morph.WordnetStemmer; //导入方法依赖的package包/类
/**
 * Get a list of possible stems. Assume we are looking up a noun.
 */
public static List<String> getStems(String word, String posTag, IDictionary iDictionary) {

	POS pos = POS.getPartOfSpeech(posTag.charAt(0));
	if (pos == null) {
		return new ArrayList<String>();
	}

	WordnetStemmer wordnetStemmer = new WordnetStemmer(iDictionary);
	List<String> stems = wordnetStemmer.findStems(word, pos);

	return stems;
}
 
开发者ID:annefried,项目名称:sitent,代码行数:16,代码来源:WordNetUtils.java

示例6: ExtractSynonymFile

import edu.mit.jwi.morph.WordnetStemmer; //导入方法依赖的package包/类
public List<ExtractSynonym> ExtractSynonymFile(File filePath) throws MalformedURLException, IOException
{
    List<ExtractSynonym> lstSynset=new ArrayList<>();
    BufferedReader reader=new BufferedReader(new FileReader(filePath));
    String Line="";
    List<String> lstText=new ArrayList<>();
    while((Line=reader.readLine())!=null)
    {
        lstText.add(Line);
    }
    for(String Sentence:lstText)
    {
        for(String str:Sentence.split(" "))
        {
            String strSynset="";
            File dicFile=new File(path);
            IDictionary dict=new Dictionary(dicFile);
            dict.open();
            WordnetStemmer stemmer=new WordnetStemmer(dict);
            for(int j=0;j<10;j++)
         {
             try
             {
            	List<String> lstStem=stemmer.findStems(str, POS.NOUN);
                IIndexWord idxWord = dict . getIndexWord (lstStem.get(0), POS.NOUN);
                IWordID wordID = idxWord . getWordIDs ().get(j);
                IWord word = dict.getWord(wordID);
                ISynset sen=word.getSynset();
                 for(IWord w:sen.getWords())
                 {
                   strSynset+=w.getLemma()+",";

                 }
                lstSynset.add(new ExtractSynonym(str, strSynset));
             }
             catch(Exception ex)
             {
             }
         }
        }
    }
    return lstSynset;
}
 
开发者ID:unsw-cse-soc,项目名称:Data-curation-API,代码行数:44,代码来源:WordNetFile.java


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