public IndexWord getIndexWord(POS pos, String lemma) { return (IndexWord) getTable(pos, DictionaryFileType.INDEX).get(prepareQueryString(lemma)); }
public Iterator getIndexWordIterator(final POS pos, final String substring) throws JWNLException { return new SubstringIndexFileLookaheadIterator(pos, prepareQueryString(substring)); }
public Exc getException(POS pos, String derivation) { return (Exc) getTable(pos, DictionaryFileType.EXCEPTION).get(prepareQueryString(derivation)); }
public Iterator getIndexWordIterator(POS pos, String substring) { substring = prepareQueryString(substring); final Iterator itr = getIndexWordIterator(pos); String temp = null; while (itr.hasNext()) { IndexWord word = (IndexWord) itr.next(); String w = word.getLemma(); if (w.indexOf(substring) != -1) { temp = w; break; } } return new IndexWordIterator(itr, substring, temp); }
/** * Return a set of <code>IndexWord</code>s, with each element in the set * corresponding to a part-of-speech of <var>word</var>. * @param lemma the word for which to lookup senses * @return An array of IndexWords, each of which is a sense of <var>word</var> */ public IndexWordSet lookupAllIndexWords(String lemma) throws JWNLException { lemma = prepareQueryString(lemma); IndexWordSet set = new IndexWordSet(lemma); for (Iterator itr = POS.getAllPOS().iterator(); itr.hasNext();) { IndexWord current = lookupIndexWord((POS)itr.next(), lemma); if (current != null) set.add(current); } return set; } }
/** * 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; }
public IndexWord getIndexWord(POS pos, String lemma) throws JWNLException { lemma = prepareQueryString(lemma); IndexWord word = null; if (lemma.length() > 0) { if (isCachingEnabled()) { word = getCachedIndexWord(new POSKey(pos, lemma)); } if (word == null) { try { long offset = getFileManager().getIndexedLinePointer( pos, DictionaryFileType.INDEX, lemma.replace(' ', '_')); if (offset >= 0) { word = parseAndCacheIndexWordLine( pos, offset, getFileManager().readLineAt(pos, DictionaryFileType.INDEX, offset)); } } catch (IOException e) { throw new JWNLException("DICTIONARY_EXCEPTION_004", lemma, e); } } } return word; }
public Exc getException(POS pos, String derivation) throws JWNLException { derivation = prepareQueryString(derivation); Exc exc = null; POSKey key = null; if (derivation != null) { if (isCachingEnabled()) { key = new POSKey(pos, derivation); exc = getCachedException(key); } if (exc == null) { long offset = -1; try { offset = getFileManager().getIndexedLinePointer( pos, DictionaryFileType.EXCEPTION, derivation.replace(' ', '_')); if (offset >= 0) { exc = parseAndCacheExceptionLine( pos, offset, getFileManager().readLineAt(pos, DictionaryFileType.EXCEPTION, offset)); } } catch (IOException ex) { throw new JWNLException("DICTIONARY_EXCEPTION_006", ex); } } } return exc; }
public IndexWord getIndexWord(POS pos, String lemma) throws JWNLException { lemma = prepareQueryString(lemma); IndexWord word = null; if (lemma.length() > 0) { if (isCachingEnabled()) { word = getCachedIndexWord(new POSKey(pos, lemma)); } if (word == null) { Query query = null; try { query = _dbManager.getIndexWordSynsetsQuery(pos, lemma); word = _elementFactory.createIndexWord(pos, lemma, query.execute()); if (word != null && isCachingEnabled()) { cacheIndexWord(new POSKey(pos, lemma), word); } } catch (SQLException e) { throw new JWNLException("DICTIONARY_EXCEPTION_023", e); } finally { query.close(); } } } return word; }