public LRUPOSCache(int capacity) { caches = new EnumMap<>(POS.class); for (POS pos : POS.getAllPOS()) { caches.put(pos, new LRUCache<>(capacity)); } }
/** * Loads all targets in load all pointers and all synsets in all index words. * * @throws JWNLException JWNLException */ protected void resolveAllPointers() throws JWNLException { for (POS pos : POS.getAllPOS()) { resolvePointers(pos); } }
public LRUPOSCache(int capacity) { caches = new EnumMap<>(POS.class); for (POS pos : POS.getAllPOS()) { caches.put(pos, new LRUCache<>(capacity)); } }
/** * Loads all targets in load all pointers and all synsets in all index words. * * @throws JWNLException JWNLException */ protected void resolveAllPointers() throws JWNLException { for (POS pos : POS.getAllPOS()) { resolvePointers(pos); } }
public static HashMap<String, Object> getStemCache() { if (stemCache == null || stemCache.keySet().isEmpty()) { stemCache = new HashMap<String, Object>(); for (Object pos : POS.getAllPOS()) { stemCache.put(((POS) pos).getKey(), new HashMap()); } } return stemCache; }
public synchronized void cacheAll() throws JWNLException { setCacheCapacity(Integer.MAX_VALUE); for (POS pos : POS.getAllPOS()) { cachePOS(pos); } }
public synchronized void cacheAll() throws JWNLException { setCacheCapacity(Integer.MAX_VALUE); for (POS pos : POS.getAllPOS()) { cachePOS(pos); } }
public void clearCache(K key) { for (POS pos : POS.getAllPOS()) { getCache(key).getCache(pos).clear(); } }
public void setCacheCapacity(K cacheKey, int capacity) { for (POS pos : POS.getAllPOS()) { getCache(cacheKey).getCache(pos).setCapacity(capacity); } }
public void clearCache(K key) { for (POS pos : POS.getAllPOS()) { getCache(key).getCache(pos).clear(); } }
/** * This method consumes a binding of a WordNet's synset and it's associated Uby-LMF-synset. * It updates the {@link SynsetRelations} of the Uby-LMF-synset. * @param binding the binding of two synset, with WordNet's synset as key * @see Synset * @see net.sf.extjwnl.data.Synset */ private void updateSynsetRelations(Entry<net.sf.extjwnl.data.Synset, Synset> binding){ // Create SynsetRelation for the binding List<SynsetRelation> synsetRelations = new LinkedList<SynsetRelation>(); net.sf.extjwnl.data.Synset synset = binding.getKey(); List<Pointer> pointers = synset.getPointers(); int posOrdinal = POS.getAllPOS().indexOf(synset.getPOS()); // ordinal of synset's POS // Iterate over all pointers of the WNSynset and generate the corresponding SynsetRelation for(Pointer pointer : pointers) { if(!ignoredPointerKeys.contains(pointer.getType().getKey())) { synsetRelations.add(generateSynsetRelation(pointer, posOrdinal)); } } binding.getValue().setSynsetRelations(synsetRelations); }
public int getCacheSize(K cacheKey) { int result = 0; for (POS pos : POS.getAllPOS()) { result = result + getCache(cacheKey).getCache(pos).size(); } return result; }
public long getCacheCapacity(K cacheKey) { long result = 0; for (POS pos : POS.getAllPOS()) { result = result + getCache(cacheKey).getCache(pos).getCapacity(); } return result; }
public void setCacheCapacity(K cacheKey, int capacity) { for (POS pos : POS.getAllPOS()) { getCache(cacheKey).getCache(pos).setCapacity(capacity); } }
public int getCacheSize(K cacheKey) { int result = 0; for (POS pos : POS.getAllPOS()) { result = result + getCache(cacheKey).getCache(pos).size(); } return result; }
public long getCacheCapacity(K cacheKey) { long result = 0; for (POS pos : POS.getAllPOS()) { result = result + getCache(cacheKey).getCache(pos).getCapacity(); } return result; }
/** * Returns 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> * @throws JWNLException JWNLException */ public IndexWordSet lookupAllIndexWords(String lemma) throws JWNLException { lemma = prepareQueryString(lemma); IndexWordSet set = new IndexWordSet(lemma); for (POS pos : POS.getAllPOS()) { IndexWord current = lookupIndexWord(pos, lemma); if (current != null) { set.add(current); } } return set; }
/** * Converts the current Dictionary to a MapBackedDictionary. * * @throws JWNLException JWNLException * @throws IOException IOException */ public void convert() throws JWNLException, IOException { destinationFiles.open(); destinationFiles.edit(); boolean canClearCache = (dictionary instanceof AbstractCachingDictionary) && ((AbstractCachingDictionary) dictionary).isCachingEnabled(); for (DictionaryFileType fileType : DictionaryFileType.getAllDictionaryFileTypes()) { for (POS pos : POS.getAllPOS()) { System.out.println("Converting " + pos.getLabel() + " " + fileType.getName() + "..."); serialize(pos, fileType); } if (canClearCache) { ((AbstractCachingDictionary) dictionary).clearCache(fileType.getElementType()); } } destinationFiles.close(); }
/** * This method consumes a lexical pointer and generates the associated RelatedForm, defined in Uby-LMF * @param pointer WordNet's lexical pointer * @return RelatedForm associated with the consumed pointer * @see RelatedForm * @see Pointer */ private RelatedForm generateRelatedForm(Pointer pointer){ RelatedForm relatedForm = new RelatedForm(); // setting RelationType ERelTypeMorphology relType = getRelType(pointer.getType().getKey(), POS.getAllPOS().indexOf(pointer.getSource().getPOS())); relatedForm.setRelType(relType); // setting targetSense Word targetLexeme = (Word) pointer.getTarget(); relatedForm.setTargetSense(lexicalEntryGenerator.getSenseGenerator().getSense(targetLexeme)); // setting targeted LexicalEntry LexicalEntry targetLexicalEntry = lexicalEntryGenerator.getLexicalEntry(targetLexeme); if (targetLexicalEntry == null) throw new NullPointerException("Unable to find target lexical entry of related form for " + targetLexeme); relatedForm.setTargetLexicalEntry(targetLexicalEntry); return relatedForm; }
/** * This method creates a SenseRelation based on the consumed WordNet-pointer * @param pointer WordNet's {@link Pointer} * @return instance of {@link SenseRelation}-class associated with the consumed pointer */ private SenseRelation createSenseRelation(Pointer pointer){ SenseRelation senseRelation = new SenseRelation(); // Setting the target Word target = (Word) pointer.getTarget(); senseRelation.setTarget(lexicalEntryGenerator.getSenseGenerator().getSense(target)); String pointerKey = pointer.getType().getKey(); int posOrdinal = POS.getAllPOS().indexOf(pointer.getSource().getPOS()); // setting RelationName String relName = getRelName(pointerKey, posOrdinal); senseRelation.setRelName(relName); // settin relation type ERelTypeSemantics relType = getRelType(pointerKey, posOrdinal); senseRelation.setRelType(relType); return senseRelation; }