public WordNet(String configPath) { try { JWNL.initialize(this.getClass().getClassLoader().getResourceAsStream(configPath)); dict = Dictionary.getInstance(); } catch (JWNLException e) { e.printStackTrace(); } }
private void registerDriver() throws JWNLException { if (!_registered) { try { Driver driver = (Driver) Class.forName(_driverClass).newInstance(); DriverManager.registerDriver(driver); _registered = true; } catch (Exception ex) { throw new JWNLException("DICTIONARY_EXCEPTION_024", ex); } } } }
e.printStackTrace(); errMsg = e.getMessage();
public WordNet() { try { JWNL.initialize(this.getClass().getClassLoader().getResourceAsStream("wordnet_properties.xml")); dict = Dictionary.getInstance(); } catch (JWNLException e) { e.printStackTrace(); } }
protected long getNextOffset(long currentOffset) throws JWNLException { try { return _db.getNextLinePointer(_pos, _fileType, currentOffset); } catch (IOException ex) { throw new JWNLException("DICTIONARY_EXCEPTION_008", new Object[]{_pos, _fileType}, ex); } } }
public String getSenseKey(String lemma, String pos,int sense) { try { IndexWord iw = dict.getIndexWord(POS.NOUN,lemma); if (iw == null) { return null; } return String.valueOf(iw.getSynsetOffsets()[sense]); } catch (JWNLException e) { e.printStackTrace(); return null; } }
/** If the class is installable, this method will install it using the parameters */ public void install() throws JWNLException { try { Installable installable = (Installable) Class.forName(_className).newInstance(); installable.install(_paramMap); } catch (Exception ex) { throw new JWNLException("UTILS_EXCEPTION_005", _className, ex); } } }
public String getSenseKey(String lemma, String pos,int sense) { try { IndexWord iw = dict.getIndexWord(POS.NOUN,lemma); if (iw == null) { return null; } return String.valueOf(iw.getSynsetOffsets()[sense]); } catch (JWNLException e) { e.printStackTrace(); return null; } }
private String[][] getSuffixArray(String suffixes) throws JWNLException { StringTokenizer tokenizer = new StringTokenizer(suffixes, "|=", true); if (!"|".equals(tokenizer.nextToken())) { throw new JWNLException("DICTIONARY_EXCEPTION_028"); } List suffixList = new ArrayList(); while (tokenizer.hasMoreTokens()) { String next = tokenizer.nextToken(); String first = ""; String second = ""; if (!"=".equals(next)) { first = next; tokenizer.nextToken(); } next = tokenizer.nextToken(); if (!"|".equals(next)) { second = next; tokenizer.nextToken(); } suffixList.add(new String[] {first, second}); } return (String[][]) suffixList.toArray(new String[suffixList.size()][]); }
@SuppressWarnings("unchecked") public String[] getLemmas(String word, String tag) { try { POS pos; if (tag.startsWith("N") || tag.startsWith("n")) { pos = POS.NOUN; } else if (tag.startsWith("V") || tag.startsWith("v")) { pos = POS.VERB; } else if (tag.startsWith("J") || tag.startsWith("a")) { pos = POS.ADJECTIVE; } else if (tag.startsWith("R") || tag.startsWith("r")) { pos = POS.ADVERB; } else { pos = POS.NOUN; } List<String> lemmas = morphy.lookupAllBaseForms(pos,word); return lemmas.toArray(new String[lemmas.size()]); } catch (JWNLException e) { e.printStackTrace(); return null; } }
public Object create(Map params) throws JWNLException { ParamList operationParams = (ParamList) params.get(OPERATIONS); if (operationParams == null) { throw new JWNLException("DICTIONARY_EXCEPTION_026"); } List operations = (List)operationParams.create(); Operation[] operationArray = (Operation[])operations.toArray(new Operation[operations.size()]); Param param = (Param) params.get(CACHE_CAPACITY); int capacity = (param == null) ? DEFAULT_CACHE_CAPACITY : new Integer(param.getValue()).intValue(); return new DefaultMorphologicalProcessor(operationArray, capacity); }
@SuppressWarnings("unchecked") public String[] getLemmas(String word, String tag) { try { POS pos; if (tag.startsWith("N") || tag.startsWith("n")) { pos = POS.NOUN; } else if (tag.startsWith("V") || tag.startsWith("v")) { pos = POS.VERB; } else if (tag.startsWith("J") || tag.startsWith("a")) { pos = POS.ADJECTIVE; } else if (tag.startsWith("R") || tag.startsWith("r")) { pos = POS.ADVERB; } else { pos = POS.NOUN; } List<String> lemmas = morphy.lookupAllBaseForms(pos,word); return lemmas.toArray(new String[lemmas.size()]); } catch (JWNLException e) { e.printStackTrace(); return null; } }
protected long getNextOffset(long currentOffset) throws JWNLException { try { return getFileManager().getMatchingLinePointer(_pos, DictionaryFileType.INDEX, currentOffset, _substring); } catch (IOException ex) { throw new JWNLException("DICTIONARY_EXCEPTION_008", new Object[]{_pos, _fileType}, ex); } } }
public WordNet(InputStream propertiesStream) { try { JWNL.initialize(propertiesStream); dict = Dictionary.getInstance(); } catch (JWNLException e) { e.printStackTrace(); } }
private Map loadDictFile(DictionaryFile file) throws JWNLException { try { return (Map) ((ObjectDictionaryFile) file).readObject(); } catch (Exception ex) { throw new JWNLException("DICTIONARY_EXCEPTION_020", file.getFile(), ex); } }
public String lemmatize(String word,int pos) { IndexWord indexWord; if(Character.isDigit(word.charAt(word.length()-1))) return word; if(pos>Lemmatiser.LASTPOS || pos<Lemmatiser.FIRSTPOS) return word; try{ indexWord = dict.lookupIndexWord(getPOS(pos), word); if (indexWord != null) return indexWord.getLemma(); else return word; } catch(JWNLException ex) { ex.printStackTrace(); return null; } }
/** * If the value of this parameter is a class name, and that class is creatable, this method will create * an instance of it using this Param's parameters. */ public Object create() throws JWNLException { try { Class clazz = Class.forName(getValue()); Createable creatable = (Createable) clazz.newInstance(); return creatable.create(_paramMap); } catch (Exception ex) { throw new JWNLException("JWNL_EXCEPTION_004", getValue(), ex); } } }
public List<String> getHyponyms(POS pos, String s) { ArrayList<String> result = new ArrayList<>(); try { IndexWord word = dict.getIndexWord(pos, s); if (word == null) { System.err.println("Unable to find index word for " + s); return result; } Synset sense = word.getSense(1); getHyponymsRecursive(result, sense, 3); } catch (JWNLException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } return result; }
public Object create(Map params) throws JWNLException { Class fileClass = null; try { fileClass = Class.forName(((Param)params.get(FILE_TYPE)).getValue()); } catch (ClassNotFoundException ex) { throw new JWNLRuntimeException("DICTIONARY_EXCEPTION_002", ex); } checkFileType(fileClass); String path = ((Param)params.get(PATH)).getValue(); try { return new FileManagerImpl(path, fileClass); } catch (IOException ex) { throw new JWNLException("DICTIONARY_EXCEPTION_016", fileClass, ex); } }
public String lemmatize(String word) { IndexWord indexWord; int i; if(Character.isDigit(word.charAt(word.length()-1))) return word; for(i=Lemmatiser.FIRSTPOS;i<=Lemmatiser.LASTPOS;i++){ try { indexWord = dict.lookupIndexWord(getPOS(i), word); if (indexWord != null) return indexWord.getLemma(); } catch (JWNLException ex) { ex.printStackTrace(); return null; } } return word; }