Joshua
open source statistical hierarchical phrase-based machine translation system
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
joshua.decoder.ff.tm.AbstractGrammar Class Reference
Inheritance diagram for joshua.decoder.ff.tm.AbstractGrammar:
[legend]
Collaboration diagram for joshua.decoder.ff.tm.AbstractGrammar:
[legend]

List of all members.

Public Member Functions

 AbstractGrammar ()
int getOOVRuleID ()
void sortGrammar (List< FeatureFunction > models)
boolean isSorted ()
void writeGrammarOnDisk (String file)
void changeGrammarCosts (Map< String, Double > weightTbl, HashMap< String, Integer > featureMap, double[] scores, String prefix, int column, boolean negate)
void obtainRulesIDTable (Map< String, Integer > rulesIDTable)

Static Public Attributes

static final int OOV_RULE_ID = 0

Protected Member Functions

void setSorted (boolean sorted)

Protected Attributes

boolean sorted

Private Member Functions

void sort (Trie node, List< FeatureFunction > models)
void changeGrammarCosts (Trie trie, HashMap< String, Integer > featureMap, double[] scores, String prefix, int column, boolean negate)
void obtainRulesIDTable (Trie trie, Map< String, Integer > rulesIDTable)

Static Private Attributes

static final Logger logger = Logger.getLogger(AbstractGrammar.class.getName())

Detailed Description

Partial implementation of the Grammar interface that provides logic for sorting a grammar.

Note: New classes implementing the Grammar interface should probably inherit from this class, unless a specific sorting technique different from that implemented by this class is required.

Author:
Zhifei Li
Lane Schwartz

Constructor & Destructor Documentation

Constructs an empty, unsorted grammar.

See also:
Grammar::isSorted()

Member Function Documentation

void joshua.decoder.ff.tm.AbstractGrammar.changeGrammarCosts ( Map< String, Double >  weightTbl,
HashMap< String, Integer >  featureMap,
double[]  scores,
String  prefix,
int  column,
boolean  negate 
)

Implements joshua.decoder.ff.tm.Grammar.

Here is the call graph for this function:

Here is the caller graph for this function:

void joshua.decoder.ff.tm.AbstractGrammar.changeGrammarCosts ( Trie  trie,
HashMap< String, Integer >  featureMap,
double[]  scores,
String  prefix,
int  column,
boolean  negate 
) [private]

Here is the call graph for this function:

Gets the integer identifier of this grammar's out-of-vocabulary (OOV) rule.

Returns:
the integer identifier of this grammar's out-of-vocabulary (OOV) rule

Implements joshua.decoder.ff.tm.Grammar.

Here is the caller graph for this function:

Determines whether the rules in this grammar have been sorted based on the latest feature function values.

This method is needed for the cube-pruning algorithm.

Returns:
true if the rules in this grammar have been sorted based on the latest feature function values, false otherwise

Implements joshua.decoder.ff.tm.Grammar.

void joshua.decoder.ff.tm.AbstractGrammar.obtainRulesIDTable ( Map< String, Integer >  rulesIDTable)

Implements joshua.decoder.ff.tm.Grammar.

Here is the call graph for this function:

Here is the caller graph for this function:

void joshua.decoder.ff.tm.AbstractGrammar.obtainRulesIDTable ( Trie  trie,
Map< String, Integer >  rulesIDTable 
) [private]

Here is the call graph for this function:

void joshua.decoder.ff.tm.AbstractGrammar.setSorted ( boolean  sorted) [protected]

Sets the flag indicating whether this grammar is sorted.

This method is called by sortGrammar(ArrayList) to indicate that the grammar has been sorted.

Its scope is protected so that child classes that override sortGrammar will also be able to call this method to indicate that the grammar has been sorted.

Parameters:
sorted

Here is the caller graph for this function:

void joshua.decoder.ff.tm.AbstractGrammar.sort ( Trie  node,
List< FeatureFunction models 
) [private]

Recursively sorts the grammar using the provided feature functions.

This method first sorts the rules stored at the provided node, then recursively calls itself on the child nodes of the provided node.

Parameters:
nodeGrammar node in the Trie whose rules should be sorted.
modelsFeature function models to use during sorting.

Here is the call graph for this function:

Here is the caller graph for this function:

Cube-pruning requires that the grammar be sorted based on the latest feature functions. To avoid synchronization, this method should be called before multiple threads are initialized for parallel decoding

Implements joshua.decoder.ff.tm.Grammar.

Here is the call graph for this function:


Member Data Documentation

final Logger joshua.decoder.ff.tm.AbstractGrammar.logger = Logger.getLogger(AbstractGrammar.class.getName()) [static, private]

Indicates whether the rules in this grammar have been sorted based on the latest feature function values.