edu.umn.cs.nlp
Class NGramDB

java.lang.Object
  extended by edu.umn.cs.nlp.NGramDB
All Implemented Interfaces:
LanguageModel

public class NGramDB
extends Object
implements LanguageModel

NGram log probabilities distribution, stored as a Berkeley DB JE database.

Version:
$LastChangedDate$
Author:
Lane Schwartz

Field Summary
static String ngramsDatabaseName
           
 
Constructor Summary
NGramDB(Scanner scanner, String dbDirectoryName, String dbEncoding)
          Construct an object from ARPA backoff N-gram model file
NGramDB(String dbDirectoryName, String dbEncoding)
          Construct an NGramLogProbabilities object by opening an existing Berkeley DB JE database which already contains the ngram data.
 
Method Summary
 void close()
          Close the underlying database.
 double get(String key)
          Get the language model probability for a given String.
 int getNGramCount(int order)
           
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ngramsDatabaseName

public static final String ngramsDatabaseName
See Also:
Constant Field Values
Constructor Detail

NGramDB

public NGramDB(Scanner scanner,
               String dbDirectoryName,
               String dbEncoding)
Construct an object from ARPA backoff N-gram model file

Parameters:
scanner - configured to read an ARPA backoff N-gram model file
dbDirectoryName - location where the database will be created
dbEncoding - text encoding to be used by the database

NGramDB

public NGramDB(String dbDirectoryName,
               String dbEncoding)
        throws FileNotFoundException
Construct an NGramLogProbabilities object by opening an existing Berkeley DB JE database which already contains the ngram data.

Parameters:
dbDirectoryName - location of the database
dbEncoding - text encoding used by the database
Throws:
FileNotFoundException
Method Detail

close

public void close()
Close the underlying database.

This method must be called in order to cleanly close the underlying database. If this method is not called, there is significant risk of corrupting the underlying database.


get

public double get(String key)
Description copied from interface: LanguageModel
Get the language model probability for a given String.

Specified by:
get in interface LanguageModel
Parameters:
key - string to look up
Returns:
the language model probability for the given String

getNGramCount

public int getNGramCount(int order)

main

public static void main(String[] args)