pt.tumba.ngram
Class ProfileReader

java.lang.Object
  extended by pt.tumba.ngram.ProfileReader

public class ProfileReader
extends java.lang.Object

Class to hold (static) methods to read in profile data. A Profile stores N-gram frequency information for a given textual string.

Author:
Bruno Martins

Field Summary
private static ProfileReader _theInstance
          The single instance of this Singleton class.
 
Constructor Summary
private ProfileReader()
          Sole constructor of ProfileReader.
 
Method Summary
static ProfileReader getInstance()
          Returns an instance of this class.
protected static java.util.Map newNGram(java.util.Map count, byte[] ba, int start, int len)
          Create a new N-gram from an array of bytes.
static java.util.List read(java.io.InputStream stream)
          Read an N-gram profile from an InputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_theInstance

private static final ProfileReader _theInstance
The single instance of this Singleton class.

Constructor Detail

ProfileReader

private ProfileReader()
Sole constructor of ProfileReader.

Method Detail

getInstance

public static ProfileReader getInstance()
Returns an instance of this class.

Returns:
An instance of ProfileReader.

newNGram

protected static java.util.Map newNGram(java.util.Map count,
                                        byte[] ba,
                                        int start,
                                        int len)
Create a new N-gram from an array of bytes.

Parameters:
count - A Map with N-gram frequency information.
ba - An array of bytes with the chars corresponding to this N-Gram.
start - Starting position in the array of bytes.
len - Length in the array of bytes.

read

public static java.util.List read(java.io.InputStream stream)
                           throws java.io.IOException
Read an N-gram profile from an InputStream.

Parameters:
stream - The InputStream from where to read the Profile.
Returns:
A List with the N-Grams in the profile.
Throws:
java.io.IOException - A problem occurred while reading from the InputStream.