net.didion.jwnl.dictionary.Dictionary.getInstance()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(174)

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

Dictionary.getInstance介绍

暂无

代码示例

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

protected WordNetManager() throws JWNLException {
  if (wordnet == null) {
    synchronized (WordNetManager.class) {
      if (wordnet == null) {
        JWNL.initialize();
        // Create dictionary object
        wordnet = Dictionary.getInstance();
      }
    }
  }
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

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");
}

代码示例来源:origin: cc.mallet/mallet

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");
}

代码示例来源:origin: com.github.steveash.mallet/mallet

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));
}

代码示例来源:origin: de.julielab/jcore-mallet-0.4

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");
}

代码示例来源:origin: de.julielab/jcore-mallet-0.4

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));
}

代码示例来源:origin: cc.mallet/mallet

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));
}

代码示例来源:origin: net.sf.jwordnet/jwnl

private void loadSynset(int i) throws JWNLException {
  if (_synsets[i] == null) {
    _synsets[i] = Dictionary.getInstance().getSynsetAt(_pos, _synsetOffsets[i]);
  }
}

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

protected WordNetManager() throws JWNLException {
  if (wordnet == null) {
    synchronized (WordNetManager.class) {
      if (wordnet == null) {
        JWNL.initialize();
        // Create dictionary object
        wordnet = Dictionary.getInstance();
      }
    }
  }
}

代码示例来源:origin: de.julielab/jcore-mallet-2.0.9

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));
}

代码示例来源:origin: com.github.steveash.mallet/mallet

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");
}

代码示例来源:origin: SmartDataAnalytics/DL-Learner

public WordNet(String configPath) {
  try {
    JWNL.initialize(this.getClass().getClassLoader().getResourceAsStream(configPath));
    dict = Dictionary.getInstance();
  }
  catch (JWNLException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: SmartDataAnalytics/DL-Learner

public WordNet() {
  try {
    JWNL.initialize(this.getClass().getClassLoader().getResourceAsStream("wordnet_properties.xml"));
    dict = Dictionary.getInstance();
  }
  catch (JWNLException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: net.sf.jwordnet/jwnl

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

代码示例来源:origin: net.sf.jwordnet/jwnl

/** Get the actual target of this pointer. */
public PointerTarget getTarget() throws JWNLException {
  if (_target == null) {
    Dictionary dic = Dictionary.getInstance();
    Synset syn = dic.getSynsetAt(_targetIndex._pos, _targetIndex._offset);
    _target = (_targetIndex._index == 0) ?
      (PointerTarget) syn : (PointerTarget) syn.getWord(_targetIndex._index - 1);
  }
  return _target;
}

代码示例来源:origin: SmartDataAnalytics/DL-Learner

public WordNet(InputStream propertiesStream) {
  try {
    JWNL.initialize(propertiesStream);
    dict = Dictionary.getInstance();
  }
  catch (JWNLException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: net.sf.jwordnet/jwnl

public boolean execute(POS pos, String derivation, BaseFormSet form) throws JWNLException {
    Exc exc = Dictionary.getInstance().getException(pos, derivation);
    if (exc != null) {
      String[] exceptions = exc.getExceptionArray();
      for (int i = 0; i < exceptions.length; i++) {
        form.add(exceptions[i]);
      }
      return true;
    }
    return false;
  }
}

代码示例来源:origin: Noahs-ARK/semafor

private WordNetAPI(InputStream propsFile) throws Exception {
  info("Initialize WordNet...: ");
  
  if (propsFile == null)
    throw new RuntimeException("Missing required property 'WN_PROP'");
  try {
    JWNL.initialize(propsFile);
    wDict = Dictionary.getInstance();
    pUtils = PointerUtils.getInstance();
    morphProcessor = wDict.getMorphologicalProcessor();
  } catch (Exception e) {
    throw new RuntimeException("Initialization failed", e);
  }
  info("Done initializing WordNet...");
}

代码示例来源:origin: de.julielab/dragontool

public WordNetDidion(String workDir){
  String propsFile;
  try{
    if(!FileUtil.exist(workDir) && FileUtil.exist(EnvVariable.getDragonHome()+"/"+workDir))
      workDir=EnvVariable.getDragonHome()+"/"+workDir;
    propsFile=workDir+"/file_properties.xml";
    if(!checkDataDirectory(propsFile,workDir)){
      System.out.println("The wordnet data directory is not correct!");
      return;
    }
    JWNL.initialize(new FileInputStream(propsFile));
    dict = Dictionary.getInstance();
  }
  catch(Exception e)
  {
    e.printStackTrace();
  }
}

代码示例来源:origin: net.sf.jwordnet/jwnl

/**
 * Lookup the base form of a word. Given a lemma, finds the WordNet
 * entry most like that lemma. This function returns the first base form
 * found. Subsequent calls to this function with the same part-of-speech
 * and word will return the same base form. To find another base form for
 * the pos/word, call lookupNextBaseForm.
 * @param pos the part-of-speech of the word to look up
 * @param derivation the word to look up
 * @return IndexWord the IndexWord found during lookup
 */
public IndexWord lookupBaseForm(POS pos, String derivation) throws JWNLException {
  // See if we've already looked this word up
  LookupInfo info = getCachedLookupInfo(new POSKey(pos, derivation));
  if (info != null && info.getBaseForms().isCurrentFormAvailable()) {
    // get the last base form we retrieved. if you want
    // the next possible base form, use lookupNextBaseForm
    return Dictionary.getInstance().getIndexWord(pos, info.getBaseForms().getCurrentForm());
  } else {
    return lookupNextBaseForm(pos, derivation, info);
  }
}

相关文章