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


Java WordnetStemmer类代码示例

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


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

示例1: WordNetUtils

import edu.mit.jwi.morph.WordnetStemmer; //导入依赖的package包/类
private WordNetUtils()
{
	try
	{
		final String location = ADWConfiguration.getInstance().getWordNetData();
		final Dictionary dict = new Dictionary(new URL("file", null, location));
		dict.getCache().setMaximumCapacity(Integer.MAX_VALUE);
		this.dictionary = dict;

		this.dictionary.open();
		
		wnStemmer = new WordnetStemmer(dict);
	}
	catch (Exception mue)
	{
		mue.printStackTrace();
	}
	
}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:20,代码来源:WordNetUtils.java

示例2: initialize

import edu.mit.jwi.morph.WordnetStemmer; //导入依赖的package包/类
@Override
public void initialize(UimaContext context)
        throws ResourceInitializationException {
    super.initialize(context);
    try {
        if (dictFile == null) // use default
            dictFile = CommonAnnotatorsHelper.COMMON_ANNOTATORS_ROOT
                    + "src/main/resources/wordnet-3.1/dict";
        dict = new RAMDictionary(new File(dictFile),
                ILoadPolicy.BACKGROUND_LOAD);
        dict.open();
        stemmer = new WordnetStemmer(dict);
    } catch (IOException e) {
        throw new ResourceInitializationException(e);
    }
}
 
开发者ID:BlueBrain,项目名称:bluima,代码行数:17,代码来源:WordnetAnnotator.java

示例3: WordNet

import edu.mit.jwi.morph.WordnetStemmer; //导入依赖的package包/类
public WordNet()
   throws IOException
{
   dictionary = new Dictionary(new File("dict"));
   dictionary.open();
   stemmer = new WordnetStemmer(dictionary);
}
 
开发者ID:anadrome,项目名称:word-constraints,代码行数:8,代码来源:WordNet.java

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: WordNet

import edu.mit.jwi.morph.WordnetStemmer; //导入依赖的package包/类
public WordNet() throws Exception {
	url = new URL("file", null, wordNetDir);
	dict = new RAMDictionary(url, ILoadPolicy.NO_LOAD);
	dict.open();
	System.out.println("Loading wordNet...");
	dict.load(true); // load dictionary into memory
	System.out.println("WordNet loaded.");
	
	stemmer = new WordnetStemmer(dict);
}
 
开发者ID:DukeNLIDB,项目名称:NLIDB,代码行数:11,代码来源:WordNet.java

示例9: 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

示例10: WordNetUtil

import edu.mit.jwi.morph.WordnetStemmer; //导入依赖的package包/类
/**
 * 
 * 
 * @param wordNetDir          A directory with WordNet files.
 * @param bUseLexFileName     Do we want to use lexical file numbers in sense representations?
 * @throws IOException
 */
public WordNetUtil(String wordNetDir, boolean bUseLexFileName) throws IOException {
  mUseLexFileName = bUseLexFileName;
  mDict = new RAMDictionary (new File(wordNetDir), ILoadPolicy.NO_LOAD
      //ILoadPolicy.BACKGROUND_LOAD /* all load options fails due to NullPointerException! */
      );
  
  mDict.open();
  mStemmer = new WordnetStemmer(mDict);
}
 
开发者ID:oaqa,项目名称:knn4qa,代码行数:17,代码来源:WordNetUtil.java

示例11: init

import edu.mit.jwi.morph.WordnetStemmer; //导入依赖的package包/类
public static void init(String wordNetPath) throws IOException{
	URL url = new URL ( "file" , null , wordNetPath ) ;
	dict = new Dictionary ( url ) ;		
	dict . open () ;
	wnst = new WordnetStemmer(dict);
	tokenToElements = new HashMap<Token,List<Element>>();
	wordToToken = new HashMap<String,List<Token>>();
	elements = new ArrayList<Element>();
	for(Element e : wh)
		elements.add(e);
	
}
 
开发者ID:everling,项目名称:PRECISE,代码行数:13,代码来源:Lexicon.java

示例12: SemanticDistanceEvaluator

