Examples of TermFreqVector


Examples of uk.ac.ucl.panda.utility.structure.TermFreqVector

  }

  // Pearson's product-moment coefficient
  private double correlation(int a, int b) throws IOException {
    double score = 0;
    TermFreqVector doc_a = reader.getTermFreqVector(a, docDataField);
    // /////////////
    // if( doc_a==null) System.out.println("doc_a is null");
    // /////////////
    TermFreqVector doc_b = reader.getTermFreqVector(b, docDataField);

    // stroe all the term freq in hashmap
    HashMap term_map = new HashMap();
    HashMap map_a = new HashMap();
    String terms[] = doc_a.getTerms();
    int freq[] = doc_a.getTermFrequencies();
    double ave_a = 0;
    for (int i = 0; i < terms.length; i++) {
      map_a.put(terms[i], freq[i]);
      term_map.put(terms[i], terms[i]);
      ave_a += freq[i];
    }
    ave_a = ave_a / terms.length;

    double ave_b = 0;
    HashMap map_b = new HashMap();
    terms = doc_b.getTerms();
    freq = doc_b.getTermFrequencies();
    for (int i = 0; i < terms.length; i++) {
      map_b.put(terms[i], freq[i]);
      term_map.put(terms[i], terms[i]);
      ave_b += freq[i];
    }
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.