@Override public int hashCode() { return this.getTermId(); } }
@Override public int hashCode() { return this.getTermId(); } }
/** * Returns the weight of a given term, computed by the * specified query expansion model. * @param term String the term to set the weight for. * @param model QueryExpansionModel the used query expansion model. * @return double the weight of the specified term. */ public double getExpansionWeight(String term, QueryExpansionModel model) { return this.getExpansionWeight(lexicon.getLexiconEntry(term).getTermId(), model); }
/** * Returns the weight of a given term. * @param term String the term to get the weight for. * @return double the weight of the specified term. */ public double getExpansionWeight(String term) { return this.getExpansionWeight(lexicon.getLexiconEntry(term).getTermId(), model); } /**
/** * Returns the weight of a given term. * @param term String the term to get the weight for. * @return double the weight of the specified term. */ public double getExpansionWeight(String term) { return this.getExpansionWeight(lexicon.getLexiconEntry(term).getTermId(), model); } /**
/** * Returns the weight of a given term, computed by the * specified query expansion model. * @param term String the term to set the weight for. * @param model QueryExpansionModel the used query expansion model. * @return double the weight of the specified term. */ public double getExpansionWeight(String term, QueryExpansionModel model) { return this.getExpansionWeight(lexicon.getLexiconEntry(term).getTermId(), model); }
/** * Returns the frequency of a given term in the top-ranked documents. * @param term String the term to get the frequency for. * @return double the frequency of the specified term in the top-ranked documents. */ public double getFrequency(String term){ return this.getFrequency(lexicon.getLexiconEntry(term).getTermId()); }
/** * Returns the frequency of a given term in the top-ranked documents. * @param term String the term to get the frequency for. * @return double the frequency of the specified term in the top-ranked documents. */ public double getFrequency(String term){ return this.getFrequency(lexicon.getLexiconEntry(term).getTermId()); }
/** * Add new term, or update existing term. * * @return The termid of the term. */ public int term(String term, EntryStatistics es) { synchronized(modificationLock) { LexiconEntry le = this.getLexiconEntry(term); if (le != null) { le.add(es); return le.getTermId(); } int termid = super.map.size(); Text key = keyFactory.newInstance(); key.set(term); ((LexiconEntry) es).setTermId(termid); super.map.put(key, (LexiconEntry) es); return termid; } }
public int term(String term, EntryStatistics es, int termid) { synchronized(modificationLock) { LexiconEntry le = this.getLexiconEntry(term); if (le != null) { le.add(es); return le.getTermId(); } Text key = keyFactory.newInstance(); key.set(term); ((LexiconEntry) es).setTermId(termid); super.map.put(key, (LexiconEntry) es); return termid; } }
@Override public IterablePosting getPostings(Pointer lEntry) throws IOException { final int term = ((LexiconEntry)lEntry).getTermId(); //System.err.println("read: " + lEntry + " => " + term); if (blocks && fields) return new BFIterablePostingFromWritablePostingSlice(postings, term); else if (fields) return new FIterablePostingFromWritablePostingSlice(postings, term); else if (blocks) return new BIterablePostingFromWritablePostingSlice(postings, term); else return new IterablePostingFromWritablePostingSlice(postings, term); } };
@Override public IterablePosting getPostings(Pointer lEntry) throws IOException { final int term = ((LexiconEntry)lEntry).getTermId(); //System.err.println("read: " + lEntry + " => " + term); if (blocks && fields) return new BFIterablePostingFromWritablePostingSlice(postings, term); else if (fields) return new FIterablePostingFromWritablePostingSlice(postings, term); else if (blocks) return new BIterablePostingFromWritablePostingSlice(postings, term); else return new IterablePostingFromWritablePostingSlice(postings, term); } };
if (maxTFStructure != null) t.setMaxFrequencyInDocuments(maxTFStructure.get(t.getTermId()));
@Test public void test_iterator() throws Exception { MemoryLexicon lexicon = new MemoryLexicon(); assertNotNull(lexicon); for (int i = 0; i < 10; i++) lexicon.term(terms[i].toString(), entries[i]); Iterator<Entry<String, LexiconEntry>> it = lexicon.iterator(); assertNotNull(it); int i = 0; while (it.hasNext()) { Entry<String, LexiconEntry> kv1 = it.next(); Entry<String, LexiconEntry> kv2 = lexicon.getLexiconEntry(i++); assertEquals(kv1.getKey(), kv2.getKey()); assertEquals(kv1.getValue().getTermId(), kv2.getValue().getTermId()); assertEquals(kv1.getValue().getDocumentFrequency(), kv2.getValue().getDocumentFrequency()); assertEquals(kv1.getValue().getFrequency(), kv2.getValue().getFrequency()); } }
@Test public void test_getLexiconEntry2() throws Exception { MemoryLexicon lexicon = new MemoryLexicon(); assertNotNull(lexicon); for (int i = 0; i < 10; i++) lexicon.term(terms[i].toString(), entries[i]); for (int i = 0; i < 10; i++) { Entry<String, LexiconEntry> kv = lexicon.getLexiconEntry(i); assertEquals("t" + i, kv.getKey()); assertEquals(i, kv.getValue().getTermId()); assertEquals(i + 1, kv.getValue().getDocumentFrequency()); assertEquals(i + 1, kv.getValue().getFrequency()); } }
@Test public void test_getIthLexiconEntry() throws Exception { MemoryLexicon lexicon = new MemoryLexicon(); assertNotNull(lexicon); for (int i = 0; i < 10; i++) lexicon.term(terms[i].toString(), entries[i]); for (int i = 0; i < 10; i++) { Entry<String, LexiconEntry> kv = lexicon.getIthLexiconEntry(i); assertEquals("t" + i, kv.getKey()); assertEquals(i, kv.getValue().getTermId()); assertEquals(i + 1, kv.getValue().getDocumentFrequency()); assertEquals(i + 1, kv.getValue().getFrequency()); } }
@Test public void test_incrementTerm2() throws Exception { MemoryLexicon lexicon = new MemoryLexicon(); assertNotNull(lexicon); for (int i = 0; i < 10; i++) lexicon.term(terms[i].toString(), entries[i]); for (int i = 0; i < 10; i++) lexicon.term(terms[i].toString(), entries[i]); assertEquals(10, lexicon.numberOfEntries()); for (int i = 0; i < 10; i++) { Entry<String, LexiconEntry> kv = lexicon.getLexiconEntry(i); assertEquals("t" + i, kv.getKey()); assertEquals(i, kv.getValue().getTermId()); assertEquals((i + 1) * 2, kv.getValue().getDocumentFrequency()); assertEquals((i + 1) * 2, kv.getValue().getFrequency()); } }
@Test public void test_getLexiconEntry1() throws Exception { MemoryLexicon lexicon = new MemoryLexicon(); assertNotNull(lexicon); for (int i = 0; i < 10; i++) lexicon.term(terms[i].toString(), entries[i]); for (int i = 0; i < 10; i++) { LexiconEntry le = lexicon.getLexiconEntry(terms[i].toString()); assertEquals(i, le.getTermId()); assertEquals(i + 1, le.getDocumentFrequency()); assertEquals(i + 1, le.getFrequency()); } }