Package edu.illinois.lis.utils

Source Code of edu.illinois.lis.utils.LuceneQuery

package edu.illinois.lis.utils;

import java.util.Iterator;

import edu.illinois.lis.document.FeatureVector;
import edu.illinois.lis.query.GQuery;

public class LuceneQuery {
  public static String gQueryToLucene(GQuery gQuery, int k) {
    FeatureVector mainVector = new FeatureVector(gQuery.getText(), null);
    mainVector.normalizeToOne();
    FeatureVector fbVector = gQuery.getFeatureVector();
    fbVector.pruneToSize(k);
    fbVector.normalizeToOne();
    FeatureVector finalVector = FeatureVector.interpolate(mainVector, fbVector, 0.5);
    StringBuilder b = new StringBuilder();
    Iterator<String> terms = finalVector.iterator();
    while(terms.hasNext()) {
      String term = terms.next();
      double weight = finalVector.getFeaturetWeight(term);
      b.append(term + "^" + weight + " ");
    }
    return b.toString().trim();
  }
}
TOP

Related Classes of edu.illinois.lis.utils.LuceneQuery

TOP
Copyright © 2018 www.massapi.com. 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.