• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Dictionary类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: WordNetAPI

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
private WordNetAPI(String propsFile) throws Exception {

		info("Initialize WordNet...: ");
		
		if (propsFile == null)
			throw new RuntimeException("Missing required property 'WN_PROP'");

		try {
			JWNL.initialize(new FileInputStream(propsFile));
			wDict = Dictionary.getInstance();
			pUtils = PointerUtils.getInstance();
			morphProcessor = wDict.getMorphologicalProcessor();
		} catch (Exception e) {
			throw new RuntimeException("Initialization failed", e);
		}
		info("Done initializing WordNet...");
	}
 
开发者ID:Noahs-ARK,项目名称:semafor-semantic-parser,代码行数:18,代码来源:WordNetAPI.java


示例2: stringTypes

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
/**
 * Lookup the word in WordNet
 * @returns Array of three strings: word, lemma, synset
 */
public static String[] stringTypes(String str) {
  try {
    String[] types = new String[3];
    String[] parts = str.split("\\s+");
    IndexWord iword = Dictionary.getInstance().lookupIndexWord(POS.VERB, parts[parts.length-1]);
    if( iword == null ) 
      iword = Dictionary.getInstance().lookupIndexWord(POS.NOUN, parts[parts.length-1]);
    if( iword == null ) {
      types[1] = parts[parts.length-1];
      types[2] = "-1";
    }
    else {
      String lemma = iword.getLemma();
      if( lemma.indexOf(' ') != -1 ) // Sometimes it returns a two word phrase
        lemma = lemma.trim().replace(' ','-');
      types[1] = lemma;
      types[2] = Long.toString(iword.getSense(1).getOffset());
    }
    types[0] = parts[parts.length-1];
    return types;
  } catch( Exception ex ) { ex.printStackTrace(); return null; }
}
 
开发者ID:nchambers,项目名称:probschemas,代码行数:27,代码来源:WordNet.java


示例3: isVerb

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
/**
 * @param word A Word
 * @return True if the word can be a verb according to WordNet
 */
private boolean isVerb(String word) {
  // save time with a table lookup
  if( wordToVerb.containsKey(word) )
    return wordToVerb.get(word);

  try {
    IndexWord iword = Dictionary.getInstance().lookupIndexWord(POS.VERB, word);

    if( iword == null ) {
      wordToVerb.put(word, false);
      return false;
    }
    else {
      wordToVerb.put(word, true);
      return true;
    }
  } catch( Exception ex ) { ex.printStackTrace(); }

  return false;
}
 
开发者ID:nchambers,项目名称:schemas,代码行数:25,代码来源:BasicEventAnalyzer.java


示例4: getDictionary

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
private static Dictionary getDictionary() {
    synchronized (WordNet.class) {
        if (dictionary == null) {
            JWNL.shutdown(); // in case it was previously initialized
            try {
                final String properties = Resources.toString(
                        WordNet.class.getResource("jwnl.xml"), Charsets.UTF_8).replace(
                        "DICTIONARY_PATH_PLACEHOLDER", dictionaryPath);
                final InputStream stream = new ByteArrayInputStream(
                        properties.getBytes(Charsets.UTF_8));
                JWNL.initialize(stream);
                dictionary = Dictionary.getInstance();
            } catch (final Throwable ex) {
                JWNL.shutdown();
                throw new Error("Cannot initialize JWNL using dictionary path '"
                        + dictionaryPath + "'", ex);
            }
        }
        return dictionary;
    }
}
 
开发者ID:dkmfbk,项目名称:pikes,代码行数:22,代码来源:WordNet.java


示例5: wordExistInEnglish

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
public static boolean wordExistInEnglish(String word)
{
	try{
	IndexWord fword = null; 
	Dictionary dict = Dictionary.getInstance();
	fword = dict.lookupIndexWord(POS.NOUN, word);
	if(fword!=null)
		return true;
	fword = dict.lookupIndexWord(POS.ADJECTIVE, word);
	if(fword!=null)
		return true;
	fword = dict.lookupIndexWord(POS.ADVERB, word);
	if(fword!=null)
		return true;
	fword = dict.lookupIndexWord(POS.VERB, word);
	if(fword!=null)
		return true;
	}
	catch(Exception ex)
	{
		return false;
	}
	return false;
}
 
