pt.tumba.ngram
Class DataProfile

java.lang.Object
  extended by pt.tumba.ngram.DataProfile
All Implemented Interfaces:
Profile

public class DataProfile
extends java.lang.Object
implements Profile

A Profile stores N-gram frequency information for a given textual string. This is a profile implementation which reads itself from a text file.

Author:
Bruno Martins

Field Summary
protected  java.lang.String name
          The name for the Profile (usually equal to the filename from where it was read).
protected  java.util.List rankedNGrams
          The list of N-grams in this Profile.
 
Constructor Summary
DataProfile(java.lang.String name, java.io.InputStream stream)
          Constructor for DataProfile.
 
Method Summary
 java.lang.String getName()
          Gets the name of the Profile.
 double getRank(NGram gram)
          Gets the ranking position of a given N-gram.
 int getSize()
          Gets the number of N-grams in the Profile.
 double getWeight(NGram gram)
          Gets the weighting score of a given N-gram.
 java.util.Iterator ngrams()
          Returns an Iterator over the N-grams in this profile.
private  void readStream(java.io.InputStream stream)
          Reads the Profile data from an InputStream.
 java.lang.String toString()
          Converts this profile to a String Object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
The name for the Profile (usually equal to the filename from where it was read).


rankedNGrams

protected java.util.List rankedNGrams
The list of N-grams in this Profile.

Constructor Detail

DataProfile

public DataProfile(java.lang.String name,
                   java.io.InputStream stream)
Constructor for DataProfile.

Parameters:
name - The name of the profile.
stream - An InputStream from where to read the Profile.
Method Detail

getName

public java.lang.String getName()
Gets the name of the Profile.

Returns:
The name of the Profile.

getRank

public double getRank(NGram gram)
Gets the ranking position of a given N-gram.

Specified by:
getRank in interface Profile
Parameters:
gram - An N-Gram
Returns:
The associated ranking position.

getWeight

public double getWeight(NGram gram)
Gets the weighting score of a given N-gram.

Specified by:
getWeight in interface Profile
Parameters:
gram - An N-Gram
Returns:
The associated occurence frequency.

getSize

public int getSize()
Gets the number of N-grams in the Profile.

Returns:
The number of N-grams in the Profile.

ngrams

public java.util.Iterator ngrams()
Returns an Iterator over the N-grams in this profile.

Specified by:
ngrams in interface Profile
Returns:
An Iterator over the N-grams in this profile.

readStream

private final void readStream(java.io.InputStream stream)
Reads the Profile data from an InputStream.

Parameters:
stream - The InputStream from where to read the Profile.

toString

public java.lang.String toString()
Converts this profile to a String Object.

Overrides:
toString in class java.lang.Object
Returns:
A String with the name of this Profile.