本文整理汇总了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();
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}