Examples of HMapIF


Examples of edu.umd.cloud9.util.map.HMapIF

  public static HMapIF loadCf(RetrievalEnvironment env, HMapIV<String> parsedQueries)
    throws Exception {
    Preconditions.checkNotNull(env);
    Preconditions.checkNotNull(parsedQueries);

    HMapIF cfs = new HMapIF();

    for(int qid: parsedQueries.keySet()) {
      String[] tokens = env.tokenize(parsedQueries.get(qid));

      if(tokens == null) {
        continue;
      }

      for(String term: tokens) {
        float cf = (float) env.collectionFrequency(term);
        cfs.put(env.getIdFromTerm(term), cf);
      }
    }

    return cfs;
  }
View Full Code Here

Examples of edu.umd.cloud9.util.map.HMapIF

  public static HMapIF loadIdf(RetrievalEnvironment env, String  queryPath)
      throws Exception {
    Preconditions.checkNotNull(env);
    Preconditions.checkNotNull(queryPath);

    HMapIF idfs = new HMapIF();
    HMapIV<String> parsedQueries = QueryUtility.loadQueries(Files.newInputStreamSupplier(new File(queryPath)));

    for(int qid: parsedQueries.keySet()) {
      String[] tokens = env.tokenize(parsedQueries.get(qid));

      if(tokens == null) {
        continue;
      }

      for(String term: tokens) {
        float idf = (float) Math.log((env.getDocumentCount() - env.documentFrequency(term) + 0.5f) /
            (env.documentFrequency(term) + 0.5f));
        idfs.put(env.getIdFromTerm(term), idf);
      }
    }

    return idfs;
  }
View Full Code Here

