GNLP
A few structures for doing NLP analysis / experiments.
Basics
A map-like data structure for representing discrete probability
distributions. Contains an underlying map of event -> probability
along with a probability for all other events. Supports some
element-wise mathematical operations with other counter.Counter
objects.
balls := counter.New(0.0)
balls.Incr("blue")
balls.Incr("blue")
balls.Incr("red")
balls.Normalize()
balls.Get("blue")
balls.Get("purple")
preference = counter.New(0.0)
preference.Set("red", 2.0)
preference.Set("blue", 1.0)
preference.Normalize()
expected_with_preference = counter.Multiply(balls, preference)
expected_with_preference.Normalize()
expected_with_preference.Get("blue")
expected_with_preference.Get("red")
balls.LogNormalize()
preferences.LogNormalize()
balls.Add(preferences)
balls.Exp()
balls.LogNormalize()
balls.Get("blue")
Similar to counter.Counters, but with a fixed set of keys and no
default value. Represented under the hood as an array of doubles (with
order fixed according to the set of keys). Supports element-wise math
operations with other frozencounter.Counters that share the same set
of keys. Some mathematical operations are accelerated by the BLAS
library.
fBalls := frozencounter.Freeze(balls)
fPrefs := frozencounter.Freeze(preference)
fExpectedWithPreference := frozencounter.Multiply(fBalls, fPrefs)