marf.Stats
Class Ngram

java.lang.Object
  extended by marf.Stats.StatisticalObject
      extended by marf.Stats.WordStats
          extended by marf.Stats.Observation
              extended by marf.Stats.Ngram
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class Ngram
extends Observation

N-gram Observation.

$Id: Ngram.java,v 1.16 2007/12/18 21:57:14 mokhov Exp $

Since:
0.3.0.2
Version:
$Revision: 1.16 $
Author:
Serguei Mokhov
See Also:
Serialized Form

Field Summary
 
Fields inherited from class marf.Stats.Observation
bSeen, dPosteriorProbability, dPriorProbability
 
Fields inherited from class marf.Stats.StatisticalObject
iFrequency, iRank
 
Constructor Summary
Ngram()
          Constructs an unigram.
Ngram(int piSize)
          Constructs an N-gram of the specified size.
Ngram(Ngram poNgram)
          Copy-constructor.
Ngram(Ngram[] paoNgramElements)
          Constructs an N-gram out of the N-gram elements.
 
Method Summary
 void addNgram(Ngram poNgram)
          Adds an N-gram at the end of the N-gram elements array.
 java.lang.Object clone()
          Implements Cloneable interface for the Ngram object.
 int getCapacity()
          Allows querying for the current capacity of the N-gram (how many elements are actually there).
static java.lang.String getMARFSourceCodeRevision()
          Returns source code revision information.
 Ngram[] getNgramElements()
          Allows querying for the contained N-gram elements.
 int getSize()
          Retrieves the size of the N-gram.
 void setNgram(int piIndex, Ngram poNgram)
          Sets an N-gram at a specified index.
 
Methods inherited from class marf.Stats.Observation
getPosteriorProbability, getPriorProbability, markAsSeen, setPosteriorProbability, setPriorProbability, wasSeen
 
Methods inherited from class marf.Stats.WordStats
getLexeme, toString
 
Methods inherited from class marf.Stats.StatisticalObject
equals, getFrequency, getRank, hashCode, incFrequency, incRank, setRank
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Ngram

public Ngram()
Constructs an unigram.


Ngram

public Ngram(int piSize)
Constructs an N-gram of the specified size. The first element of the N-gram is this object itself.

Parameters:
piSize - N

Ngram

public Ngram(Ngram[] paoNgramElements)
Constructs an N-gram out of the N-gram elements. Makes a deep copy of the parameter array.

Parameters:
paoNgramElements - the N-gram array to make a copy from

Ngram

public Ngram(Ngram poNgram)
Copy-constructor.

Parameters:
poNgram - Ngram object to copy properties of
Since:
0.3.0.5
Method Detail

setNgram

public void setNgram(int piIndex,
                     Ngram poNgram)
Sets an N-gram at a specified index.

Parameters:
piIndex - the index
poNgram - the n-gram
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the index is outside the valid range

addNgram

public void addNgram(Ngram poNgram)
Adds an N-gram at the end of the N-gram elements array.

Parameters:
poNgram - the N-gram to add.
Throws:
java.lang.ArrayIndexOutOfBoundsException - the N-gram being added exceeds the initial capacity

getSize

public final int getSize()
Retrieves the size of the N-gram.

Returns:
N

getNgramElements

public final Ngram[] getNgramElements()
Allows querying for the contained N-gram elements.

Returns:
the collection of the elements
Since:
0.3.0.5

getCapacity

public final int getCapacity()
Allows querying for the current capacity of the N-gram (how many elements are actually there). Should be less than or equal to the length of the elements array.

Returns:
current capacity of the n-gram
Since:
0.3.0.5

clone

public java.lang.Object clone()
Implements Cloneable interface for the Ngram object.

Overrides:
clone in class Observation
Since:
0.3.0.5
See Also:
Object.clone()

getMARFSourceCodeRevision

public static java.lang.String getMARFSourceCodeRevision()
Returns source code revision information.

Returns:
revision string


SourceForge Logo