Examples of edu.umd.cloud9.util.map.HMapIF

    DocumentVectorSlidingWindow generator = new DocumentVectorSlidingWindow(env, fs);

    //Parse queries, judgemnts and features
    HMapIV<String> parsedQueries = QueryUtility.loadQueries(queryPath);
    HMapIV<int[]> queries = QueryUtility.queryToIntegerCode(env, parsedQueries);
    HMapIF idfs = QueryUtility.loadIdf(env, parsedQueries);
    HMapIF cfs = QueryUtility.loadCf(env, parsedQueries);
    HMapIV<int[]> qrels = QrelUtility.parseQrelsFromTabDelimited(qrelPath);
    Map<String, Feature> featuresMap = FeatureUtility.parseFeatures(featurePath);
    Feature[] features = new Feature[featuresMap.size()];
    int index = 0;
    for(String key: featuresMap.keySet()) {
View Full Code Here

Examples of edu.umd.cloud9.util.map.HMapIF


  public static void addToTable(int curIndex, TreeSet<PairOfFloatString> topTrans, float cumProb, TTable_monolithic_IFAs table,
      Vocab trgVocab, float cumProbThreshold, HookaStats stats) {
    List<Integer> sortedIndices = new ArrayList<Integer>();
    HMapIF index2ProbMap = new HMapIF();

    float sumOfProbs = 0.0f;    //only extract the top K<15 if the mass prob. exceeds MAX_probThreshold
    while(!topTrans.isEmpty() && sumOfProbs < cumProbThreshold){
      PairOfFloatString e = topTrans.pollLast();
      String term = e.getRightElement();
      float pr = e.getLeftElement()/cumProb;    // normalize
      logger.debug(term+"-->"+pr);
      int trgIndex = trgVocab.addOrGet(term);
      sumOfProbs += e.getLeftElement();         // keep track of unnormalized cumulative prob for determining cutoff
      sortedIndices.add(trgIndex);
      index2ProbMap.put(trgIndex, pr);
    }

    // to enable faster access with binary search, we sort entries by vocabulary index.
    Collections.sort(sortedIndices);
    int numEntries = sortedIndices.size();

    // for statistics only
    stats.update(numEntries, sumOfProbs);

    // write translation list to TTable object
    int[] indices = new int[numEntries];
    float[] probs = new float[numEntries];
    int i=0;
    for(int sortedIndex : sortedIndices){
      indices[i]=sortedIndex;
      probs[i]=index2ProbMap.get(sortedIndex);
      i++;
    }     
    table.set(curIndex, new IndexedFloatArray(indices, probs, true));
  }
View Full Code Here

Examples of edu.umd.cloud9.util.map.HMapIF

    DocumentVectorOnTheFlyIndexing generator = new DocumentVectorOnTheFlyIndexing(env, fs);

    //Parse queries, judgemnts and features
    HMapIV<String> parsedQueries = QueryUtility.loadQueries(queryPath);
    HMapIV<int[]> queries = QueryUtility.queryToIntegerCode(env, parsedQueries);
    HMapIF idfs = QueryUtility.loadIdf(env, parsedQueries);
    HMapIF cfs = QueryUtility.loadCf(env, parsedQueries);
    HMapIV<int[]> qrels = QrelUtility.parseQrelsFromTabDelimited(qrelPath);
    Map<String, Feature> featuresMap = FeatureUtility.parseFeatures(featurePath);
    Feature[] features = new Feature[featuresMap.size()];
    int index = 0;
    for(String key: featuresMap.keySet()) {
View Full Code Here

Examples of edu.umd.cloud9.util.map.HMapIF

  public static HMapIF loadIdf(RetrievalEnvironment env, String  queryPath)
      throws Exception {
    Preconditions.checkNotNull(env);
    Preconditions.checkNotNull(queryPath);

    HMapIF idfs = new HMapIF();
    HMapIV<String> parsedQueries = QueryUtility.loadQueries(Files.newInputStreamSupplier(new File(queryPath)));

    for(int qid: parsedQueries.keySet()) {
      String[] tokens = env.tokenize(parsedQueries.get(qid));

      if(tokens == null) {
        continue;
      }

      for(String term: tokens) {
        float idf = (float) Math.log((env.getDocumentCount() - env.documentFrequency(term) + 0.5f) /
            (env.documentFrequency(term) + 0.5f));
        idfs.put(env.getIdFromTerm(term), idf);
      }
    }

    return idfs;
  }
View Full Code Here

Examples of edu.umd.cloud9.util.map.HMapIF

  public static HMapIF loadIdf(RetrievalEnvironment env, HMapIV<String> parsedQueries)
    throws Exception {
    Preconditions.checkNotNull(env);
    Preconditions.checkNotNull(parsedQueries);

    HMapIF idfs = new HMapIF();

    for(int qid: parsedQueries.keySet()) {
      String[] tokens = env.tokenize(parsedQueries.get(qid));

      if(tokens == null) {
        continue;
      }

      for(String term: tokens) {
        float idf = (float) Math.log((env.getDocumentCount() - env.documentFrequency(term) + 0.5f) /
                                     (env.documentFrequency(term) + 0.5f));
        idfs.put(env.getIdFromTerm(term), idf);
      }
    }

    return idfs;
  }
View Full Code Here

Examples of edu.umd.cloud9.util.map.HMapIF

  public static HMapIF loadCf(RetrievalEnvironment env, String  queryPath)
    throws Exception {
    Preconditions.checkNotNull(env);
    Preconditions.checkNotNull(queryPath);

    HMapIF cfs = new HMapIF();
    HMapIV<String> parsedQueries = QueryUtility.loadQueries(Files.newInputStreamSupplier(new File(queryPath)));

    for(int qid: parsedQueries.keySet()) {
      String[] tokens = env.tokenize(parsedQueries.get(qid));

      if(tokens == null) {
        continue;
      }

      for(String term: tokens) {
        float cf = (float) env.collectionFrequency(term);
        cfs.put(env.getIdFromTerm(term), cf);
      }
    }

    return cfs;
  }
View Full Code Here

Examples of edu.umd.cloud9.util.map.HMapIF

  public static HMapIF loadCf(RetrievalEnvironment env, HMapIV<String> parsedQueries)
    throws Exception {
    Preconditions.checkNotNull(env);
    Preconditions.checkNotNull(parsedQueries);

    HMapIF cfs = new HMapIF();

    for(int qid: parsedQueries.keySet()) {
      String[] tokens = env.tokenize(parsedQueries.get(qid));

      if(tokens == null) {
        continue;
      }

      for(String term: tokens) {
        float cf = (float) env.collectionFrequency(term);
        cfs.put(env.getIdFromTerm(term), cf);
      }
    }

    return cfs;
  }
View Full Code Here

Examples of edu.umd.cloud9.util.map.HMapIF

    RankAndFeaturesSmallAdaptive generator = new RankAndFeaturesSmallAdaptive(env, fs);

    //Parse queries and find integer codes for the query terms.
    HMapIV<String> parsedQueries = QueryUtility.loadQueries(queryPath);
    HMapIV<int[]> queries = QueryUtility.queryToIntegerCode(env, parsedQueries);
    HMapIF idfs = QueryUtility.loadIdf(env, parsedQueries);
    HMapIF cfs = QueryUtility.loadCf(env, parsedQueries);
    HMapIV<int[]> qrels = QrelUtility.parseQrelsFromTabDelimited(qrelPath);
    Map<String, Feature> featuresMap = FeatureUtility.parseFeatures(featurePath);
    Feature[] features = new Feature[featuresMap.size()];
    int index = 0;
    for(String key: featuresMap.keySet()) {
View Full Code Here
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.