public class ContextVector
extends java.lang.Object
implements java.io.Externalizable
Use of this code is free for academic, education, research and other non-profit making uses only.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
ContextVector.Frequency
Holds an externalizable frequency (count).
|
| Modifier and Type | Field and Description |
|---|---|
protected int |
sum |
protected java.util.Map<java.lang.String,ContextVector.Frequency> |
table
Labeled frquencies.
|
| Constructor and Description |
|---|
ContextVector()
Create ContextVector.
|
| Modifier and Type | Method and Description |
|---|---|
static double |
cos(ContextVector a,
ContextVector b)
Compute the cosine of vector a and b
|
static double |
cos(ContextVector a,
ContextVector b,
EntropyVector tf)
Compute the cosine of vector a and b, accounting for term frequency.
|
static int |
dot(ContextVector a,
ContextVector b)
Compute the dot product of vector a and b.
|
static int |
freq(java.lang.String key,
ContextVector vector)
Get the frequency count of key in context vector
|
static int |
inc(java.lang.String key,
int increment,
ContextVector vector)
Increment frequency count of key.
|
static java.lang.String[] |
keys(ContextVector v)
Get the list of context vector keys.
|
void |
readExternal(java.io.ObjectInput in)
Read ContextVector from object file.
|
static int |
sum(ContextVector vector)
Get the sum of frequencies
|
void |
writeExternal(java.io.ObjectOutput out)
Save ContextVector to file as object.
|
protected java.util.Map<java.lang.String,ContextVector.Frequency> table
protected int sum
public static double cos(ContextVector a, ContextVector b)
a - First context vector.b - Second context vector.public static double cos(ContextVector a, ContextVector b, EntropyVector tf)
a - First vector.b - Second vector.tf - Term frequency vector.public static int dot(ContextVector a, ContextVector b)
a - first vector.b - second vector.public static int freq(java.lang.String key,
ContextVector vector)
key - The key.vector - The context vector.public static int inc(java.lang.String key,
int increment,
ContextVector vector)
key - The key.increment - The increment value.vector - The context vector.public static java.lang.String[] keys(ContextVector v)
v - The context vector.public final void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizablein - The object input file.java.io.IOExceptionjava.lang.ClassNotFoundExceptionpublic static int sum(ContextVector vector)
vector - The context vector.public final void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizableout - The object output file.java.io.IOException