Package cc.mallet.types

Examples of cc.mallet.types.FeatureCounter


  //print topic-word matrix, for further IR use
  public void printPhi(File f, double threshold) throws IOException{
    PrintWriter pw = new PrintWriter(new FileWriter(f));
    FeatureCounter[] wordCountsPerTopic = new FeatureCounter[numTopics];
    for (int ti = 0; ti < numTopics; ti++) {
      wordCountsPerTopic[ti] = new FeatureCounter(alphabet);
    }

    for (int fi = 0; fi < numTypes; fi++) {
      int[] topics = typeTopicCounts[fi].keys();
      for (int i = 0; i < topics.length; i++) {
        wordCountsPerTopic[topics[i]].increment(fi, typeTopicCounts[fi].get(topics[i]));
      }
    }
   
    for(int ti = 0; ti < numTopics; ti++){
      pw.println("Topic\t" + ti);
      FeatureCounter counter = wordCountsPerTopic[ti];
      FeatureVector fv = counter.toFeatureVector();
      for(int pos = 0; pos < fv.numLocations(); pos++){
        int fi = fv.indexAtLocation(pos);
        String word = (String) alphabet.lookupObject(fi);
        int count = (int) fv.valueAtLocation(pos);
        double prob;
View Full Code Here

TOP

Related Classes of cc.mallet.types.FeatureCounter

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.