private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); // set POS to reference the static instance defined in the current runtime environment _pos = POS.getPOSForKey(_pos.getKey()); _synsets = new Synset[_synsetOffsets.length]; } }
public DictionaryCatalog(String path, DictionaryFileType fileType, Class dictionaryFileType) { _fileType = fileType; try { Constructor c = dictionaryFileType.getConstructor(new Class[0]); DictionaryFile factory = (DictionaryFile) c.newInstance(null); for (Iterator itr = POS.getAllPOS().iterator(); itr.hasNext();) { DictionaryFile file = factory.newInstance(path, (POS)itr.next(), fileType); _files.put(file.getPOS(), file); } } catch (Exception ex) { throw new JWNLRuntimeException("DICTIONARY_EXCEPTION_0018", new Object[]{fileType, dictionaryFileType}, ex); } }
/** * Return the <code>POS</code> whose key matches <var>label</var>, * or null if the label does not match any POS. */ public static POS getPOSForLabel(String label) { for (Iterator itr = ALL_POS.iterator(); itr.hasNext();) { POS pos = (POS)itr.next(); if (pos.getLabel().equals(label)) { return pos; } } return null; }
/** * Return the <code>POS</code> whose key matches <var>key</var>, * or null if the key does not match any POS. */ public static POS getPOSForKey(String key) { for (Iterator itr = ALL_POS.iterator(); itr.hasNext();) { POS pos = (POS)itr.next(); if (pos.getKey().equals(key)) { return pos; } } return null; }
private static Synset getSynset(final String id) { final POS pos = POS.getPOSForKey(getPOS(id)); final long offset = getOffset(id); try { synchronized (WordNet.class) { return getDictionary().getSynsetAt(pos, offset); } } catch (final JWNLException ex) { throw new Error(ex); } }
public int hashCode() { return _pos.hashCode() ^ _key.hashCode(); }
protected AbstractDelegatingOperation getInstance(Map params) throws JWNLException { Map suffixMap = new HashMap(); for (Iterator itr = params.values().iterator(); itr.hasNext();) { Param p = (Param) itr.next(); POS pos = POS.getPOSForLabel(p.getName()); if (pos != null) { suffixMap.put(pos, getSuffixArray(p.getValue())); } } return new DetachSuffixesOperation(suffixMap); }
@Nullable public static String mapSynsetToBBN(@Nullable final String synsetID) { final List<String> ids = Lists.newLinkedList(); ids.add(synsetID); while (!ids.isEmpty()) { final String id = ids.remove(0); final List<String> bbns = SYNSET_TO_BBN.get(id); if (bbns != null && !bbns.isEmpty()) { return bbns.get(0); // return only first BBN in case of ambiguity } try { final Synset source = getSynset(id); final List<String> hypernymIDs = Lists.newArrayList(); for (final PointerType type : new PointerType[] { PointerType.HYPERNYM, PointerType.INSTANCE_HYPERNYM }) { for (final Pointer pointer : source.getPointers(type)) { final Synset target = pointer.getTargetSynset(); hypernymIDs.add(getSynsetID(target.getOffset(), target.getPOS().getKey())); } } Collections.sort(hypernymIDs); // necessary in order to get deterministic results ids.addAll(hypernymIDs); } catch (final JWNLException ex) { throw new Error("Unexpected exception (!)", ex); } } return null; }
PointerType type = PointerType.getPointerTypeForKey(pointers.getString(1)); long targetOffset = pointers.getLong(2); POS targetPOS = POS.getPOSForKey(pointers.getString(3)); int sourceIndex = pointers.getInt(4); int targetIndex = pointers.getInt(5);
public int hashCode() { return _pos.hashCode() ^ _fileType.hashCode(); }
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); // set POS to reference the static instance defined in the current runtime environment _pos = POS.getPOSForKey(_pos.getKey()); } }
private Query createPOSQuery(POS pos, String sql) throws JWNLException { Query query = null; try { query = _connectionManager.getQuery(sql); query.getStatement().setString(1, pos.getKey()); return query; } catch (SQLException ex) { if (query != null) { query.close(); } throw new JWNLException("DICTIONARY_EXCEPTION_023", ex); } }
PointerType pointerType = PointerType.getPointerTypeForKey(pt); long targetOffset = tokenizer.nextLong(); POS targetPOS = POS.getPOSForKey(tokenizer.nextToken()); int linkIndices = tokenizer.nextHexInt(); int sourceIndex = linkIndices / 256;
public int hashCode() { return getLemma().hashCode() ^ getPOS().hashCode(); }
/** * 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; } }
public String toString() { if (_cachedToString == null) { _cachedToString = JWNL.resolveMessage("DATA_TOSTRING_010", getLabel()); } return _cachedToString; }
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); // set POS to reference the static instance defined in the current runtime environment _pos = POS.getPOSForKey(_pos.getKey()); } }
private Query createPOSIdQuery(POS pos, int id, String sql) throws JWNLException { Query query = null; try { query = _connectionManager.getQuery(sql); query.getStatement().setString(1, pos.getKey()); query.getStatement().setInt(2, id); return query; } catch (SQLException ex) { if (query != null) { query.close(); } throw new JWNLException("DICTIONARY_EXCEPTION_023", ex); } } }
public int hashCode() { return getPOS().hashCode() ^ (int) getOffset(); }
/** Create a <code>MapBackedDictionary</code> with the specified set of files.*/ private MapBackedDictionary(DictionaryCatalogSet files, MorphologicalProcessor morph) throws JWNLException { super(morph); if (!files.isOpen()) { try { files.open(); } catch (Exception ex) { throw new JWNLException("DICTIONARY_EXCEPTION_019", ex); } } // Load all the hashtables into memory _log.log(MessageLogLevel.INFO, "Loading MapBackedDictionary"); if (_log.isLevelEnabled(MessageLogLevel.TRACE)) { _log.log(MessageLogLevel.TRACE, "Starting Memory: " + Runtime.getRuntime().freeMemory()); } for (Iterator typeItr = DictionaryFileType.getAllDictionaryFileTypes().iterator(); typeItr.hasNext();) { DictionaryFileType fileType = (DictionaryFileType)typeItr.next(); DictionaryCatalog catalog = files.get(fileType); for (Iterator posItr = POS.getAllPOS().iterator(); posItr.hasNext();) { POS pos = (POS)posItr.next(); _log.log(MessageLogLevel.INFO, "Loading " + pos + " " + fileType); putTable(pos, fileType, loadDictFile(catalog.get(pos))); if (_log.isLevelEnabled(MessageLogLevel.TRACE)) { _log.log(MessageLogLevel.TRACE, "Current Memory: " + Runtime.getRuntime().freeMemory()); } } } }