Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.stanford.nlp.stats
Class AbstractCounter<E>

    java.lang.Object
      edu.stanford.nlp.stats.AbstractCounter<E>

All Implemented Interfaces:
  Counter<E>

Direct Known Subclasses:
  IntCounter

    public abstract class AbstractCounter<E>

extends Object
implements Counter<E>

Default implementations of all the convenience methods provided by `Counter`.

Author:
  dramage

Constructor Summary
`AbstractCounter()`

Method Summary
`void` | `addAll(Counter<E> counter)` Adds the counts in the given Counter to the counts in this Counter.
`double` | `decrementCount(E key)` Decrements the count for this key by 1.0.
`double` | `decrementCount(E key, double amount)` Decrements the count for this key by the given value.
`double` | `incrementCount(E key)` Increments the count for this key by 1.0.
`double` | `incrementCount(E key, double amount)` Increments the count for the given key by the given value.
`double` | `logIncrementCount(E key, double amount)` Increments the count stored in log space for this key by the given log-transformed value.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface edu.stanford.nlp.stats.Counter
`clear, containsKey, defaultReturnValue, entrySet, getCount, getFactory, keySet, remove, setCount, setDefaultReturnValue, size, totalCount, values`

Constructor Detail

### AbstractCounter

    public AbstractCounter()

Method Detail

### logIncrementCount

    public double logIncrementCount(E key,
                                    double amount)

  Description copied from interface: `Counter`
  Increments the count stored in log space for this key by the given log-transformed value. If the current count for the key is v1, and you call logIncrementCount with a value of v2, then the new value will be log(e^v1 + e^v2). If the key hasn't been seen before, it is assumed to have count Double.NEGATIVE_INFINITY, and thus this method will set its count to the given amount. Note that this is true regardless of the setting of defaultReturnValue. To set a count to a specifc value instead of incrementing it, you need to first take the log yourself and then to call `Counter.setCount(Object,double)`.

  Specified by:
    `logIncrementCount` in interface `Counter<E>`
  Parameters:
    `key` - The key to increment
    `amount` - The amount to increment it by, in log space
  Returns:
    The value associated with they key, post-increment, in log space

### incrementCount

    public double incrementCount(E key,
                                 double amount)

  Description copied from interface: `Counter`
  Increments the count for the given key by the given value. If the key hasn't been seen before, it is assumed to have count 0.0, and thus this method will set its count to the given amount. Note that this is true regardless of the setting of defaultReturnValue. Negative increments are equivalent to calling `decrementCount`. To more conveniently increment the count by 1.0, use `Counter.incrementCount(Object)`. To set a count to a specifc value instead of incrementing it, use `Counter.setCount(Object,double)`.

  Specified by:
    `incrementCount` in interface `Counter<E>`
  Parameters:
    `key` - The key to increment
    `amount` - The amount to increment it by
  Returns:
    The value associated with they key, post-increment.

### incrementCount

    public double incrementCount(E key)

  Description copied from interface: `Counter`
  Increments the count for this key by 1.0. If the key hasn't been seen before, it is assumed to have count 0.0, and thus this method will set its count to 1.0. Note that this is true regardless of the setting of defaultReturnValue. To increment the count by a value other than 1.0, use `Counter.incrementCount(Object,double)`. To set a count to a specifc value instead of incrementing it, use `Counter.setCount(Object,double)`.

  Specified by:
    `incrementCount` in interface `Counter<E>`
  Parameters:
    `key` - The key to increment by 1.0
  Returns:
    The value associated with they key, post-increment.

### decrementCount

    public double decrementCount(E key,
                                 double amount)

  Description copied from interface: `Counter`
  Decrements the count for this key by the given value. If the key hasn't been seen before, it is assumed to have count 0.0, and thus this method will set its count to the negative of the given amount. Note that this is true regardless of the setting of defaultReturnValue. Negative increments are equivalent to calling `incrementCount`. To more conviently decrement the count by 1.0, use `Counter.decrementCount(Object)`. To set a count to a specifc value instead of decrementing it, use `Counter.setCount(Object,double)`.

  Specified by:
    `decrementCount` in interface `Counter<E>`
  Parameters:
    `key` - The key to decrement
    `amount` - The amount to decrement it by
  Returns:
    The value associated with they key, post-decrement.

### decrementCount

    public double decrementCount(E key)

  Description copied from interface: `Counter`
  Decrements the count for this key by 1.0. If the key hasn't been seen before, it is assumed to have count 0.0, and thus this method will set its count to -1.0. Note that this is true regardless of the setting of defaultReturnValue. To decrement the count by a value other than 1.0, use `Counter.decrementCount(Object,double)`. To set a count to a specifc value instead of decrementing it, use `Counter.setCount(Object,double)`.

  Specified by:
    `decrementCount` in interface `Counter<E>`
  Parameters:
    `key` - The key to decrement by 1.0
  Returns:
    The value of associated with they key, post-decrement.

### addAll

    public void addAll(Counter<E> counter)

  Adds the counts in the given Counter to the counts in this Counter. This is identical in effect to calling Counters.addInPlace(this, counter).

  Specified by:
    `addAll` in interface `Counter<E>`
  Parameters:
    `counter` - The Counter whose counts will be added. For each key in counter, if it is not in this, then it will be added with value `counter.getCount(key)`. Otherwise, it will have value `this.getCount(key) + counter.getCount(key)`.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Stanford NLP Group