Guava Multiset - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava Multiset class.

This code example shows how to use the following methods:count, elementSet, size
  @Override 
  protected double weight(byte[] originalForm) {
    // the counts here are adjusted so that every observed value has an extra 0.5 count 
    // as does a hypothetical unobserved value.  This smooths our estimates a bit and 
    // allows the first word seen to have a non-zero weight of -log(1.5 / 2) 
    double thisWord = dictionary.count(new String(originalForm, Charsets.UTF_8)) + 0.5;
    double allWords = dictionary.size() + dictionary.elementSet().size() * 0.5 + 0.5;
    return -Math.log(thisWord / allWords);
  } 
 
  public Multiset<String> getDictionary() {
    return dictionary;
  } 
} 
7
CodeRank
This code example shows how to use the following methods:elementSet
This code example shows how to use the following methods:count
    calls.add("getUser");
    return User.ANONYMOUS;
  } 
 
  public Integer getCallCount(String method) {
    return calls.count(method);
  } 
} 
5
CodeRank
This code example shows how to use the following methods:elementSet
This code example shows how to use the following methods:add, elementSet
        probDist.total = probDist.counts.elementSet().size();
        return probDist;
    } 
 
    public void add(T event) {
        counts.add(event);
        total = counts.elementSet().size();
    } 
 
    public void add(T event, int i) {
        counts.add(event, i);
        total = counts.elementSet().size();
    } 
 
    public void addAll(Collection<T> events) {
        counts.addAll(events);
        total = counts.elementSet().size();
    } 
 
    public int count(T event) {
5
CodeRank
This code example shows how to use the following methods:elementSet
This code example shows how to use the following methods:count
  public Collection<Rule> rules() {
    return rules.elementSet();
  } 
 
  public int countRule(Rule rule) {
    return rules.count(rule);
  } 
 
  public static class Rule { 
 
    private RuleKey ruleKey;
    private String name;
 
    public Rule(RuleKey ruleKey, String name) {
      this.ruleKey = ruleKey;
      this.name = name;
    } 
 
    public RuleKey ruleKey() { 
      return ruleKey;
4
CodeRank
This code example shows how to use the following methods:count
   */ 
  public int getCount(T actual, T predicted) {
    if (!matrix.containsKey(actual)) {
      return 0; 
    } else { 
      return matrix.get(actual).count(predicted);
    } 
  } 
 
  /** 
   * Computes the total number of times the class was predicted by the classifier. 
   */ 
  public int getPredictedTotal(T predicted) {
    int total = 0;
    for (T actual : classes) {
      total += getCount(actual, predicted);
    } 
    return total;
  } 
 
3
CodeRank
This code example shows how to use the following methods:count
   */ 
  public int getCount(T actual, T predicted) {
    if (!matrix.containsKey(actual)) {
      return 0; 
    } else { 
      return matrix.get(actual).count(predicted);
    } 
  } 
 
  /** 
   * Computes the total number of times the class was predicted by the classifier. 
   */ 
  public int getPredictedTotal(T predicted) {
    int total = 0;
    for (T actual : classes) {
      total += getCount(actual, predicted);
    } 
    return total;
  } 
 
4
CodeRank
This code example shows how to use the following methods:elementSet
See Code Examples for Guava Multiset Methods: