Joshua
open source statistical hierarchical phrase-based machine translation system
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
joshua.util.ChartSpan< Type > Class Reference

List of all members.

Public Member Functions

 ChartSpan (int w, Type defaultValue)
Type get (int i, int j)
void set (int i, int j, Type value)
void setDiagonal (Type value)

Package Attributes

Object[] chart
int max

Private Member Functions

int offset (int i, int j)

Detailed Description

CKY-based decoding makes extensive use of charts, which maintain information about spans (i, j) over the length-n input sentence, 0 <= i <= j <= n. These charts are used for many things; for example, lattices use a chart to denote whether there is a path between nodes i and j, and what their costs is, and the decoder uses charts to record the partial application of rules ( DotChart) and the existence of proved items (PhraseChart).

The dummy way to implement a chart is to initialize a two-dimensional array; however, this wastes a lot of space, because the constraint (i <= j) means that only half of this space can ever be used. This is especially a problem for lattices, where the sentence length (n) is the number of nodes in the lattice!

Fortunately, there is a smarter way, since there is a simple deterministic mapping between chart spans under a given maximum length. This class implements that in a generic way, introducing large savings in both space and time.

Author:
Matt Post post@.nosp@m.cs.j.nosp@m.hu.ed.nosp@m.u

Constructor & Destructor Documentation

joshua.util.ChartSpan< Type >.ChartSpan ( int  w,
Type  defaultValue 
)

Member Function Documentation

Type joshua.util.ChartSpan< Type >.get ( int  i,
int  j 
)
int joshua.util.ChartSpan< Type >.offset ( int  i,
int  j 
) [private]

This computes the offset into the one-dimensional array for a given span.

Parameters:
i
j
Returns:
the offset
Exceptions:
InvalidSpanException
void joshua.util.ChartSpan< Type >.set ( int  i,
int  j,
Type  value 
)
void joshua.util.ChartSpan< Type >.setDiagonal ( Type  value)

Convenience function for setting the values along the diagonal.

Parameters:
value

Member Data Documentation

Object [] joshua.util.ChartSpan< Type >.chart [package]
int joshua.util.ChartSpan< Type >.max [package]