org.apache.lucene.search.similarities.IndependenceChiSquared Java Examples

The following examples show how to use org.apache.lucene.search.similarities.IndependenceChiSquared. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DFISimilarityFactory.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private Independence parseIndependenceMeasure(String expr) {
  if ("ChiSquared".equals(expr)) {
    return new IndependenceChiSquared();
  } else if ("Standardized".equals(expr)) {
    return new IndependenceStandardized();
  } else if ("Saturated".equals(expr)) {
    return new IndependenceSaturated();
  } else {
    throw new RuntimeException("Invalid independence measure: " + expr);
  }
}
 
Example #2
Source File: TestDFISimilarityFactory.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * dfi with no parameters
 */
public void test() throws Exception {
  Similarity sim = getSimilarity("text");
  assertEquals(DFISimilarity.class, sim.getClass());
  DFISimilarity dfi = (DFISimilarity) sim;
  assertTrue(dfi.getDiscountOverlaps());
  assertTrue(dfi.getIndependence() instanceof IndependenceChiSquared);
}
 
Example #3
Source File: LtrQueryTests.java    From elasticsearch-learning-to-rank with Apache License 2.0 5 votes vote down vote up
@Before
public void setupIndex() throws IOException {
    dirUnderTest = newDirectory();
    List<Similarity> sims = Arrays.asList(
            new ClassicSimilarity(),
            new SweetSpotSimilarity(), // extends Classic
            new BM25Similarity(),
            new LMDirichletSimilarity(),
            new BooleanSimilarity(),
            new LMJelinekMercerSimilarity(0.2F),
            new AxiomaticF3LOG(0.5F, 10),
            new DFISimilarity(new IndependenceChiSquared()),
            new DFRSimilarity(new BasicModelG(), new AfterEffectB(), new NormalizationH1()),
            new IBSimilarity(new DistributionLL(), new LambdaDF(), new NormalizationH3())
        );
    similarity = sims.get(random().nextInt(sims.size()));

    indexWriterUnderTest = new RandomIndexWriter(random(), dirUnderTest, newIndexWriterConfig().setSimilarity(similarity));
    for (int i = 0; i < docs.length; i++) {
        Document doc = new Document();
        doc.add(newStringField("id", "" + i, Field.Store.YES));
        doc.add(newField("field", docs[i], Store.YES));
        indexWriterUnderTest.addDocument(doc);
    }
    indexWriterUnderTest.commit();
    indexWriterUnderTest.forceMerge(1);
    indexWriterUnderTest.flush();


    indexReaderUnderTest = indexWriterUnderTest.getReader();
    searcherUnderTest = newSearcher(indexReaderUnderTest);
    searcherUnderTest.setSimilarity(similarity);
}