Package gnu.trove

Examples of gnu.trove.TIntIntHashMap.adjustOrPutValue()


      // Sample a topic assignment from this distribution
      newTopic = random.nextDiscrete (topicWeights, topicWeightsSum);

      // Put that new topic into the counts
      oneDocTopics[si] = newTopic;
      currentTypeTopicCounts.adjustOrPutValue(newTopic, 1, 1);
      localTopicCounts[newTopic] ++;
      tokensPerTopic[newTopic]++;
    }
  }
 
View Full Code Here


      // Sample a topic assignment from this distribution
      newTopic = random.nextDiscrete (topicWeights, topicWeightsSum);

      // Put that new topic into the counts
      oneDocTopics[si] = newTopic;
      currentTypeTopicCounts.adjustOrPutValue(newTopic, 1, 1);
      localTopicCounts[newTopic] ++;
      tokensPerTopic[newTopic]++;
    }
  }
View Full Code Here

      // Sample a topic assignment from this distribution
      newTopic = random.nextDiscrete (topicWeights, topicWeightsSum);

      // Put that new topic into the counts
      oneDocTopics[si] = newTopic;
      currentTypeTopicCounts.adjustOrPutValue(newTopic, 1, 1);
      tokensPerTopic[newTopic]++;
    }
  }

  //print human readable doc-topic matrix, for further IR use
View Full Code Here

      smoothingOnlyMass -= alpha[newTopic] * beta /
        (tokensPerTopic[newTopic] + betaSum);
      topicBetaMass -= beta * localTopicCounts.get(newTopic) /
        (tokensPerTopic[newTopic] + betaSum);

      localTopicCounts.adjustOrPutValue(newTopic, 1, 1);
      tokensPerTopic[newTopic]++;

      //      update the coefficients for the non-zero topics
      cachedCoefficients[newTopic] =
        (alpha[newTopic] + localTopicCounts.get(newTopic)) /
View Full Code Here

   
    for (Instance instance: instances) {
      FeatureSequence features = (FeatureSequence) instance.getData();
           
      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];
View Full Code Here

      assert (currentTypeTopicCounts.size() != 0);

      if (readjustTopicsAndStats) {
        // Remove this token from all counts
        oneDocTopicCounts[oldTopic]--;
        adjustedValue = currentTypeTopicCounts.adjustOrPutValue(oldTopic, -1, -1);
        if (adjustedValue == 0) currentTypeTopicCounts.remove(oldTopic);
        else if (adjustedValue == -1) throw new IllegalStateException ("Token count in topic went negative.");
        tokensPerTopic[oldTopic]--;
      }
View Full Code Here

    int docLength = tokenSequence.getLength();

    //    populate topic counts
    TIntIntHashMap localTopicCounts = new TIntIntHashMap();
    for (int position = 0; position < docLength; position++) {
      localTopicCounts.adjustOrPutValue(oneDocTopics[position], 1, 1);
    }

    //    Initialize the topic count/beta sampling bucket
    double topicBetaMass = 0.0;
    for (int topic: localTopicCounts.keys()) {
View Full Code Here

      while(ip.next() != IterablePosting.EOL)
      {
        //System.err.println("Got id " + ip.getId());
        assertTrue("Got too big a docid ("+ip.getId()+") from inverted index input stream for term at index " + ithTerm, ip.getId() < numDocs);
        count++;
        calculatedDocLengths.adjustOrPutValue(ip.getId(), ip.getFrequency(), ip.getFrequency());
      }
      assertEquals(expected, count);
    }
    assertEquals("Number of documents is unexpected,", documentLengths.length - countZero(documentLengths), calculatedDocLengths.size());
    long tokens = 0;
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.