Class Sentence

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.Box
                    |
                    +--Sentence

public class Sentence
extends javax.swing.Box

Represents a single sentence and all related data; responsible for information storage as well as visual display. Visually, a Sentence is implemented as a subclass of javax.swing.Box, which basically means it is either a row or column of Words. It provides methods for changing the GUI as well as accessors for information about individual words.

Author:
Mike Jahr
See Also:
Web, Word, Serialized Form

Inner Class Summary
protected  class Sentence.WordAdder
          Thread utility class which adds all words to the given sentence.
 
Inner classes inherited from class javax.swing.Box
javax.swing.Box.AccessibleBox, javax.swing.Box.Filler
 
Field Summary
static int HUMAN
          Constant for marking human sentences.
static int SOURCE
          Constant for marking source sentences.
static int TARGET
          Constant for marking target sentences.
 
Fields inherited from class javax.swing.Box
accessibleContext
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
Sentence(int intype, int axis)
          Creates a new sentence with the given type and axis.
Sentence(Sentence ins, int axis)
          Creates a duplicate of the given sentence on the new axis.
 
Method Summary
 void clear()
          Clears all data related to this sentence.
 void finish()
          Finishes initialization of the sentence.
 java.lang.String getLanguage()
          Returns the language of this sentence.
 int getLength()
          Returns the number of Words in this sentence.
 java.awt.Dimension getMaximumSize()
          Overrides Box.getMaximumSize().
 java.awt.Dimension getMinimumSize()
          Overrides Box.getMinimumSize().
 java.awt.Dimension getPreferredSize()
          Overrides Box.getPreferredSize().
 double getProb()
          Returns the probability of this sentence.
 int getType()
          Returns the type of the sentence.
 java.lang.String getTypeString()
          Returns a string representing the type of the current sentence.
 Web getWeb()
          Returns the Web associated with this sentence.
 Word getWordAt(int index)
          Returns the Word at the given index.
 java.util.Enumeration getWords()
          Returns an enumeration of the Words in this sentence.
 int getWordXLoc(int index)
          Returns the x coordinate of the location of the Word at the given index.
 int getWordYLoc(int index)
          Returns the y coordinate of the location of the Word at the given index.
 boolean isHuman()
          Returns true if this is a human sentence.
 boolean isSource()
          Returns true if this is a source sentence.
 boolean isTarget()
          Returns true if this is a target sentence.
 void readDistortions(java.io.StreamTokenizer st)
          Reads a distortion table from an alignment file.
 void readFertility(java.io.StreamTokenizer st, boolean corr)
          Reads a fertility table from an alignment file.
 void readProb(java.io.StreamTokenizer st)
          Reads a sentence probability from an alignment file.
 void readTranslations(java.io.StreamTokenizer st, boolean corr, Sentence oppositeSent)
          Reads a translation table from an alignment file.
 void readWords(java.io.StreamTokenizer st)
          Reads a sentence from an alignment file.
 void setLanguage(java.lang.String inl)
          Sets the language of this sentence to the given value.
 void setProb(double p)
          Sets the probability of this sentence to the given value.
 void setStreamVisible(int str, boolean vis)
          Displays or hides the given stream and updates the display.
 void setWeb(Web w)
          Sets the Web associated with this sentence to the given value.
 java.lang.String toString()
          Returns a string representation of the sentence.
 void updateAxis()
          Update the sentence to reflect the current web.axis.
 
Methods inherited from class javax.swing.Box
createGlue, createHorizontalBox, createHorizontalGlue, createHorizontalStrut, createRigidArea, createVerticalBox, createVerticalGlue, createVerticalStrut, getAccessibleContext, setLayout
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TARGET

public static final int TARGET
Constant for marking target sentences.

SOURCE

public static final int SOURCE
Constant for marking source sentences.

HUMAN

public static final int HUMAN
Constant for marking human sentences.
Constructor Detail

Sentence

public Sentence(int intype,
                int axis)
Creates a new sentence with the given type and axis.

Sentence

public Sentence(Sentence ins,
                int axis)
Creates a duplicate of the given sentence on the new axis.
Method Detail

readProb

public void readProb(java.io.StreamTokenizer st)
              throws FormatException
Reads a sentence probability from an alignment file.
See Also:
AlnLoader

readFertility

public void readFertility(java.io.StreamTokenizer st,
                          boolean corr)
                   throws FormatException
Reads a fertility table from an alignment file.
See Also:
AlnLoader

readTranslations

public void readTranslations(java.io.StreamTokenizer st,
                             boolean corr,
                             Sentence oppositeSent)
                      throws FormatException
Reads a translation table from an alignment file.
See Also:
AlnLoader

readDistortions

public void readDistortions(java.io.StreamTokenizer st)
                     throws FormatException
Reads a distortion table from an alignment file.
See Also:
AlnLoader

readWords

public void readWords(java.io.StreamTokenizer st)
               throws FormatException
Reads a sentence from an alignment file.
See Also:
AlnLoader

updateAxis

public void updateAxis()
Update the sentence to reflect the current web.axis.

toString

public java.lang.String toString()
Returns a string representation of the sentence.
Overrides:
toString in class java.awt.Component

clear

public void clear()
Clears all data related to this sentence.

setStreamVisible

public void setStreamVisible(int str,
                             boolean vis)
Displays or hides the given stream and updates the display.

getType

public int getType()
Returns the type of the sentence.
See Also:
getTypeString(), SOURCE, TARGET, HUMAN

getTypeString

public java.lang.String getTypeString()
Returns a string representing the type of the current sentence. Returns one of "reference", "target", "source", or "unknown".
See Also:
getType()

isSource

public boolean isSource()
Returns true if this is a source sentence.
See Also:
getType()

isTarget

public boolean isTarget()
Returns true if this is a target sentence.
See Also:
getType()

isHuman

public boolean isHuman()
Returns true if this is a human sentence.
See Also:
getType()

setWeb

public void setWeb(Web w)
Sets the Web associated with this sentence to the given value.
See Also:
getWeb()

getWeb

public Web getWeb()
Returns the Web associated with this sentence.
See Also:
setWeb(Web)

setProb

public void setProb(double p)
Sets the probability of this sentence to the given value.
See Also:
getProb()

getProb

public double getProb()
Returns the probability of this sentence.
See Also:
setProb(double)

setLanguage

public void setLanguage(java.lang.String inl)
Sets the language of this sentence to the given value.
See Also:
getLanguage()

getLanguage

public java.lang.String getLanguage()
Returns the language of this sentence.
See Also:
setLanguage(String)

getWords

public java.util.Enumeration getWords()
Returns an enumeration of the Words in this sentence.
See Also:
Word

getWordAt

public Word getWordAt(int index)
Returns the Word at the given index.
See Also:
Word

getLength

public int getLength()
Returns the number of Words in this sentence.

getWordXLoc

public int getWordXLoc(int index)
Returns the x coordinate of the location of the Word at the given index.
See Also:
getWordYLoc(int)

getWordYLoc

public int getWordYLoc(int index)
Returns the y coordinate of the location of the Word at the given index.
See Also:
getWordXLoc(int)

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides Box.getPreferredSize().
Overrides:
getPreferredSize in class java.awt.Container
See Also:
getMaximumSize(), getMinimumSize()

finish

public void finish()
Finishes initialization of the sentence.

getMaximumSize

public java.awt.Dimension getMaximumSize()
Overrides Box.getMaximumSize().
Overrides:
getMaximumSize in class java.awt.Container
See Also:
getPreferredSize(), getMinimumSize()

getMinimumSize

public java.awt.Dimension getMinimumSize()
Overrides Box.getMinimumSize().
Overrides:
getMinimumSize in class java.awt.Container
See Also:
getMaximumSize(), getPreferredSize()