Package org.terrier.matching

Examples of org.terrier.matching.ResultSet


   * Prints the results
   * @param pw PrintWriter the file to write the results to.
   * @param q SearchRequest the search request to get results from.
   */
  public void printResults(PrintWriter pw, SearchRequest q) throws IOException {
    ResultSet set = q.getResultSet();
    int[] docids = set.getDocids();
    double[] scores = set.getScores();
    int minimum = RESULTS_LENGTH;
    //if the minimum number of documents is more than the
    //number of documents in the results, aw.length, then
    //set minimum = aw.length
    if (minimum > set.getResultSize())
      minimum = set.getResultSize();
    if (verbose)
      if(set.getResultSize()>0)
        pw.write("\n\tDisplaying 1-"+set.getResultSize()+ " results\n");
      else
        pw.write("\n\tNo results\n");
    if (set.getResultSize() == 0)
      return;
   
    int metaKeyId = 0; final int metaKeyCount = metaKeys.length;
    String[][] docNames = new String[metaKeyCount][];
    for(String metaIndexDocumentKey : metaKeys)
    {
      if (set.hasMetaItems(metaIndexDocumentKey))
      {
        docNames[metaKeyId] = set.getMetaItems(metaIndexDocumentKey);
      }
      else
      {
        final MetaIndex metaIndex = index.getMetaIndex();
        docNames[metaKeyId] = metaIndex.getItems(metaIndexDocumentKey, docids);
View Full Code Here


   
    private ResultSet MMR(ResultSet sim1set) throws IOException {
           //   MetaIndex meta1=index.getMetaIndex();  
           //     name=meta1.getItem("filename",docid1);   
           //    System.out.println(name);
        ResultSet MMRSet=sim1set.getResultSet(0,3);
           //     FileReader fr=new FileReader(name);
           //     BufferedReader read=new BufferedReader(fr);
           //     document=read.readLine();
           //       System.out.println(document);
        return MMRSet;
View Full Code Here

      }

      mqt.setQuery(q);
      mqt.normaliseTermWeights();
      try{
        ResultSet outRs = matching.match(rq.getQueryID(), mqt);
        //now crop the collectionresultset down to a query result set.
        rq.setResultSet(outRs.getResultSet(0, outRs.getResultSize()));
      } catch (IOException ioe) {
        logger.error("Problem running Matching, returning empty result set as query"+rq.getQueryID(), ioe);
        rq.setResultSet(new QueryResultSet(0));
      }
    }
View Full Code Here

    Request rq = (Request)srq;
    PostFilter[] filters = getPostFilters(rq);
    final int filters_length = filters.length;
   
    //the results to filter
    ResultSet results = rq.getResultSet();

    //the size of the results - this could be more than what we need to display
    int ResultsSize = results.getResultSize();

    //load in the lower and upper bounds of the resultset
    String tmp = rq.getControl("start");/* 0 based */
    if (tmp.length() == 0)
      tmp = "0";
    int Start = Integer.parseInt(tmp);
    tmp = rq.getControl("end");
    if (tmp.length() == 0)
      tmp = "0";
    int End = Integer.parseInt(tmp);/* 0 based */
    if (End == 0)
    {
      End = ResultsSize -1;
    }
    int length = End-Start+1;
    if (length > ResultsSize)
      length = ResultsSize-Start;
    //we've got no filters set, so just give the results ASAP
    if (filters_length == 0)
    {
      rq.setResultSet( results.getResultSet(Start, length) );
      if (logger.isDebugEnabled()) {
        logger.debug("No filters, just Crop: "+Start+", length"+length);
        logger.debug("Resultset is now "+results.getScores().length + " long");
      }
      return;
    }

    //tell all the postfilters that they are processing another query
    for(int i=0;i<filters_length; i++)
    {
      filters[i].new_query(this, srq, results);
    }
   
    int doccount = -1;//doccount is zero-based, so 0 means 1 document
    TIntArrayList docatnumbers = new TIntArrayList();//list of resultset index numbers to keep
    byte docstatus; int thisDocId;
    int[] docids = results.getDocids();
    //int elitesetsize = results.getExactResultSize();
    //the exact result size is the total number of
    //documents that would be retrieved if we
    //didn't do any cropping
    int elitesetsize = results.getResultSize();
    for(int thisdoc = 0; thisdoc < elitesetsize; thisdoc++)
    {
      //run this document through all the filters
      docstatus = PostFilter.FILTER_OK;
      thisDocId = docids[thisdoc];
      //run this doc through the filters
      for(int i=0;i<filters_length; i++)
      {
        if ( ( docstatus = filters[i].filter(this, srq, results, thisdoc, thisDocId) )
          == PostFilter.FILTER_REMOVE
        )
          break;
          //break if the document has to be removed
      }
      //if it's not being removed, then
      if (docstatus != PostFilter.FILTER_REMOVE) //TODO this should always be true
      {
        //success, another real document
        doccount++;
        //check if it's in our results "WINDOW"
        if (doccount >= Start)
        {
          if (doccount <= End)
          {  //add to the list of documents to keep
            docatnumbers.add(thisdoc);
            //System.out.println("Keeping @"+thisdoc);
          }
          else
          {
            //we've now got enough results, break
            break;
          }
        }
      }
      else
      {
        //System.out.println("Removed");
      }
    }
    //since doccount is zero-based, we add one so that it
    //corresponds to the real number of documents.
    doccount++;
    rq.setNumberOfDocumentsAfterFiltering(doccount);
    if (docatnumbers.size() < docids.length)
    {
      //result set is definently shorter, replace with new one
      rq.setResultSet( results.getResultSet(docatnumbers.toNativeArray()));
      rq.getResultSet().setExactResultSize(results.getExactResultSize());
    }
  }
           
        catch(Exception e){}
        }
