edu.mit.jwi.morph.WordnetStemmer.findStems()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(79)

本文整理了Java中edu.mit.jwi.morph.WordnetStemmer.findStems()方法的一些代码示例,展示了WordnetStemmer.findStems()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WordnetStemmer.findStems()方法的具体详情如下:
包路径:edu.mit.jwi.morph.WordnetStemmer
类名称:WordnetStemmer
方法名:findStems

WordnetStemmer.findStems介绍

暂无

代码示例

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-wnsim

public void getStems(String word) {
  List<String> stems = wstem.findStems(word,null);
  for(String s: stems){
    System.out.println(s);
  }
}

代码示例来源:origin: CogComp/cogcomp-nlp

public void getStems(String word) {
  List<String> stems = wstem.findStems(word, null);
  for (String s : stems) {
    System.out.println(s);
  }
}

代码示例来源:origin: CogComp/cogcomp-nlp

/**
   * Implements getLemma method
   */
  public String getLemma(String word, String pos) {
    List<String> lis = stemmer.findStems(word, convertPOS(pos));
    if (lis.size() == 0) {
      return word;
    } else {
      return lis.get(0);
    }
  }
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-lemmatizer

/**
   * Implements getLemma method
   */
  public String getLemma(String word, String pos) {
    List<String> lis = stemmer.findStems(word, convertPOS(pos));
    if (lis.size() == 0) {
      return word;
    } else {
      return lis.get(0);
    }
  }
}

代码示例来源:origin: oaqa/knn4qa

public HashSet<String> getRelatedWords(String origStr, 
                    POS pos,
                    IPointer type) {
 HashSet<String>   seen = new HashSet<String>();

 for (String lemma: mStemmer.findStems(origStr, pos)) {    
  IIndexWord        idxWord = mDict.getIndexWord(lemma, pos);
 
  if (idxWord == null) continue; // For some reason this happens sometimes
  
  seen.addAll(getRelated(idxWord, type));
 }
 
 return seen;
}

代码示例来源:origin: apache/ctakes

