本文整理了Java中net.didion.jwnl.data.Word.getLemma()
方法的一些代码示例,展示了Word.getLemma()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Word.getLemma()
方法的具体详情如下:
包路径:net.didion.jwnl.data.Word
类名称:Word
方法名:getLemma
暂无
代码示例来源:origin: hltfbk/Excitement-Open-Platform
/**
* @param words
* @param wordToLookup
* @return
*/
private Word lookupWordInWords(Word[] words, String wordToLookup) {
boolean found = false;
Word someWord = null;
for (int i = 0; i < words.length && !found; i++)
{
someWord = words[i];
found = someWord.getLemma().equalsIgnoreCase(wordToLookup);
}
return someWord;
}
}
代码示例来源:origin: CogComp/cogcomp-nlp
private void addSynonymFeature(Set<String> f1, Synset synset, WordNetFeatureClass name,
String key) {
if (featureClasses.contains(name)) {
for (Word w : synset.getWords())
f1.add(key + w.getLemma());
}
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison
private void addSynonymFeature(Set<String> f1, Synset synset, WordNetFeatureClass name,
String key) {
if (featureClasses.contains(name)) {
for (Word w : synset.getWords())
f1.add(key + w.getLemma());
}
}
代码示例来源:origin: hltfbk/Excitement-Open-Platform
public Set<String> getWords() throws WordNetException
{
if (words == null)
{
words = new HashSet<String>();
for (Word word : this.realSynset.getWords())
{
String lemma = word.getLemma();
lemma = lemma.replaceAll("_", " "); // clean
words.add(lemma);
}
}
return new HashSet<String>(words); // return a copy
}
代码示例来源:origin: eu.fbk.pikes/pikes-resources
public static Set<String> getLemmas(final String synsetID) {
final Set<String> lemmas = Sets.newLinkedHashSet();
final Synset synset = getSynset(synsetID);
if (synset != null) {
for (final Word word : synset.getWords()) {
lemmas.add(word.getLemma());
}
}
return lemmas;
}
代码示例来源:origin: net.sf.jwordnet/jwnl
/** Returns true if <code>lemma</code> is one of the words contained in this synset.*/
public boolean containsWord(String lemma) {
for (int i = 0; i < getWordsSize(); i++) {
if (getWord(i).getLemma().equals(lemma))
return true;
}
return false;
}
代码示例来源:origin: hltfbk/Excitement-Open-Platform
public long getUsageOf(String word) throws WordNetException
{
long ret = 0;
Word[] wordsOfSynset = this.realSynset.getWords();
for (Word wordOfSynset : wordsOfSynset)
{
if (wordOfSynset.getLemma().equals(word))
{
ret = wordOfSynset.getUsageCount();
}
}
return ret;
}
代码示例来源:origin: CogComp/cogcomp-nlp
private void addRelatedWordsFeatures(Set<String> f1, Synset synset, PointerType type,
WordNetFeatureClass name, String key) throws JWNLException {
if (featureClasses.contains(name)) {
Pointer[] pointers = synset.getPointers(type);
for (Pointer p : pointers) {
Synset target = p.getTargetSynset();
for (Word w : target.getWords()) {
f1.add(key + w.getLemma());
}
}
}
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison
private void addRelatedWordsFeatures(Set<String> f1, Synset synset, PointerType type,
WordNetFeatureClass name, String key) throws JWNLException {
if (featureClasses.contains(name)) {
Pointer[] pointers = synset.getPointers(type);
for (Pointer p : pointers) {
Synset target = p.getTargetSynset();
for (Word w : target.getWords()) {
f1.add(key + w.getLemma());
}
}
}
}
代码示例来源:origin: CogComp/cogcomp-nlp
public synchronized List<String> getSynonyms(String word, POS pos, boolean firstOnly)
throws JWNLException {
List<String> syns = new ArrayList<>();
IndexWord indexWord = getIndexWord(pos, word);
if (indexWord == null)
return syns;
for (Synset synset : indexWord.getSenses()) {
for (Word w : synset.getWords()) {
syns.add(w.getLemma());
}
if (firstOnly)
break;
}
return syns;
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison
public synchronized List<String> getSynonyms(String word, POS pos, boolean firstOnly)
throws JWNLException {
List<String> syns = new ArrayList<>();
IndexWord indexWord = getIndexWord(pos, word);
if (indexWord == null)
return syns;
for (Synset synset : indexWord.getSenses()) {
for (Word w : synset.getWords()) {
syns.add(w.getLemma());
}
if (firstOnly)
break;
}
return syns;
}
代码示例来源:origin: SmartDataAnalytics/DL-Learner
public List<String> getAttributes(String s) {
List<String> result = new ArrayList<>();
try {
IndexWord iw = dict.getIndexWord(POS.ADJECTIVE, s);
if (iw != null) {
Synset[] synsets = iw.getSenses();
Word[] words = synsets[0].getWords();
for (Word w : words) {
String c = w.getLemma();
if (!c.equals(s) && !c.contains(" ") && result.size() < 4) {
result.add(c);
}
}
}
}
catch (JWNLException e) {
e.printStackTrace();
}
return result;
}
代码示例来源:origin: net.sf.jwordnet/jwnl
public String toString() {
if (_cachedToString == null) {
StringBuffer words = new StringBuffer();
for (int i = 0; i < getWordsSize(); ++i) {
if (i > 0) words.append(", ");
words.append(getWord(i).getLemma());
}
if (getGloss() != null)
words.append(" -- (" + getGloss() + ")");
_cachedToString =
JWNL.resolveMessage("DATA_TOSTRING_009", new Object[]{new Long(getOffset()), getPOS(), words.toString()});
}
return _cachedToString;
}
代码示例来源:origin: net.sf.jwordnet/jwnl
public String toString() {
if (_cachedToString == null) {
Object[] params = new Object[]{getPOS(), getLemma(), getSynset(), new Integer(getIndex())};
_cachedToString = JWNL.resolveMessage("DATA_TOSTRING_005", params);
}
return _cachedToString;
}
代码示例来源:origin: CogComp/cogcomp-nlp
public synchronized List<String> getRelatedWords(String word, POS pos, PointerType type,
boolean firstOnly) throws JWNLException {
List<String> syns = new ArrayList<>();
IndexWord indexWord = getIndexWord(pos, word);
if (indexWord == null)
return syns;
for (Synset synset : indexWord.getSenses()) {
Pointer[] pointers = synset.getPointers(type);
for (Pointer p : pointers) {
Synset target = p.getTargetSynset();
for (Word w : target.getWords()) {
syns.add(w.getLemma());
}
}
if (firstOnly)
break;
}
return syns;
}
代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-edison
public synchronized List<String> getRelatedWords(String word, POS pos, PointerType type,
boolean firstOnly) throws JWNLException {
List<String> syns = new ArrayList<>();
IndexWord indexWord = getIndexWord(pos, word);
if (indexWord == null)
return syns;
for (Synset synset : indexWord.getSenses()) {
Pointer[] pointers = synset.getPointers(type);
for (Pointer p : pointers) {
Synset target = p.getTargetSynset();
for (Word w : target.getWords()) {
syns.add(w.getLemma());
}
}
if (firstOnly)
break;
}
return syns;
}
代码示例来源:origin: hltfbk/Excitement-Open-Platform
/**
* Ctor with an {@link Word} and a dictionary
* This Ctor is quicker than the other.
* @param jwiDictionary
* @throws WordNetException
*/
JwnlSensedWord(Word objWord, JwnlDictionary jwnlDictionary) throws WordNetException {
this.wordObj = objWord;
this.synset = new JwnlSynset(jwnlDictionary, objWord.getSynset());
this.word = objWord.getLemma();
this.dictionary = jwnlDictionary;
this.pos = JwnlUtils.getWordNetPartOfSpeech( wordObj.getPOS());
}
代码示例来源:origin: SmartDataAnalytics/DL-Learner
public void getHyponymsRecursive(List<String> lemmas, Synset sense, int depthToGo) {
for (Word w : sense.getWords()) {
lemmas.add(w.getLemma());
}
if (depthToGo == 0) {
return;
}
try {
PointerTargetNodeList directHyponyms = PointerUtils.getInstance().getDirectHyponyms(sense);
for (Object directHyponym : directHyponyms) {
getHyponymsRecursive(lemmas, ((PointerTargetNode) directHyponym).getSynset(), depthToGo - 1);
}
}
catch (JWNLException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
代码示例来源:origin: SmartDataAnalytics/DL-Learner
public void getHyponymsScoredRecursive(List<LemmaScorePair> lemmas, Synset sense, int depthToGo, double score) {
for (Word w : sense.getWords()) {
lemmas.add(new LemmaScorePair(w.getLemma(), score));
}
if (depthToGo == 0) {
return;
}
try {
PointerTargetNodeList directHyponyms = PointerUtils.getInstance().getDirectHyponyms(sense);
for (Object directHyponym : directHyponyms) {
getHyponymsScoredRecursive(lemmas, ((PointerTargetNode) directHyponym).getSynset(), depthToGo - 1,
score * HYPONYM_FACTOR);
}
}
catch (JWNLException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
代码示例来源:origin: stackoverflow.com
IndexWord word = dictionary.lookupIndexWord(POS.NOUN, exampleWord);
List<Synset> synset=word.getSenses();
int nums = word.sortSenses();
// for each sense of the word
for ( Synset syn : synset) {
// get the synonyms of the sense
PointerTargetTree s = PointerUtils.getSynonymTree(syn, 2 /*depth*/);
List<PointerTargetNodeList> l = s.toList();
for (PointerTargetNodeList nl : l) {
for (PointerTargetNode n : nl) {
Synset ns = n.getSynset();
if (ns!=null) {
List<Word> ws = ns.getWords();
for (Word ww : ws) {
// ww.getUseCount() is the frequency of occurance as reported by wordnet engine
println(ww.getLemma(), ww.getUseCount());
}
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!