ch.uzh.ifi.attempto.preditor.text
Class TextElement

java.lang.Object
  extended by ch.uzh.ifi.attempto.preditor.text.TextElement
Direct Known Subclasses:
OntologyTextElement

public class TextElement
extends java.lang.Object

This class describes a text element (a word or phrase) that is used by the predictive editor. Every text element contains a text and one or more grammatical categories. If a text element contains more than one categories then this means that it can stand for any of these categories.

Author:
Tobias Kuhn

Constructor Summary
TextElement()
          Creates a text element with an empty string as its text and category of the same name.
TextElement(int number)
          Creates a new text element containing a number which is also the name of the category.
TextElement(java.lang.String categoryName)
          Creates a new text element where the text is the name of the category.
TextElement(java.lang.String text, java.util.List<Terminal> categories)
          Creates a new text element with the given categories.
TextElement(java.lang.String text, java.lang.String categoryName)
          Creates a new text element.
TextElement(java.lang.String text, Terminal category)
          Creates a new text element with one category.
TextElement(Terminal category)
          Creates a new text element where the text is the name of the category.
 
Method Summary
 boolean applyRestriction(Restriction restr)
          Applies the given restriction by excluding all categories that are not fulfilled by the restriction.
 boolean equals(java.lang.Object obj)
          Two text elements are equals if they share the same text.
 Terminal[] getCategories()
          Returns the grammatical category of this text element.
 java.lang.String getOriginalText()
          Returns the original text of this text element.
 java.lang.String getText()
          Returns the text of this text element.
 void include(TextElement textElement)
          Includes the categories of the given text element.
 void setID(int id)
          Sets the feature "id" for all categories.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextElement

public TextElement(java.lang.String text,
                   Terminal category)
Creates a new text element with one category.

Parameters:
text - The text.
category - The category.

TextElement

public TextElement(java.lang.String text,
                   java.util.List<Terminal> categories)
Creates a new text element with the given categories.

Parameters:
text - The text.
categories - The categories.

TextElement

public TextElement(java.lang.String text,
                   java.lang.String categoryName)
Creates a new text element.

Parameters:
text - The text.
categoryName - The name of the category.

TextElement

public TextElement(Terminal category)
Creates a new text element where the text is the name of the category.

Parameters:
category - The category.

TextElement

public TextElement(java.lang.String categoryName)
Creates a new text element where the text is the name of the category.

Parameters:
categoryName - The name of the category.

TextElement

public TextElement()
Creates a text element with an empty string as its text and category of the same name.


TextElement

public TextElement(int number)
Creates a new text element containing a number which is also the name of the category.

Parameters:
number - The number.
Method Detail

getOriginalText

public java.lang.String getOriginalText()
Returns the original text of this text element. This is the unchanged text before it is given to the context checker.

Returns:
The original text (before the context checker).

getText

public java.lang.String getText()
Returns the text of this text element. The text might have been changed by the context checker.

Returns:
The text (after the context checker).

getCategories

public Terminal[] getCategories()
Returns the grammatical category of this text element.

Returns:
The grammatical category.

applyRestriction

public final boolean applyRestriction(Restriction restr)
Applies the given restriction by excluding all categories that are not fulfilled by the restriction. The return value indicates whether this text elements fulfills the restriction which is the case if and only if at least one category is left.

Parameters:
restr - The restriction to be applied.
Returns:
true if the restrictions is altogether fulfilled, i.e. if at least one category fulfills the restriction.

setID

public void setID(int id)
Sets the feature "id" for all categories.

Parameters:
id - The id value.

include

public void include(TextElement textElement)
Includes the categories of the given text element. This is only allowed if the two text elements are equal (accoring to the equals-method).

Parameters:
textElement - The text element whose categories should be included.

equals

public boolean equals(java.lang.Object obj)
Two text elements are equals if they share the same text.

Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright 2008-2009, Attempto Group, University of Zurich (see http://attempto.ifi.uzh.ch)