Search in sources :

Example 11 with FeatureExtractors

use of io.anserini.ltr.feature.FeatureExtractors in project Anserini by castorini.

the class FeatureExtractorChainFromJsonTest method testChainSingleExtractorNoParam.

@Test
public void testChainSingleExtractorNoParam() throws Exception {
    String jsonString = "{extractors: [ {name: \"AvgSCQ\"} ]}";
    JsonObject json = parser.parse(jsonString).getAsJsonObject();
    String testText = "test document";
    String testQuery = "document";
    //idf = 0.28768
    //tf =1
    float[] expected = { -0.24590f };
    FeatureExtractors chain = FeatureExtractors.fromJson(json);
    assertFeatureValues(expected, testQuery, testText, chain);
}
Also used : FeatureExtractors(io.anserini.ltr.feature.FeatureExtractors) JsonObject(com.google.gson.JsonObject) Test(org.junit.Test)

Example 12 with FeatureExtractors

use of io.anserini.ltr.feature.FeatureExtractors in project Anserini by castorini.

the class FeatureExtractorChainFromJsonTest method testChainSingleExtractorParam.

@Test
public void testChainSingleExtractorParam() throws Exception {
    String jsonString = "{extractors: [ {name: \"BM25Feature\", params: {k1:0.9, b:0.4}} ]}";
    JsonObject json = parser.parse(jsonString).getAsJsonObject();
    String docText = "single document test case";
    String queryText = "test";
    //df, tf =1, avgFL = 4, numDocs = 1
    //idf = log(1 + (0.5 / 1 + 0.5)) = 0.287682
    // 0.287682* 1.9 / (1 + 0.9 * (0.6 + 0.4 * (4/4))) = 1 * 0.287682
    // 0.287682 * 2.25 / (1 + 1.25 *(0.25 + 0.75)) = 0.287682
    float[] expected = { 0.287682f };
    FeatureExtractors chain = FeatureExtractors.fromJson(json);
    assertFeatureValues(expected, queryText, docText, chain);
}
Also used : FeatureExtractors(io.anserini.ltr.feature.FeatureExtractors) JsonObject(com.google.gson.JsonObject) Test(org.junit.Test)

Example 13 with FeatureExtractors

use of io.anserini.ltr.feature.FeatureExtractors in project Anserini by castorini.

the class FeatureExtractorChainFromJsonTest method testMultipleExtractorNoParam.

@Test
public void testMultipleExtractorNoParam() throws Exception {
    String jsonString = "{extractors: [ {name: \"AvgIDF\"}, {name: \"SumTermFrequency\"} ]}";
    JsonObject json = parser.parse(jsonString).getAsJsonObject();
    String docText = "document missing token";
    String queryText = "document test";
    float[] expected = { 0.836985f, 1f };
    FeatureExtractors chain = FeatureExtractors.fromJson(json);
    assertFeatureValues(expected, queryText, docText, chain);
}
Also used : FeatureExtractors(io.anserini.ltr.feature.FeatureExtractors) JsonObject(com.google.gson.JsonObject) Test(org.junit.Test)

Example 14 with FeatureExtractors

use of io.anserini.ltr.feature.FeatureExtractors in project Anserini by castorini.

the class TermFrequencyFeatureExtractorTest method getChain.

private FeatureExtractors getChain() {
    FeatureExtractors chain = new FeatureExtractors();
    chain.add(new TermFrequencyFeatureExtractor());
    return chain;
}
Also used : FeatureExtractors(io.anserini.ltr.feature.FeatureExtractors) TermFrequencyFeatureExtractor(io.anserini.ltr.feature.base.TermFrequencyFeatureExtractor)

Example 15 with FeatureExtractors

use of io.anserini.ltr.feature.FeatureExtractors in project Anserini by castorini.

the class BigramFeaturesTest method getAllPairsUnOrdered.

private FeatureExtractors getAllPairsUnOrdered() {
    FeatureExtractors chain = new FeatureExtractors();
    chain.add(new UnorderedQueryPairsFeatureExtractor(2));
    chain.add(new UnorderedQueryPairsFeatureExtractor(4));
    chain.add(new UnorderedQueryPairsFeatureExtractor(6));
    return chain;
}
Also used : FeatureExtractors(io.anserini.ltr.feature.FeatureExtractors) UnorderedQueryPairsFeatureExtractor(io.anserini.ltr.feature.UnorderedQueryPairsFeatureExtractor)

Aggregations

FeatureExtractors (io.anserini.ltr.feature.FeatureExtractors)18 Test (org.junit.Test)6 JsonObject (com.google.gson.JsonObject)5 RerankerContext (io.anserini.rerank.RerankerContext)4 Qrels (io.anserini.util.Qrels)4 PrintStream (java.io.PrintStream)4 Directory (org.apache.lucene.store.Directory)4 FSDirectory (org.apache.lucene.store.FSDirectory)4 RerankerCascade (io.anserini.rerank.RerankerCascade)3 File (java.io.File)3 FileOutputStream (java.io.FileOutputStream)3 IndexReader (org.apache.lucene.index.IndexReader)3 BM25Similarity (org.apache.lucene.search.similarities.BM25Similarity)3 LMDirichletSimilarity (org.apache.lucene.search.similarities.LMDirichletSimilarity)3 CmdLineException (org.kohsuke.args4j.CmdLineException)3 CmdLineParser (org.kohsuke.args4j.CmdLineParser)3 OrderedSequentialPairsFeatureExtractor (io.anserini.ltr.feature.OrderedSequentialPairsFeatureExtractor)2 UnorderedSequentialPairsFeatureExtractor (io.anserini.ltr.feature.UnorderedSequentialPairsFeatureExtractor)2 Rm3Reranker (io.anserini.rerank.rm3.Rm3Reranker)2 RemoveRetweetsTemporalTiebreakReranker (io.anserini.rerank.twitter.RemoveRetweetsTemporalTiebreakReranker)2