import edu.mit.jwi.morph.WordnetStemmer; //导入依赖的package包/类
public SemanticDistanceEvaluator(String first, String second, SM_Engine similarityComparationEngine, SMconf similarityMeasureConfiguration, IndexerWordNetBasic wordnetNounIndexer, IndexerWordNetBasic wordnetVerbIndexer, MaxentTagger maxentTagger, WordnetStemmer wordnetStemmer){
	this.first = first; 
	this.second = second; 
	this.similarityComparationEngine = similarityComparationEngine; 
	this.similarityMeasureConfiguration = similarityMeasureConfiguration; 
	this.wordnetNounIndexer = wordnetNounIndexer; 
	this.wordnetVerbIndexer = wordnetVerbIndexer;
	this.maxentTagger = maxentTagger; 
	this.wordnetStemmer = wordnetStemmer; 
}
 
开发者ID:MDEGroup,项目名称:EMFCompare-Semantic-Extension,代码行数:11,代码来源:SemanticDistanceEvaluator.java

示例13: SemanticDistanceFunction

import edu.mit.jwi.morph.WordnetStemmer; //导入依赖的package包/类
public SemanticDistanceFunction(SM_Engine similarityComparationEngine, SMconf similarityMeasureConfiguration, IndexerWordNetBasic wordnetNounIndexer, IndexerWordNetBasic wordnetVerbIndexer, MaxentTagger maxentTagger, WordnetStemmer wordnetStemmer, IDictionary wordnetDictionary){
	this.similarityComparationEngine = similarityComparationEngine; 
	this.similarityMeasureConfiguration = similarityMeasureConfiguration; 
	this.wordnetNounIndexer = wordnetNounIndexer; 
	this.wordnetVerbIndexer = wordnetVerbIndexer; 
	this.maxentTagger = maxentTagger;
	this.wordnetStemmer = wordnetStemmer; 
	this.wordnetDictionary = wordnetDictionary; 
}
 
开发者ID:MDEGroup,项目名称:EMFCompare-Semantic-Extension,代码行数:10,代码来源:SemanticDistanceFunction.java

示例14: SemanticDistanceEvaluator

import edu.mit.jwi.morph.WordnetStemmer; //导入依赖的package包/类
public SemanticDistanceEvaluator(String first, String second, SM_Engine similarityComparationEngine, SMconf similarityMeasureConfiguration, IndexerWordNetBasic wordnetNounIndexer, IndexerWordNetBasic wordnetVerbIndexer, MaxentTagger maxentTagger, WordnetStemmer wordnetStemmer){
	this.first = first; 
	this.second = second; 
	this.similarityComparationEngine = similarityComparationEngine; 
	this.similarityMeasureConfiguration = similarityMeasureConfiguration; 
	this.wordnetNounIndexer = wordnetNounIndexer; 
	this.wordnetVerbIndexer = wordnetVerbIndexer; 
	this.maxentTagger = maxentTagger; 
	this.wordnetStemmer = wordnetStemmer; 
}
 
开发者ID:MDEGroup,项目名称:EMFCompare-Semantic-Extension,代码行数:11,代码来源:SemanticDistanceEvaluator.java

示例15: SemanticDistanceFunction

import edu.mit.jwi.morph.WordnetStemmer; //导入依赖的package包/类
public SemanticDistanceFunction(SM_Engine similarityComparationEngine, SMconf similarityMeasureConfiguration, IndexerWordNetBasic wordnetNounIndexer, IndexerWordNetBasic wordnetVerbIndexer, MaxentTagger maxentTagger, WordnetStemmer wordnetStemmer, IDictionary wordnetDictionary){
	this.similarityComparationEngine = similarityComparationEngine; 
	this.similarityMeasureConfiguration = similarityMeasureConfiguration; 
	this.wordnetNounIndexer = wordnetNounIndexer; 
	this.wordnetVerbIndexer = wordnetVerbIndexer; 
	this.maxentTagger = maxentTagger; 
	this.wordnetStemmer = wordnetStemmer; 
	this.wordnetDictionary = wordnetDictionary; 
}
 
开发者ID:MDEGroup,项目名称:EMFCompare-Semantic-Extension,代码行数:10,代码来源:SemanticDistanceFunction.java


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