org.apache.mahout.utils.nlp.collocations.llr
Class Gram
java.lang.Object
org.apache.hadoop.io.BinaryComparable
org.apache.mahout.utils.nlp.collocations.llr.Gram
- All Implemented Interfaces:
- java.lang.Comparable<org.apache.hadoop.io.BinaryComparable>, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable<org.apache.hadoop.io.BinaryComparable>
public class Gram
- extends org.apache.hadoop.io.BinaryComparable
- implements org.apache.hadoop.io.WritableComparable<org.apache.hadoop.io.BinaryComparable>
Writable for holding data generated from the collocation discovery jobs. Depending on the job configuration
gram may be one or more words. In some contexts this is used to hold a complete ngram, while in others it
holds a part of an existing ngram (subgram). Tracks the frequency of the gram and its position in the ngram
in which is was found.
Constructor Summary |
Gram()
|
Gram(Gram other)
Copy constructor |
Gram(java.lang.String ngram,
Gram.Type type)
Create an gram with a frequency of 1 |
Gram(java.lang.String ngram,
int frequency,
Gram.Type type)
Create a gram with the specified frequency. |
Methods inherited from class org.apache.hadoop.io.BinaryComparable |
compareTo, compareTo, equals, hashCode |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.lang.Comparable |
compareTo |
Gram
public Gram()
Gram
public Gram(Gram other)
- Copy constructor
- Parameters:
other
-
Gram
public Gram(java.lang.String ngram,
Gram.Type type)
- Create an gram with a frequency of 1
- Parameters:
ngram
- the gram stringtype
- whether the gram is at the head or tail of its text unit or it is a unigram
Gram
public Gram(java.lang.String ngram,
int frequency,
Gram.Type type)
- Create a gram with the specified frequency.
- Parameters:
ngram
- the gram stringfrequency
- the gram frequencytype
- whether the gram is at the head of its text unit or tail or unigram
getBytes
public byte[] getBytes()
- Specified by:
getBytes
in class org.apache.hadoop.io.BinaryComparable
getLength
public int getLength()
- Specified by:
getLength
in class org.apache.hadoop.io.BinaryComparable
getType
public Gram.Type getType()
- Returns:
- the gram is at the head of its text unit or tail or unigram.
getString
public java.lang.String getString()
- Returns:
- gram term string
getFrequency
public int getFrequency()
- Returns:
- gram frequency
setFrequency
public void setFrequency(int frequency)
- Parameters:
frequency
- gram's frequency
incrementFrequency
public void incrementFrequency(int i)
readFields
public void readFields(java.io.DataInput in)
throws java.io.IOException
- Specified by:
readFields
in interface org.apache.hadoop.io.Writable
- Throws:
java.io.IOException
write
public void write(java.io.DataOutput out)
throws java.io.IOException
- Specified by:
write
in interface org.apache.hadoop.io.Writable
- Throws:
java.io.IOException
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
encodeType
public static void encodeType(Gram.Type type,
byte[] buf,
int offset)
decodeType
public static Gram.Type decodeType(byte[] buf,
int offset)
Copyright © 2008-2010 The Apache Software Foundation. All Rights Reserved.