Package edu.illinois.lis.document

Examples of edu.illinois.lis.document.FeatureVector


      GQuery query = queryIterator.next();
      System.err.println(query.getTitle());
      String queryText = query.getText();
     
      // stupid hack.  need to lowercase the query vector
      FeatureVector temp = new FeatureVector(null);
      Iterator<String> qTerms = query.getFeatureVector().iterator();
      while(qTerms.hasNext()) {
        String term = qTerms.next();
        temp.addTerm(term.toLowerCase(), query.getFeatureVector().getFeaturetWeight(term));
      }
      temp.normalizeToOne();
      query.setFeatureVector(temp);
     
     
      // if we're doing feedback
      if(fbDocs > 0 && fbTerms > 0) {
        List<TResult> results = client.search(queryText, query.getQuerytweettime(), fbDocs);
        FeedbackRelevanceModel fb = new FeedbackRelevanceModel();
        fb.setOriginalQuery(query);
        fb.setRes(results);
        fb.build(stopper);
       
        FeatureVector fbVector = fb.asFeatureVector();
        fbVector.pruneToSize(fbTerms);
        fbVector.normalizeToOne();
        fbVector = FeatureVector.interpolate(query.getFeatureVector(), fbVector, ORIG_QUERY_WEIGHT);
   
        System.err.println(fbVector);
       
        StringBuilder builder = new StringBuilder();
        Iterator<String> terms = fbVector.iterator();
        while(terms.hasNext()) {
          String term = terms.next();
          if(term.length() < 2)
            continue;
          double prob = fbVector.getFeaturetWeight(term);
          builder.append(term + "^" + prob + " ");
        }
        queryText = builder.toString().trim();
       
      }
View Full Code Here


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();
  }
View Full Code Here

     
      hitIterator = relDocs.iterator();
      while(hitIterator.hasNext()) {
        TResult hit = hitIterator.next();
        String text = hit.getText().toLowerCase();
        FeatureVector docVector = new FeatureVector(text, stopper);
        vocab.addAll(docVector.getFeatures());
        fbDocVectors.add(docVector);
      }

      features = new LinkedList<KeyValuePair>();

     
      Iterator<String> it = vocab.iterator();
      while(it.hasNext()) {
        String term = it.next();       
        double fbWeight = 0.0;

        Iterator<FeatureVector> docIT = fbDocVectors.iterator();
        k=0;
        while(docIT.hasNext()) {
          double docWeight = 1.0;
          if(docWeights != null)
            docWeight = docWeights[k];
          FeatureVector docVector = docIT.next();
          double docProb = docVector.getFeaturetWeight(term) / docVector.getLength();
          docProb *= rsvs[k++] * docWeight;

          fbWeight += docProb;
        }
       
View Full Code Here

  public GQuery asGquery() {
    GQuery newQuery = new GQuery();
    newQuery.setTitle(originalQuery.getTitle());
    newQuery.setText(originalQuery.getText());
   
    FeatureVector finalVector = new FeatureVector(stopper);
   
    ScorableComparator comparator = new ScorableComparator(true);
    Collections.sort(features, comparator);
    Iterator<KeyValuePair> it = features.iterator();
   
    int i=0;
    while(it.hasNext() && i++ < fbTermCount) {     
      KeyValuePair tuple = it.next();
      finalVector.addTerm(tuple.getKey(), tuple.getScore());
    }
   
    newQuery.setFeatureVector(finalVector);
   
    return newQuery;
View Full Code Here

   
    return newQuery;
  }

  public FeatureVector asFeatureVector() {
    FeatureVector f = new FeatureVector(stopper);
    Iterator<KeyValuePair> it = features.iterator();
   
    while(it.hasNext()) {     
      KeyValuePair tuple = it.next();
      f.addTerm(tuple.getKey(), tuple.getScore());
   
   
    return f;
  }
View Full Code Here

      String title = queryObject.get("title").getAsString();
      String text  = queryObject.get("text").getAsString();
      double epoch = queryObject.get("epoch").getAsDouble();
      long querytweettime = queryObject.get("querytweettime").getAsLong();
      nameToIndex.put(title, k++);
      FeatureVector featureVector = new FeatureVector(null);
      JsonArray modelObjectArray = queryObject.getAsJsonArray("model");
      Iterator<JsonElement> featureIterator = modelObjectArray.iterator();
      while(featureIterator.hasNext()) {
        JsonObject featureObject = (JsonObject)featureIterator.next();
        double weight  = featureObject.get("weight").getAsDouble();
        String feature = featureObject.get("feature").getAsString();
        featureVector.addTerm(feature, weight);
      }
     
     
      GQuery gQuery = new GQuery();
      gQuery.setTitle(title);
View Full Code Here

    return null;
  }
 
  public FeatureVector getDocVector(String docId) {
    if(seenDocs.containsKey(docId))
      return new FeatureVector(seenDocs.get(docId), null);

    // we should also be able to ping the API to get docs we haven't already seen
    return null;
  }
View Full Code Here

TOP

Related Classes of edu.illinois.lis.document.FeatureVector

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.