edu.umn.cs.nlp.mt
Class LexicalTranslationProbabilityDistribution

java.lang.Object
  extended by edu.umn.cs.nlp.mt.LexicalTranslationProbabilityDistribution

public class LexicalTranslationProbabilityDistribution
extends Object

Lexical translation probability distribution, stored as a Berkeley DB JE database.

This class works only with regular probabilities, not with log probabibilities.

Version:
$LastChangedDate: 2007-11-26 10:42:44 -0600 (Mon, 26 Nov 2007) $
Author:
Lane Schwartz

Constructor Summary
LexicalTranslationProbabilityDistribution(Scanner sourceToTargetFile, Scanner targetToSourceFile, String dbDirectoryName, String dbEncoding)
          Construct a LexicalTranslationProbabilityDistribution by reading word pair count data from source-to-target word pair count data and target-to-source word pair count data.
LexicalTranslationProbabilityDistribution(String dbDirectoryName, String dbEncoding)
          Construct a LexicalTranslationProbabilityDistribution by opening an existing Berkeley DB JE database which already contains the lexical translation probability distribution data.
 
Method Summary
 void close()
          Close the underlying database.
 boolean delete()
          Delete the database directory backing this object.
static void main(String[] args)
          Sample code for querying a lexprob database
 double sourceGivenTarget(String sourceWord, String targetWord)
          Look up the lexical translation probability of a source language word given a target language word.
 double targetGivenSource(String targetWord, String sourceWord)
          Look up the lexical translation probability of a target language word given a source language word.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LexicalTranslationProbabilityDistribution

public LexicalTranslationProbabilityDistribution(String dbDirectoryName,
                                                 String dbEncoding)
                                          throws FileNotFoundException
Construct a LexicalTranslationProbabilityDistribution by opening an existing Berkeley DB JE database which already contains the lexical translation probability distribution data.

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

LexicalTranslationProbabilityDistribution

public LexicalTranslationProbabilityDistribution(Scanner sourceToTargetFile,
                                                 Scanner targetToSourceFile,
                                                 String dbDirectoryName,
                                                 String dbEncoding)
Construct a LexicalTranslationProbabilityDistribution by reading word pair count data from source-to-target word pair count data and target-to-source word pair count data.

The constructor calculates the lexical translation probability distributions specified by the word pair count data, and stores the lexical translation probability distributions in a new Berkeley DB JE database stored in the specified directory.

Parameters:
sourceToTargetFile - source-to-target word pair counts
targetToSourceFile - target-to-source word pair counts
dbDirectoryName - location where the database will be created
dbEncoding - text encoding to be used by the database
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.


sourceGivenTarget

public double sourceGivenTarget(String sourceWord,
                                String targetWord)
Look up the lexical translation probability of a source language word given a target language word.

Parameters:
sourceWord - the source language word
targetWord - the target language word
Returns:
the lexical translation probability

targetGivenSource

public double targetGivenSource(String targetWord,
                                String sourceWord)
Look up the lexical translation probability of a target language word given a source language word.

Parameters:
targetWord - the target language word
sourceWord - the source language word
Returns:
the lexical translation probability

delete

public boolean delete()
Delete the database directory backing this object. Use with care!

Returns:
true if the backing directory was deleted, false otherwise

main

public static void main(String[] args)
Sample code for querying a lexprob database

Parameters:
args -