Package gnu.trove

Examples of gnu.trove.TIntIntHashMap.keys()


        if (sample < topicBetaMass) {
          //betaTopicCount++;

          sample /= beta;

          topicTermIndices = localTopicCounts.keys();
          topicTermValues = localTopicCounts.getValues();

          for (i=0; i < topicTermIndices.length; i++) {
            newTopic = topicTermIndices[i];
View Full Code Here


    }

    //    Clean up our mess: reset the coefficients to values with only
    //    smoothing. The next doc will update its own non-zero topics...
    for (int topic: localTopicCounts.keys()) {
      cachedCoefficients[topic] =
        alpha[topic] / (tokensPerTopic[topic] + betaSum);
    }

    if (shouldSaveState) {
View Full Code Here

    if (shouldSaveState) {
      //      Update the document-topic count histogram,
      //      for dirichlet estimation
      docLengthCounts[ docLength ]++;
      for (int topic: localTopicCounts.keys()) {
        topicDocCounts[topic][ localTopicCounts.get(topic) ]++;
      }
    }
  }
View Full Code Here

           
      for (int i=0; i<features.getLength(); i++) {
        docCounts.adjustOrPutValue(features.getIndexAtPosition(i), 1, 1);
      }
           
      int[] keys = docCounts.keys();
      for (int i = 0; i < keys.length - 1; i++) {
        int feature = keys[i];
        result[feature][0] += docCounts.get(feature);
        result[feature][1]++;
      }
View Full Code Here

        else if (adjustedValue == -1) throw new IllegalStateException ("Token count in topic went negative.");
        tokensPerTopic[oldTopic]--;
      }

      // Build a distribution over topics for this token
      topicIndices = currentTypeTopicCounts.keys();
      topicCounts = currentTypeTopicCounts.getValues();
      topicDistribution = new double[topicIndices.length];
      // TODO Yipes, memory allocation in the inner loop!  But note that .keys and .getValues is doing this too.
      topicDistributionSum = 0;
      for (int i = 0; i < topicCounts.length; i++) {
View Full Code Here

      localTopicCounts.adjustOrPutValue(oneDocTopics[position], 1, 1);
    }

    //    Initialize the topic count/beta sampling bucket
    double topicBetaMass = 0.0;
    for (int topic: localTopicCounts.keys()) {
      int n = localTopicCounts.get(topic);

      //      initialize the normalization constant for the (B * n_{t|d}) term
      topicBetaMass += beta * n /  (tokensPerTopic[topic] + betaSum)

View Full Code Here

      }
      assertEquals(expected, count);
    }
    assertEquals("Number of documents is unexpected,", documentLengths.length - countZero(documentLengths), calculatedDocLengths.size());
    long tokens = 0;
    for(int docid : calculatedDocLengths.keys())
    {
      assertEquals("Document length for docid "+docid+" is unexpected,", documentLengths[docid], calculatedDocLengths.get(docid));
      tokens += calculatedDocLengths.get(docid);
    }
    assertEquals("Number of tokens is unexpected,", StaTools.sum(documentLengths), tokens);
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.