View Full Code Here

      srq.setControl("qemodel", defaultQEModel);
      srq.setControl("qe", "on");
    }
   
    preQueryingSearchRequestModification(queryId, srq);
    ResultSet rs = resultsCache.checkCache(srq);
    if (rs != null)
      ((Request)rs).setResultSet(rs);
   
   
    //if (logger.isInfoEnabled())
View Full Code Here

       
       return 3;
    }
     public ResultSet getResultSet(ResultSet set1){
    
      ResultSet MMRSet=set1.getResultSet(0,1);
      return MMRSet;
     }
View Full Code Here

     *            SearchRequest the object encapsulating the query and the
     *            results.
     */
    public void printResults(final PrintWriter pw, final SearchRequest q,
        String method, String iteration, int _RESULTS_LENGTH) throws IOException {
      final ResultSet set = q.getResultSet();
      final String metaIndexDocumentKey = ApplicationSetup.getProperty("trec.querying.outputformat.docno.meta.key", "docno");
      final double[] scores = set.getScores();
      if (set.getResultSize() == 0) {
        //logger.warn("No results retrieved for query " + q.getQueryID());
        return;
      }
      String[] docnos = obtainDocnos(metaIndexDocumentKey, q, set);
     
      final int maximum = _RESULTS_LENGTH > set.getResultSize()
          || _RESULTS_LENGTH == 0 ? set.getResultSize()
          : _RESULTS_LENGTH;
      // if the minimum number of documents is more than the
      // number of documents in the results, aw.length, then
      // set minimum = aw.length

View Full Code Here

     *            SearchRequest the object encapsulating the query and the
     *            results.
     */
    public void printResults(final PrintWriter pw, final SearchRequest q,
        String method, String iteration, int _RESULTS_LENGTH) throws IOException {
      final ResultSet set = q.getResultSet();

      final int[] docids = set.getDocids();
      final double[] scores = set.getScores();
      if (set.getResultSize() == 0) {
        //logger.warn("No results retrieved for query " + q.getQueryID());
        return;
      }

      final int maximum = _RESULTS_LENGTH > set.getResultSize()
          || _RESULTS_LENGTH == 0 ? set.getResultSize()
          : _RESULTS_LENGTH;
      // if the minimum number of documents is more than the
      // number of documents in the results, aw.length, then
      // set minimum = aw.length

View Full Code Here

    * @param manager The manager instance handling this search session.
    * @param q the current query being processed
    */
  public void process(Manager manager, SearchRequest q)
  {
    ResultSet rs = q.getResultSet();
    new_query(manager, q, rs);
    if (earlyKeys.size() == 0)
      return;
   
   
    int docids[] = rs.getDocids();
    int resultsetsize = docids.length;
    //logger.info("Early decorating resultset with metadata for " + resultsetsize + " documents");
   
    String[] earlykeys = earlyKeys.toArray(new String[earlyKeys.size()]);
    String[] allKeys = keys.keys(new String[keys.size()]);
    String[][] metadata = getMetadata(allKeys, docids);
    for(String k : earlykeys)
    {
      rs.addMetaItems(k, metadata[keys.get(k)]);
    }
  }
View Full Code Here

       
        }
       
    private ResultSet MMR(ResultSet sim1set) throws IOException {
         MetaIndex meta1=index.getMetaIndex();  
         ResultSet MMRSet=sim1set.getResultSet(0,3);
         name=meta1.getItems("filename", docid);
         System.out.println(" info : names using docid received");
     //    System.out.println("docid at 0th position in MMR func just above for loop "+docid[0]);
         for(int j=0;j<5;j++)
         {
View Full Code Here

TOP

Related Classes of org.terrier.matching.ResultSet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.