Package org.terrier.structures
Class SimpleNgramEntryStatistics
- java.lang.Object
-
- org.terrier.structures.SimpleNgramEntryStatistics
-
- All Implemented Interfaces:
java.io.Serializable
,org.apache.hadoop.io.Writable
,EntryStatistics
,NgramEntryStatistics
public class SimpleNgramEntryStatistics extends java.lang.Object implements NgramEntryStatistics, org.apache.hadoop.io.Writable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SimpleNgramEntryStatistics()
SimpleNgramEntryStatistics(int ws)
SimpleNgramEntryStatistics(EntryStatistics e)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(EntryStatistics e)
Increment the statistics of this object by that of another.int
getDocumentFrequency()
Return the number of documents that the term occurs in.int
getFrequency()
Return the frequency (total number of occurrences) of the term.int
getMaxFrequencyInDocuments()
Return the maximum in-document term frequency of the term among all documents the terms appears in.int
getTermId()
Return the id of the term.int
getWindowSize()
Get the size of the window used to calculate an n-gram frequencyEntryStatistics
getWritableEntryStatistics()
Copy this entry statistics to one that can be reused.void
readFields(java.io.DataInput in)
void
setDocumentFrequency(int nt)
Set the number of documents that the term occurs in.void
setFrequency(int F)
Set the frequency (total number of occurrences) of the term.void
setMaxFrequencyInDocuments(int max)
Set the maximum in-document term frequency of the term among all documents the terms appears in.void
setWindowSize(int ws)
Update the window sizevoid
subtract(EntryStatistics e)
Decrement the statistics of this object by that of another.java.lang.String
toString()
void
write(java.io.DataOutput out)
-
-
-
Constructor Detail
-
SimpleNgramEntryStatistics
public SimpleNgramEntryStatistics(EntryStatistics e)
-
SimpleNgramEntryStatistics
public SimpleNgramEntryStatistics()
-
SimpleNgramEntryStatistics
public SimpleNgramEntryStatistics(int ws)
-
-
Method Detail
-
getFrequency
public int getFrequency()
Description copied from interface:EntryStatistics
Return the frequency (total number of occurrences) of the term.- Specified by:
getFrequency
in interfaceEntryStatistics
- Returns:
- the frequency (total number of occurrences) of the entry (term).
-
getDocumentFrequency
public int getDocumentFrequency()
Description copied from interface:EntryStatistics
Return the number of documents that the term occurs in.- Specified by:
getDocumentFrequency
in interfaceEntryStatistics
- Returns:
- the number of documents that the term occurs in.
-
getTermId
public int getTermId()
Description copied from interface:EntryStatistics
Return the id of the term.- Specified by:
getTermId
in interfaceEntryStatistics
- Returns:
- the id of the term.
-
add
public void add(EntryStatistics e)
Description copied from interface:EntryStatistics
Increment the statistics of this object by that of another.- Specified by:
add
in interfaceEntryStatistics
- Parameters:
e
- the other object whose statistics are used to increment the statistics of this object.
-
subtract
public void subtract(EntryStatistics e)
Description copied from interface:EntryStatistics
Decrement the statistics of this object by that of another.- Specified by:
subtract
in interfaceEntryStatistics
- Parameters:
e
- the other object whose statistics are used to decrement the statistics of this object.
-
getWritableEntryStatistics
public EntryStatistics getWritableEntryStatistics()
Description copied from interface:EntryStatistics
Copy this entry statistics to one that can be reused. Kind of like a clone.- Specified by:
getWritableEntryStatistics
in interfaceEntryStatistics
- Returns:
- an identical entry statistics, but which can be reused.
-
getWindowSize
public int getWindowSize()
Description copied from interface:NgramEntryStatistics
Get the size of the window used to calculate an n-gram frequency- Specified by:
getWindowSize
in interfaceNgramEntryStatistics
- Returns:
- number of tokens
-
setWindowSize
public void setWindowSize(int ws)
Description copied from interface:NgramEntryStatistics
Update the window size- Specified by:
setWindowSize
in interfaceNgramEntryStatistics
-
readFields
public void readFields(java.io.DataInput in) throws java.io.IOException
- Specified by:
readFields
in interfaceorg.apache.hadoop.io.Writable
- Throws:
java.io.IOException
-
write
public void write(java.io.DataOutput out) throws java.io.IOException
- Specified by:
write
in interfaceorg.apache.hadoop.io.Writable
- Throws:
java.io.IOException
-
getMaxFrequencyInDocuments
public int getMaxFrequencyInDocuments()
Description copied from interface:EntryStatistics
Return the maximum in-document term frequency of the term among all documents the terms appears in.- Specified by:
getMaxFrequencyInDocuments
in interfaceEntryStatistics
- Returns:
- the maximum in-document term frequency of the term among all documents the terms appears in.
-
setMaxFrequencyInDocuments
public void setMaxFrequencyInDocuments(int max)
Description copied from interface:EntryStatistics
Set the maximum in-document term frequency of the term among all documents the terms appears in.- Specified by:
setMaxFrequencyInDocuments
in interfaceEntryStatistics
- Parameters:
max
- the maximum in-document term frequency of the term among all documents the terms appears in.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
setFrequency
public void setFrequency(int F)
Description copied from interface:EntryStatistics
Set the frequency (total number of occurrences) of the term.- Specified by:
setFrequency
in interfaceEntryStatistics
- Parameters:
F
- the frequency (total number of occurrences) of the entry (term).
-
setDocumentFrequency
public void setDocumentFrequency(int nt)
Description copied from interface:EntryStatistics
Set the number of documents that the term occurs in.- Specified by:
setDocumentFrequency
in interfaceEntryStatistics
- Parameters:
nt
- the number of documents that the term occurs in.
-
-