/**
 * 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;
}

代码示例来源:origin: org.apache.ctakes/ctakes-relation-extractor

/**
 * 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;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-wnsim

public ArrayList<String> getStemsList(String word, POS pos) { //experimental change!!!!!!!!!!!!!!!!!!!!!!!
  List<String> stems = new ArrayList<String>();
  if(pos!=null) {
    List<String> stems1 = wstem.findStems(word, pos);
    stems=fix(stems1, word.substring(0,1), word);
  }
  else {
    for (POS p : POS.values()) {
      try {
        List<String> stems1=wstem.findStems(word, p);
        stems.addAll(fix(stems1, word.substring(0,1), word));
      }
      catch(Exception e) {}
    }
  }
  stems = new ArrayList<String>((new HashSet<String>(stems)));
  if(stems.size() == 0) {
    stems.add(word);
    return (ArrayList<String>) stems;
  }
  //System.out.println(Arrays.toString(stems.toArray(new String[0]))+" "+word);
  return (ArrayList<String>) stems;
}

代码示例来源:origin: CogComp/cogcomp-nlp

public ArrayList<String> getStemsList(String word, POS pos) { // experimental
                                // change!!!!!!!!!!!!!!!!!!!!!!!
  List<String> stems = new ArrayList<String>();
  if (pos != null) {
    List<String> stems1 = wstem.findStems(word, pos);
    stems = fix(stems1, word.substring(0, 1), word);
  } else {
    for (POS p : POS.values()) {
      try {
        List<String> stems1 = wstem.findStems(word, p);
        stems.addAll(fix(stems1, word.substring(0, 1), word));
      } catch (Exception e) {
      }
    }
  }
  stems = new ArrayList<String>((new HashSet<String>(stems)));
  if (stems.size() == 0) {
    stems.add(word);
    return (ArrayList<String>) stems;
  }
  // System.out.println(Arrays.toString(stems.toArray(new String[0]))+"
  // "+word);
  return (ArrayList<String>) stems;
}

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-wnsim

public void getSynsetId(String word) {
  List<String> stems = wstem.findStems(word, null);
  if(stems.size() > 0)
    word = stems.get(0);
  IIndexWord idxWord = dict.getIndexWord(word, POS.NOUN) ;
  IWordID wordID = idxWord.getWordIDs().get(0); // 1 st meaning
  IWord iword = dict . getWord (wordID);
  ISynset synset = iword.getSynset();
  System.out.println(synset.getID());
}

代码示例来源:origin: CogComp/cogcomp-nlp

public void getSynsetId(String word) {
  List<String> stems = wstem.findStems(word, null);
  if (stems.size() > 0)
    word = stems.get(0);
  IIndexWord idxWord = dict.getIndexWord(word, POS.NOUN);
  IWordID wordID = idxWord.getWordIDs().get(0); // 1 st meaning
  IWord iword = dict.getWord(wordID);
  ISynset synset = iword.getSynset();
  System.out.println(synset.getID());
}

代码示例来源:origin: oaqa/knn4qa

for (String lemma: mStemmer.findStems(origStr, pos)) {    
 IIndexWord        idxWord = mDict.getIndexWord(lemma, pos);

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-wnsim

public void getAllSemanticRelations(String lemma) {
  //for each stem, for each sense in stemn\,print lemma, sensem, probability, sr and lr
  List<String> stems = wstem.findStems(lemma, null);
  for(String s: stems){
    for (POS pos : POS.values()) {
      IIndexWord idxWord = dict.getIndexWord(lemma, pos) ;
      if(idxWord==null)
        continue;
      List<IWordID> senses = idxWord.getWordIDs(); // 1 st meaning
      for(IWordID iw : senses) {
        ISynset is = dict.getSynset(iw.getSynsetID());
        System.out.println(is.getGloss());
        getAllSemanticRelations(is);
      }
    }
  }
}

代码示例来源:origin: CogComp/cogcomp-nlp

public void getAllSemanticRelations(String lemma) {
  // for each stem, for each sense in stemn\,print lemma, sensem,
  // probability, sr and lr
  List<String> stems = wstem.findStems(lemma, null);
  for (String s : stems) {
    for (POS pos : POS.values()) {
      IIndexWord idxWord = dict.getIndexWord(lemma, pos);
      if (idxWord == null)
        continue;
      List<IWordID> senses = idxWord.getWordIDs(); // 1 st meaning
      for (IWordID iw : senses) {
        ISynset is = dict.getSynset(iw.getSynsetID());
        System.out.println(is.getGloss());
        getAllSemanticRelations(is);
      }
    }
  }
}

代码示例来源:origin: oaqa/knn4qa

String res = "";
for (String lemma: mStemmer.findStems(origStr, pos)) {    
 IIndexWord        idxWord = mDict.getIndexWord(lemma, pos);

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-wnsim

public void getAllLexicalRelations(String lemma) {
  //for each stem, for each sense in stemn\,print lemma, sensem, probability, sr and lr
  List<String> stems = wstem.findStems(lemma, null);
  for(String s: stems){
    for (POS pos : POS.values()) {
      IIndexWord idxWord = dict.getIndexWord(lemma, pos) ;
      if(idxWord==null)
        continue;
      List<IWordID> senses = idxWord.getWordIDs(); // 1 st meaning
      for(IWordID iw : senses) {
        ISynset is = dict.getSynset(iw.getSynsetID());
        System.out.println(is.getGloss());
        getAllLexicalRelations(dict.getWord(iw));
      }
    }
  }
}

代码示例来源:origin: CogComp/cogcomp-nlp

public void getAllLexicalRelations(String lemma) {
  // for each stem, for each sense in stemn\,print lemma, sensem,
  // probability, sr and lr
  List<String> stems = wstem.findStems(lemma, null);
  for (String s : stems) {
    for (POS pos : POS.values()) {
      IIndexWord idxWord = dict.getIndexWord(lemma, pos);
      if (idxWord == null)
        continue;
      List<IWordID> senses = idxWord.getWordIDs(); // 1 st meaning
      for (IWordID iw : senses) {
        ISynset is = dict.getSynset(iw.getSynsetID());
        System.out.println(is.getGloss());
        getAllLexicalRelations(dict.getWord(iw));
      }
    }
  }
}

代码示例来源:origin: ch.epfl.bbp.nlp/bluima_commons

&& POS.getPartOfSpeech(t.getPos().charAt(0)) != null) {
POS pos = POS.getPartOfSpeech(t.getPos().charAt(0));
List<String> stems = stemmer.findStems(t.getCoveredText(),
    pos);
if (!stems.isEmpty()) {
  List<String> stems = stemmer.findStems(
      t.getCoveredText(), pos);
  if (!stems.isEmpty()) {

相关文章