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

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

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

Dictionary.getMorphologicalProcessor介绍

暂无

代码示例

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

public synchronized ArrayList<String> getMorphs(POS pos, String lexicalForm)
    throws JWNLException {
  HashSet<String> forms = new LinkedHashSet<>();
  List<?> baseForms =
      wordnet.getMorphologicalProcessor().lookupAllBaseForms(pos, lexicalForm);
  for (Object baseForm : baseForms) {
    forms.add(baseForm.toString());
  }
  return new ArrayList<>(forms);
}

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

public synchronized ArrayList<String> getMorphs(POS pos, String lexicalForm)
    throws JWNLException {
  HashSet<String> forms = new LinkedHashSet<>();
  List<?> baseForms =
      wordnet.getMorphologicalProcessor().lookupAllBaseForms(pos, lexicalForm);
  for (Object baseForm : baseForms) {
    forms.add(baseForm.toString());
  }
  return new ArrayList<>(forms);
}

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

/**
 * Main word lookup procedure. First try a normal lookup. If that doesn't work,
 * try looking up the stemmed form of the lemma.
 * @param pos the part-of-speech of the word to look up
 * @param lemma the lemma to look up
 * @return IndexWord the IndexWord found by the lookup procedure, or null
 *                if an IndexWord is not found
 */
public IndexWord lookupIndexWord(POS pos, String lemma) throws JWNLException {
  lemma = prepareQueryString(lemma);
  IndexWord word = getIndexWord(pos, lemma);
  if (word == null && getMorphologicalProcessor() != null) {
    word = getMorphologicalProcessor().lookupBaseForm(pos, lemma);
  }
  return word;
}

代码示例来源: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: Ailab403/ailab-mltk4j

public JWNLDictionary(String searchDirectory) throws IOException, JWNLException {
 PointerType.initialize();
 Adjective.initialize();
 VerbFrame.initialize();
 Map<POS, String[][]> suffixMap = new HashMap<POS, String[][]>();
 suffixMap.put(POS.NOUN,new String[][] {{"s",""},{"ses","s"},{"xes","x"},{"zes","z"},{"ches","ch"},{"shes","sh"},{"men","man"},{"ies","y"}});
 suffixMap.put(POS.VERB,new String[][] {{"s",""},{"ies","y"},{"es","e"},{"es",""},{"ed","e"},{"ed",""},{"ing","e"},{"ing",""}});
 suffixMap.put(POS.ADJECTIVE,new String[][] {{"er",""},{"est",""},{"er","e"},{"est","e"}});
 DetachSuffixesOperation tokDso = new DetachSuffixesOperation(suffixMap);
 tokDso.addDelegate(DetachSuffixesOperation.OPERATIONS,new Operation[] {new LookupIndexWordOperation(),new LookupExceptionsOperation()});
 TokenizerOperation tokOp = new TokenizerOperation(new String[] {" ","-"});
 tokOp.addDelegate(TokenizerOperation.TOKEN_OPERATIONS,new Operation[] {new LookupIndexWordOperation(),new LookupExceptionsOperation(),tokDso});
 DetachSuffixesOperation morphDso = new DetachSuffixesOperation(suffixMap);
 morphDso.addDelegate(DetachSuffixesOperation.OPERATIONS,new Operation[] {new LookupIndexWordOperation(),new LookupExceptionsOperation()});
 Operation[] operations = {new LookupExceptionsOperation(), morphDso , tokOp};
 morphy = new DefaultMorphologicalProcessor(operations);
 FileManager manager = new FileManagerImpl(searchDirectory,PrincetonRandomAccessDictionaryFile.class);
 FileDictionaryElementFactory factory = new PrincetonWN17FileDictionaryElementFactory();
 FileBackedDictionary.install(manager, morphy,factory,true);
 dict = net.didion.jwnl.dictionary.Dictionary.getInstance();
 morphy = dict.getMorphologicalProcessor();
}

代码示例来源:origin: apache/opennlp-sandbox

public JWNLDictionary(String searchDirectory) throws IOException, JWNLException {
 PointerType.initialize();
 Adjective.initialize();
 VerbFrame.initialize();
 Map<POS, String[][]> suffixMap = new HashMap<POS, String[][]>();
 suffixMap.put(POS.NOUN,new String[][] {{"s",""},{"ses","s"},{"xes","x"},{"zes","z"},
   {"ches","ch"},{"shes","sh"},{"men","man"},{"ies","y"}});
 suffixMap.put(POS.VERB,new String[][] {{"s",""},{"ies","y"},{"es","e"},{"es",""},{"ed","e"},
   {"ed",""},{"ing","e"},{"ing",""}});
 suffixMap.put(POS.ADJECTIVE,new String[][] {{"er",""},{"est",""},{"er","e"},{"est","e"}});
 DetachSuffixesOperation tokDso = new DetachSuffixesOperation(suffixMap);
 tokDso.addDelegate(DetachSuffixesOperation.OPERATIONS,new Operation[] {
   new LookupIndexWordOperation(),new LookupExceptionsOperation()});
 TokenizerOperation tokOp = new TokenizerOperation(new String[] {" ","-"});
 tokOp.addDelegate(TokenizerOperation.TOKEN_OPERATIONS,new Operation[] {
   new LookupIndexWordOperation(),new LookupExceptionsOperation(),tokDso});
 DetachSuffixesOperation morphDso = new DetachSuffixesOperation(suffixMap);
 morphDso.addDelegate(DetachSuffixesOperation.OPERATIONS,new Operation[] {
   new LookupIndexWordOperation(),new LookupExceptionsOperation()});
 Operation[] operations = {new LookupExceptionsOperation(), morphDso , tokOp};
 morphy = new DefaultMorphologicalProcessor(operations);
 FileManager manager = new FileManagerImpl(searchDirectory,
   PrincetonRandomAccessDictionaryFile.class);
 FileDictionaryElementFactory factory = new PrincetonWN17FileDictionaryElementFactory();
 FileBackedDictionary.install(manager, morphy,factory,true);
 dict = net.didion.jwnl.dictionary.Dictionary.getInstance();
 morphy = dict.getMorphologicalProcessor();
}

相关文章