Package org.terrier.matching

Examples of org.terrier.matching.MatchingQueryTerms


    }
    setQueryExpansionModel(getQueryExpansionModel(qeModel));
    if(logger.isInfoEnabled()){
      //logger.info("query expansion model: " + QEModel.getInfo());
    }
    MatchingQueryTerms queryTerms = ((Request)q).getMatchingQueryTerms();
    if (queryTerms == null)
    {
      //logger.warn("No query terms for this query. Skipping QE");
      return;
    }
    // get the expanded query terms
    try{
      expandQuery(queryTerms, (Request)q);
    } catch (IOException ioe) {
      logger.error("IOException while expanding query, skipping QE", ioe);
      return;
    }
    if(logger.isInfoEnabled()){
      //logger.info("query length after expansion: " + queryTerms.length());
      //logger.info("Expanded query: ");
    }
    final String[] newQueryTerms = queryTerms.getTerms();
    StringBuilder newQuery = new StringBuilder();
    for (int i = 0; i < newQueryTerms.length; i++){
      try{
        if(logger.isInfoEnabled()){
          //logger.info((i + 1) + ": " + newQueryTerms[i] +
//            ", normalisedFrequency: " + Rounding.toString(queryTerms.getTermWeight(newQueryTerms[i]), 4));
        }
        newQuery.append(newQueryTerms[i]);
        newQuery.append('^');
        newQuery.append(Rounding.toString(queryTerms.getTermWeight(newQueryTerms[i]), 9));
        newQuery.append(' ');
      }
      catch(NullPointerException npe){
        logger.fatal("Nullpointer exception occured in Query Expansion dumping of new Query", npe);
      }
View Full Code Here


      query.getTermsOf(org.terrier.querying.parser.SingleTermQuery.class, terms, true);
      for(Query sqt : terms)
        ((org.terrier.querying.parser.SingleTermQuery)sqt).setRequired(0);
    }

    MatchingQueryTerms queryTerms = new MatchingQueryTerms(rq.getQueryID(), rq);
   
    query.obtainQueryTerms(queryTerms);
    rq.setMatchingQueryTerms(queryTerms);
                  }
                catch(Exception e){
View Full Code Here

      Matching matching = getMatchingModel(rq);
     
      if (logger.isDebugEnabled()){
        logger.debug("weighting model: " + wmodel.getInfo());
      }
      MatchingQueryTerms mqt = rq.getMatchingQueryTerms();
      mqt.setDefaultTermWeightingModel((WeightingModel)wmodel);
      Query q = rq.getQuery();
     
      /* now propagate fields into requirements, and apply boolean matching
         for the decorated terms. */
      ArrayList<Query> requirement_list = new ArrayList<Query>();
      ArrayList<Query> field_list = new ArrayList<Query>();
     
      q.getTermsOf(RequirementQuery.class, requirement_list, true);
      q.getTermsOf(FieldQuery.class, field_list, true);
                     //  System.out.println(requirement_list);
                      //  System.out.println(field_list);
      for (int i=0; i<field_list.size(); i++)
        if (!requirement_list.contains(field_list.get(i)))
          requirement_list.add(field_list.get(i));
                                           
                       //     System.out.println(requirement_list);
                      //  System.out.println(field_list);
      /*if (logger.isDebugEnabled())
      {
        for (int i=0; i<requirement_list.size(); i++) {
          if(logger.isDebugEnabled()){
          logger.debug("requirement: " + ((RequiredTermModifier)requirement_list.get(i)).getName());
          }
        }
        for (int i=0; i<field_list.size(); i++) {
          if(logger.isDebugEnabled()){
          logger.debug("field: " + ((TermInFieldModifier)field_list.get(i)).getName());
          }
        }
      }*/
   
      if (requirement_list.size()>0) {
        mqt.addDocumentScoreModifier(new BooleanScoreModifier(requirement_list));
      }

      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) {
View Full Code Here

TOP

Related Classes of org.terrier.matching.MatchingQueryTerms

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.