Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to use Jelinek-Mercer QL scoring model #465

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/io/anserini/ltr/DumpTweetsLtrData.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static<K> void main(String[] argv) throws Exception {
IndexReader reader = DirectoryReader.open(dir);
IndexSearcher searcher = new IndexSearcher(reader);

if (args.ql) {
if (args.ql || args.qld) {
LOG.info("Using QL scoring model");
searcher.setSimilarity(new LMDirichletSimilarity(args.mu));
} else if (args.bm25) {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/io/anserini/search/SearchArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public class SearchArgs {
@Option(name = "-ql", usage = "use query likelihood scoring model")
public boolean ql = false;

@Option(name = "-qld", usage = "use Dirichlet query likelihood scoring model")
public boolean qld = false;

@Option(name = "-mu", metaVar = "[value]", usage = "Dirichlet smoothing parameter")
public float mu = 1000.0f;
/*
Expand Down Expand Up @@ -186,4 +189,11 @@ public class SearchArgs {

@Option(name = "-model", metaVar = "[file]", required = false, usage = "ranklib model file")
public String model = "";

@Option(name = "-qljm", usage = "use Jelinek-Mercer query likelihood scoring model")
public boolean qljm = false;

@Option(name = "-qljm.lambda", metaVar = "[value]", usage = "Jelinek Mercer smoothing parameter")
public float qljm_lambda = 0.1f;

}
5 changes: 4 additions & 1 deletion src/main/java/io/anserini/search/SearchCollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public SearchCollection(SearchArgs args) throws IOException {
this.reader = DirectoryReader.open(FSDirectory.open(indexPath));

// Figure out which scoring model to use.
if (args.ql) {
if (args.ql || args.qld) {
LOG.info("Using QL scoring model");
this.similarity = new LMDirichletSimilarity(args.mu);
} else if (args.bm25) {
Expand All @@ -122,6 +122,9 @@ public SearchCollection(SearchArgs args) throws IOException {
} else if (args.f2log) {
LOG.info("Using F2Log scoring model");
this.similarity = new F2LogSimilarity(args.f2log_s);
} else if (args.qljm) {
LOG.info("Using Jelinek-Mercer QL scoring model");
this.similarity = new LMJelinekMercerSimilarity(args.qljm_lambda);
} else {
throw new IllegalArgumentException("Error: Must specify scoring model!");
}
Expand Down