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


Java Word.getLemma方法代码示例

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


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

示例1: getInfinitiveForm

import net.sf.extjwnl.data.Word; //导入方法依赖的package包/类
/**
* Returns the infinitive form for a given word.
* 
* @param word the word
* @return the infinitive form
*/
  public String getInfinitiveForm(String word) {
  	//System.out.println("Word: " + word);
      String[] split = word.split(" ");
      String verb = split[0];

      if(verb.endsWith("ed") && split.length == 1) { 
      	// probably past tense
      	
      } else if (verb.endsWith("do")) { // termina com participio
      	
      	// check for past construction that simply need an auxiliary
      	return "ser " + word;
      }

      try {
	IndexWord iw = database.getIndexWord(POS.VERB, word);
	if(iw != null) {
		List<Synset> synsets = iw.getSenses();
		//double min = verb.length();
		String result = verb;
		for (Synset synset : synsets) {
		    for (Word w : synset.getWords()) {
		        if (verb.contains(w.getLemma())) {
		            result = w.getLemma();
		            if (split.length > 1) {
		                for (int k = 1; k < split.length; k++) {
		                    result = result + " " + split[k];
		                }
		            }
		            return result;
		        }
		    }
		}
	}
} catch (JWNLException e) {
	logger.error("WordNet lookup failed.", e);
}
      return word;
  }
 
开发者ID:dice-group,项目名称:RDF2PT,代码行数:46,代码来源:PropertyVerbalizerPortuguese.java

示例2: getInfinitiveForm

import net.sf.extjwnl.data.Word; //导入方法依赖的package包/类
/**
 * Returns the infinitive form for a given word.
 * 
 * @param word
 *            the word
 * @return the infinitive form
 */
public String getInfinitiveForm(String word) {

	String[] split = word.split(" ");
	String verb = split[0];

	if (verb.endsWith("ed") && split.length == 1) {
		// probably past tense

	} else if (verb.endsWith("ed") || verb.endsWith("un") || verb.endsWith("wn") || verb.endsWith("en")) {
		// check for past construction that simply need an auxiliary
		return "be " + word;
	}

	try {
		IndexWord iw = database.getIndexWord(POS.VERB, word);
		if (iw != null) {
			List<Synset> synsets = iw.getSenses();
			double min = verb.length();
			String result = verb;
			for (Synset synset : synsets) {
				for (Word w : synset.getWords()) {
					if (verb.contains(w.getLemma())) {
						result = w.getLemma();
						if (split.length > 1) {
							for (int k = 1; k < split.length; k++) {
								result = result + " " + split[k];
							}
						}
						return result;
					}
				}
			}
		}
	} catch (JWNLException e) {
		logger.error("WordNet lookup failed.", e);
	}
	return word;
}
 
开发者ID:dice-group,项目名称:BENGAL,代码行数:46,代码来源:PropertyVerbalizer.java

示例3: ExtJwnlSensedWord

import net.sf.extjwnl.data.Word; //导入方法依赖的package包/类
/**
 * Ctor with an {@link Word} and a dictionary
 * This Ctor is quicker than the other.
 * @param jwiDictionary 
 * @throws WordNetException 
 */
ExtJwnlSensedWord(Word wordObj, ExtJwnlDictionary extJwnlDictionary) throws WordNetException {
	if (wordObj==null)
		throw new WordNetException("wordObj is null!");
	this.wordObj = wordObj;
	this.synset = new ExtJwnlSynset(extJwnlDictionary, wordObj.getSynset());
	this.word = wordObj.getLemma();
	this.dictionary = extJwnlDictionary;
	this.pos = ExtJwnlUtils.getWordNetPartOfSpeech( wordObj.getPOS());
}
 
开发者ID:hltfbk,项目名称:Excitement-TDMLEDA,代码行数:16,代码来源:ExtJwnlSensedWord.java

示例4: getWords

import net.sf.extjwnl.data.Word; //导入方法依赖的package包/类
public Set<String> getWords() throws WordNetException
{
	if (words == null)
	{
		words = new LinkedHashSet<String>();
		for (Word word : this.realSynset.getWords())
		{
			String lemma = word.getLemma();
			lemma = lemma.replaceAll("_", " ");	// clean
			words.add(lemma);
		}
	}
	return new LinkedHashSet<String>(words);	// return a copy
}
 
开发者ID:hltfbk,项目名称:Excitement-TDMLEDA,代码行数:15,代码来源:ExtJwnlSynset.java

示例5: getRepresentative

import net.sf.extjwnl.data.Word; //导入方法依赖的package包/类
public String getRepresentative(String w, String pos) {
    POS posw;
    if (pos.equals("NN") || pos.equals("NNS") || pos.equals("NNP") || pos.equals("NNPS")) {
        posw = POS.NOUN;
    } else if (pos.equals("VBZ") || pos.equals("VBG") || pos.equals("VBP") || pos.equals("VBN") || pos.equals("VBD") || pos.equals("VB")) {
        posw = POS.VERB;
    } else if (pos.equals("JJ")) {
        posw = POS.ADJECTIVE;
    } else {
        if (pos.startsWith("V") || pos.startsWith("N")) {
            System.out.println("POS discarded: " + pos);
        }
        return "";
    }
    if (!representative.containsKey(w)) {
        IndexWord iw1 = null;
        try {
            iw1 = dictionary.getIndexWord(posw, w);
        } catch (Exception e) {
        }
        String r = null;
        if (iw1 != null) {
            long[] offsets = iw1.getSynsetOffsets();
            if (offsets.length > 0) {
                //try only the first meaning
                try {
                    Synset synset = dictionary.getSynsetAt(posw, offsets[0]);
                    for (Word word : synset.getWords()) {
                        String lemma = word.getLemma();
                        if (representative.containsKey(lemma)) {
                            r = lemma;
                            break;
                        }
                    }
                } catch (JWNLException ex) {
                    Logger.getLogger(RepresentativeProvider.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
        if (r != null) {
            representative.put(w, representative.get(r));
        } else {
            representative.put(w, w);
        }
        newEntries++;
    }
    if (newEntries == UPDATE_FREQUENCY) {
        saveRepresentatives();
        newEntries = 0;
    }
    return representative.get(w);
}
 
开发者ID:UCLA-BD2K,项目名称:aztec-text-analysis-tools,代码行数:53,代码来源:RepresentativeProvider.java


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