Terrier Users :  Terrier Forum terrier.org
General discussion about using/developing applications using Terrier 
Documents Ranking
Posted by: nadhem7 ()
Date: December 09, 2017 10:29AM

Hi everyone,

I'm trying to rank my documents and i'm facing some difficulties...I'm using the TF_idf weighting model...

Here is my code:

import org.terrier.matching.ResultSet;
import org.terrier.querying.Manager;
import org.terrier.querying.SearchRequest;
import org.terrier.structures.Index;
import org.terrier.utility.ApplicationSetup;

public class DocumentRank {

public static void main(String[] args) {
// TODO Auto-generated method stub

// Configure Terrier
System.setProperty("terrier.home", "/home/nadhem/pfeFinalFinalFinal/terrier-core-4.2"winking smiley;
System.setProperty("terrier.etc", "/home/nadhem/pfeFinalFinalFinal/terrier-core-4.2/etc"winking smiley;
ApplicationSetup.bootstrapInitialisation();
ApplicationSetup.setProperty("indexer.meta.forward.keys", "docno"winking smiley;
ApplicationSetup.setProperty("indexer.meta.forward.keylens", "5000"winking smiley;

Index index = Index.createIndex();


Manager queryingManager = new Manager(index);
SearchRequest srq = queryingManager.newSearchRequestFromQuery("sport"winking smiley;

srq.addMatchingModel("Matching","TF_IDF"winking smiley;

queryingManager.runSearchRequest(srq);

ResultSet results = srq.getResultSet();

System.out.println(results.getExactResultSize()+" documents were scored"winking smiley;
System.out.println("The top "+results.getResultSize()+" of those documents were returned"winking smiley;

for (int i =0; i< results.getResultSize(); i++) {
int[] docid = results.getDocids();
double[] score = results.getScores();
System.out.println(" Rank " + i + " Docid: "+ docid + " Score: "+" "+score);
}


}

}

And I got this result:

364 documents were scored
The top 364 of those documents were returned
Rank 0 Docid: [I@4461c7e3 Score: [D@351d0846
Rank 1 Docid: [I@4461c7e3 Score: [D@351d0846
Rank 2 Docid: [I@4461c7e3 Score: [D@351d0846
Rank 3 Docid: [I@4461c7e3 Score: [D@351d0846
Rank 4 Docid: [I@4461c7e3 Score: [D@351d0846
Rank 5 Docid: [I@4461c7e3 Score: [D@351d0846
Rank 6 Docid: [I@4461c7e3 Score: [D@351d0846
Rank 7 Docid: [I@4461c7e3 Score: [D@351d0846
Rank 8 Docid: [I@4461c7e3 Score: [D@351d0846
Rank 9 Docid: [I@4461c7e3 Score: [D@351d0846
Rank 10 Docid: [I@4461c7e3 Score: [D@351d0846
...

Do you have any idea why docid and score appear in this format (I guess it is an address) and how can I show it as an int.

Any help would be most appreciated.

thanks,
nadhem

Options: ReplyQuote
Re: Documents Ranking
Posted by: nadhem7 ()
Date: December 10, 2017 03:12PM

Hi everyone,

I fixed the problem ... I forgot to put the index to each docid and score.

Have a nice day,
Nadhem...

Options: ReplyQuote


Sorry, only registered users may post in this forum.
This forum powered by Phorum.