public String toString() { if (_cachedToString == null) { _cachedToString = JWNL.resolveMessage( "DATA_TOSTRING_011", new Object[]{getLabel(), getKey(), getFlagsAsString()}); } return _cachedToString; }
public static List getAllPointerTypesForPOS(POS pos) { List types = new ArrayList(); for (Iterator itr = ALL_TYPES.iterator(); itr.hasNext();) { PointerType pt = (PointerType) itr.next(); if (pt.appliesTo(pos)) { types.add(pt); } } return Collections.unmodifiableList(types); }
/** Whether or not this PointerType can be associated with <code>pos</code> */ public boolean appliesTo(POS pos) { return (_flags & getPOSMask(pos)) != 0; }
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); // set pointer type to reference the static instance defined in the current runtime environment _pointerType = PointerType.getPointerTypeForKey(_pointerType.getKey()); }
PointerType.initialize(); Adjective.initialize(); VerbFrame.initialize();
public int hashCode() { return getLabel().hashCode(); }
/** Returns true if <var>type</var> is symmetric to this pointer type. */ public boolean symmetricTo(PointerType type) { return getSymmetricType() != null && getSymmetricType().equals(type); }
PointerType type = PointerType.getPointerTypeForKey(pointers.getString(1)); long targetOffset = pointers.getLong(2); POS targetPOS = POS.getPOSForKey(pointers.getString(3));
public static void initialize() { if (!_initialized) { POS_TO_MASK_MAP.put(POS.NOUN, new Integer(N)); POS_TO_MASK_MAP.put(POS.VERB, new Integer(V)); POS_TO_MASK_MAP.put(POS.ADJECTIVE, new Integer(ADJ)); POS_TO_MASK_MAP.put(POS.ADVERB, new Integer(ADV)); for (Iterator itr = ALL_TYPES.iterator(); itr.hasNext();) { PointerType pt = (PointerType) itr.next(); KEY_TO_POINTER_TYPE_MAP.put(pt.getKey(), pt); } _initialized = true; } }
public int hashCode() { return getPointerTarget().hashCode() ^ getType().hashCode(); }
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(); }
private void addPointerFeature(Set<String> f1, Synset synset, WordNetFeatureClass name, String key) { if (featureClasses.contains(name)) { for (Pointer p : synset.getPointers()) { f1.add(key + p.getType().getLabel()); } } }
public Relationship reverse() { PointerTargetNodeList list = ((PointerTargetNodeList)getNodeList().deepClone()).reverse(); for (int i = 0; i < list.size(); i++) { ((PointerTargetNode)list.get(i)).setType(getType().getSymmetricType()); } return new SymmetricRelationship(getType(), list, getSourceSynset(), getTargetSynset()); } }
for (int i = 0; i < pointerCount; i++) { String pt = tokenizer.nextToken(); PointerType pointerType = PointerType.getPointerTypeForKey(pt); long targetOffset = tokenizer.nextLong(); POS targetPOS = POS.getPOSForKey(tokenizer.nextToken());
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(); }
private void addPointerFeature(Set<String> f1, Synset synset, WordNetFeatureClass name, String key) { if (featureClasses.contains(name)) { for (Pointer p : synset.getPointers()) { f1.add(key + p.getType().getLabel()); } } }
public Relationship reverse() { PointerTargetNodeList list = ((PointerTargetNodeList) getNodeList().deepClone()).reverse(); int commonParentIndex = (list.size() - 1) - getCommonParentIndex(); for (int i = 0; i < list.size(); i++) { if (i != commonParentIndex) { ((PointerTargetNode) list.get(i)).setType(getType().getSymmetricType()); } } return new AsymmetricRelationship(getType(), list, commonParentIndex, getSourceSynset(), getTargetSynset()); } }
public synchronized Set<String> getPointers(String word, POS pos, boolean firstOnly) throws JWNLException { Set<String> pointers = new LinkedHashSet<>(); IndexWord indexWord = getIndexWord(pos, word); if (indexWord == null) return pointers; for (Synset synset : indexWord.getSenses()) { for (Pointer p : synset.getPointers()) { pointers.add(p.getType().getLabel()); } if (firstOnly) break; } return pointers; }
node.setType(type.getSymmetricType()); relationship.add(node);
public synchronized Set<String> getPointers(String word, POS pos, boolean firstOnly) throws JWNLException { Set<String> pointers = new LinkedHashSet<>(); IndexWord indexWord = getIndexWord(pos, word); if (indexWord == null) return pointers; for (Synset synset : indexWord.getSenses()) { for (Pointer p : synset.getPointers()) { pointers.add(p.getType().getLabel()); } if (firstOnly) break; } return pointers; }