开发者ID:nikolamilosevic86,项目名称:TableDisentangler,代码行数:25,代码来源:ConceptizationStats.java


示例6: testGetWordSenses

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
/**
 * Pulls a noun "tank" from the dictionary and checks to see if it has 5 senses.
 *
 */
public void testGetWordSenses() {
    try {
        JWNL.initialize(TestDefaults.getInputStream());
        IndexWord word = Dictionary.getInstance().getIndexWord(POS.NOUN, "tank");
  
        assertTrue(word.getSenseCount() == 5); 
        
        word = Dictionary.getInstance().getIndexWord(POS.VERB, "eat");
        assertTrue(word.getSenseCount() == 6); 
        
        word = Dictionary.getInstance().getIndexWord(POS.ADJECTIVE, "quick");
        assertTrue(word.getSenseCount() == 6); 
        
        word = Dictionary.getInstance().getIndexWord(POS.ADJECTIVE, "big");
        assertTrue(word.getSenseCount() == 13); 
        
    } catch(JWNLException e) {
        fail("Exception in testGetSenses caught");
        e.printStackTrace();
    } 
}
 
开发者ID:duguyue100,项目名称:chomsky,代码行数:26,代码来源:Wordnet30SynsetTest.java


示例7: VerbImpl

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
public VerbImpl(Word _word,
                Synset _synset,
                int _senseNumber,
                int _orderInSynset,
                boolean _isSemcor,
                net.didion.jwnl.data.Verb _jwVerb,
                Dictionary _wnDict) {

  super(_word,_synset,_senseNumber,_orderInSynset,_isSemcor, _wnDict);

  Assert.assertNotNull(_jwVerb);

  String[] jwFrames = _jwVerb.getVerbFrames();
  this.verbFrames = new ArrayList(jwFrames.length);

  for (int i= 0; i< jwFrames.length; i++) {
    this.verbFrames.add(new VerbFrameImpl(jwFrames[i]));
  }
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:20,代码来源:VerbImpl.java


示例8: WordSenseImpl

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
public WordSenseImpl(Word _word,
                    Synset _synset,
                    int _senseNumber,
                    int _orderInSynset,
                    boolean _isSemcor,
                    Dictionary _wnDict) {

  //0.
  Assert.assertNotNull(_word);
  Assert.assertNotNull(_synset);
  Assert.assertNotNull(_wnDict);

  this.word = _word;
  this.synset = _synset;
  this.senseNumber = _senseNumber;
  this.orderInSynset = _orderInSynset;
  this.isSemcor = _isSemcor;
  this.wnDictionary = _wnDict;
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:20,代码来源:WordSenseImpl.java


示例9: init

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
/** Initialise this resource, and return it. */
public Resource init() throws ResourceInstantiationException {

  if (null == this.propertyUrl) {
    throw new ResourceInstantiationException("property file not set");
  }

  try {

    InputStream inProps = this.propertyUrl.openStream();

    JWNL.initialize(inProps);
    this.wnDictionary = Dictionary.getInstance();
    Assert.assertNotNull(this.wnDictionary);
  }
  catch(Exception e) {
    throw new ResourceInstantiationException(e);
  }

  return this;
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:22,代码来源:JWNLWordNetImpl.java


示例10: unload

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
@Override
public void unload() {

	this.mCache.clear();

	if (mDictionary != null)
		mDictionary.close();

	if (mInit) {
		Dictionary.uninstall();
		JWNL.shutdown();
	}
}
 
开发者ID:SI3P,项目名称:supWSD,代码行数:14,代码来源:JWNLLemmatizer.java


示例11: unload

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
@Override
public void unload() {

	if(mDictionary!=null)
	mDictionary.close();
	
	if(mInit){
		Dictionary.uninstall();
		JWNL.shutdown();
	}
}
 
开发者ID:SI3P,项目名称:supWSD,代码行数:12,代码来源:SensEvalMNS.java


示例12: Examples

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
public Examples() throws JWNLException {
	ACCOMPLISH = Dictionary.getInstance().getIndexWord(POS.VERB, "accomplish");
	DOG = Dictionary.getInstance().getIndexWord(POS.NOUN, "dog");
	CAT = Dictionary.getInstance().lookupIndexWord(POS.NOUN, "cat");
	FUNNY = Dictionary.getInstance().lookupIndexWord(POS.ADJECTIVE, "funny");
	DROLL = Dictionary.getInstance().lookupIndexWord(POS.ADJECTIVE, "droll");
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:8,代码来源:Examples.java


示例13: demonstrateMorphologicalAnalysis

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
private void demonstrateMorphologicalAnalysis(String phrase) throws JWNLException {
	// "running-away" is kind of a hard case because it involves
	// two words that are joined by a hyphen, and one of the words
	// is not stemmed. So we have to both remove the hyphen and stem
	// "running" before we get to an entry that is in WordNet
	System.out.println("Base form for \"" + phrase + "\": " +
	                   Dictionary.getInstance().lookupIndexWord(POS.VERB, phrase));
}
 
开发者ID:kostagiolasn,项目名称:NucleosomePatternClassifier,代码行数:9,代码来源:Examples.java


示例14: verbToLemma

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
/**
 * @param word A word
 * @return The lemma of the word if it is a verb, null otherwise
 */
public String verbToLemma(String word) {
  if( _verbToLemma == null ) _verbToLemma = new HashMap<String, String>();

  // save time with a table lookup
  if( _verbToLemma.containsKey(word) ) return _verbToLemma.get(word);

  try {
    // don't return lemmas for hyphenated words
    if( word.indexOf('-') > -1 || word.indexOf('/') > -1 ) {
      _verbToLemma.put(word, null);
      return null;	
    }

    // get the lemma
    IndexWord iword = Dictionary.getInstance().lookupIndexWord(POS.VERB, word);
    if( iword == null ) {
      _verbToLemma.put(word, null);
      return null;
    }
    else {
      String lemma = iword.getLemma();
      if( lemma.indexOf(' ') != -1 ) // Sometimes it returns a two word phrase
        lemma = lemma.trim().replace(' ','_');

      _verbToLemma.put(word, lemma);
      return lemma;
    }
  } catch( Exception ex ) { ex.printStackTrace(); }

  return null;
}
 
开发者ID:nchambers,项目名称:probschemas,代码行数:36,代码来源:WordNet.java


示例15: adjectiveToLemma

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
/**
 * @param word A word
 * @return The lemma of the word if it is an adjective, null otherwise
 */
public String adjectiveToLemma(String word) {
  if( _adjToLemma == null ) _adjToLemma = new HashMap<String, String>();

  // save time with a table lookup
  if( _adjToLemma.containsKey(word) ) return _adjToLemma.get(word);

  try {
    // don't return lemmas for hyphenated words
    if( word.indexOf('-') > -1 || word.indexOf('/') > -1 ) {
      _adjToLemma.put(word, null);
      return null;	
    }

    // get the lemma
    IndexWord iword = Dictionary.getInstance().lookupIndexWord(POS.ADJECTIVE, word);
    if( iword == null ) {
      _adjToLemma.put(word, null);
      return null;
    }
    else {
      String lemma = iword.getLemma();
      if( lemma.indexOf(' ') != -1 ) // Sometimes it returns a two word phrase
        lemma = lemma.trim().replace(' ','_');

      _adjToLemma.put(word, lemma);
      return lemma;
    }
  } catch( Exception ex ) { ex.printStackTrace(); }

  return null;
}
 
开发者ID:nchambers,项目名称:probschemas,代码行数:36,代码来源:WordNet.java


示例16: synsetsOf

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
/**
 * @return All synsets for the given word and POS category.
 */
public Synset[] synsetsOf(String token, POS postag) {
  try {
    IndexWord iword = Dictionary.getInstance().lookupIndexWord(postag, token);
    if( iword != null ) {
      Synset[] synsets = iword.getSenses();
      return synsets;
    }
  } catch( Exception ex ) { ex.printStackTrace(); }
  return null;
}
 
开发者ID:nchambers,项目名称:probschemas,代码行数:14,代码来源:WordNet.java


示例17: Wordnet

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
public Wordnet() {
	String propsFile = "file_properties.xml";
	try {
		JWNL.initialize(new FileInputStream(propsFile));
		dict = Dictionary.getInstance();
	} catch (Exception ex) {
		ex.printStackTrace();
	}
}
 
开发者ID:nikolamilosevic86,项目名称:Marvin,代码行数:10,代码来源:Wordnet.java


示例18: wordToLemma

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
/**
 * @param word A word
 * @return The lemma of the word if it is a verb, null otherwise
 */
public String wordToLemma(String word, POS type, Map<String,String> cache) {
  //    System.out.println("wordToLemma " + word + " - " + type);
  // save time with a table lookup
  if( cache.containsKey(word) ) return cache.get(word);

  try {
    // don't return lemmas for hyphenated words
    if( word.indexOf('-') > -1 || word.indexOf('/') > -1 ) {
      cache.put(word, null);
      return null;	
    }

    // get the lemma
    IndexWord iword = Dictionary.getInstance().lookupIndexWord(type, word);
    if( iword == null ) {
      cache.put(word, null);
      return null;
    }
    else {
      String lemma = iword.getLemma();
      if( lemma.indexOf(' ') != -1 ) // Sometimes it returns a two word phrase
        lemma = lemma.trim().replace(' ','_');

      cache.put(word, lemma);
      return lemma;
    }
  } catch( Exception ex ) { ex.printStackTrace(); }

  return null;
}
 
开发者ID:nchambers,项目名称:schemas,代码行数:35,代码来源:BasicEventAnalyzer.java


示例19: getAnswerType

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
public static String getAnswerType(Term focusTerm){
    if (focusTerm == null) {
        return null;
    }
    String focusText = focusTerm.getText();
    List<AnswerType> focusTypes = new ArrayList<AnswerType>();

    try {
        IndexWord indexWord = Dictionary.getInstance().lookupIndexWord(POS.NOUN, focusText);
        if (indexWord == null) throw new Exception("Failed to get index word");
        Synset[] senses = indexWord.getSenses();
        if (senses == null) throw new Exception("Failed to get synsets");
        
        for (Synset sense : senses) {
            AnswerType type = findWnMapMatch(sense,0);
            if (type != null) {
                focusTypes.add(type);
            }
        }
    } catch (Exception e) {
        log.warn("Failed to get hypernyms for noun '"+focusText+"'");
    }
    
    if (focusTypes.size() == 0) return focusText.toLowerCase().replaceAll(" ","_");
    Collections.sort(focusTypes,atypeComparator);
    return focusTypes.get(0).getType();            
}
 
开发者ID:claritylab,项目名称:lucida,代码行数:28,代码来源:WordNetAnswerTypeMapping.java


示例20: execute

import net.didion.jwnl.dictionary.Dictionary; //导入依赖的package包/类
public boolean execute(POS pos, String lemma, BaseFormSet baseForms) throws JWNLException {
	if (Dictionary.getInstance().getIndexWord(pos, lemma) != null) {
		baseForms.add(lemma);
		return true;
	}
	return false;
}
 
开发者ID:duguyue100,项目名称:chomsky,代码行数:8,代码来源:LookupIndexWordOperation.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Task类代码示例发布时间:2022-05-21
下一篇:
Java IPerspectiveAwareModel类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap