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

java.lang.Object
  extended by ch.uzh.ifi.attempto.preditor.text.EnglishContextChecker
All Implemented Interfaces:
ContextChecker

public class EnglishContextChecker
extends java.lang.Object
implements ContextChecker

This is a simple implementation of a context checker for the English language. The words "a" and "an" are adapted accoring to the following word, e.g. "a","apple" becomes "an","apple", and "an", "customer" becomes "a","customer". Furthermore, words can be capitalized if they are at sentence- initial position. Capitalization can be turned on or off. In both cases exceptions can be defined using the feature "capitalize" that is read from the category of the text element. If exceptions are enabled and the value of "capitalize" is "true" or "false" then this overrides the default capitalization behavior.

Author:
Tobias Kuhn

Constructor Summary
EnglishContextChecker(boolean defaultCapitalize)
          Creates a new English context checker with no exceptions for capitalization.
EnglishContextChecker(boolean defaultCapitalize, boolean exceptionsEnabled)
          Creates a new English context checker.
 
Method Summary
 boolean areExceptionsEnabled()
          Returns whether capitalization exceptions are enabled.
 java.lang.String getTextInContext(TextElement textElement, java.lang.String precedingText, java.lang.String followingText)
          This method should return the adapted text of the text element if it occurs between the given tokens.
 boolean isDefaultCapitalize()
          Returns whether words are capitalized by default.
 void setDefaultCapitalize(boolean defaultCapitalize)
          Enables or disables the default capitalization.
 void setExceptionsEnabled(boolean exceptionsEnabled)
          Enables or disables capitalization exceptions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnglishContextChecker

public EnglishContextChecker(boolean defaultCapitalize,
                             boolean exceptionsEnabled)
Creates a new English context checker.

Parameters:
defaultCapitalize - true if words should be capitalized by default.
exceptionsEnabled - true if exceptions can be defined using the feature "capitalize".

EnglishContextChecker

public EnglishContextChecker(boolean defaultCapitalize)
Creates a new English context checker with no exceptions for capitalization.

Parameters:
defaultCapitalize - true if words should be capitalized by default.
Method Detail

isDefaultCapitalize

public boolean isDefaultCapitalize()
Returns whether words are capitalized by default.

Returns:
true if words are capitalized by default.

setDefaultCapitalize

public void setDefaultCapitalize(boolean defaultCapitalize)
Enables or disables the default capitalization.

Parameters:
defaultCapitalize - true if words should be capitalized by default.

areExceptionsEnabled

public boolean areExceptionsEnabled()
Returns whether capitalization exceptions are enabled.

Returns:
true if capitalization exceptions are enabled.

setExceptionsEnabled

public void setExceptionsEnabled(boolean exceptionsEnabled)
Enables or disables capitalization exceptions.

Parameters:
exceptionsEnabled - true if exceptions the feature "capitalize" should be used to define capitalization exceptions.

getTextInContext

public java.lang.String getTextInContext(TextElement textElement,
                                         java.lang.String precedingText,
                                         java.lang.String followingText)
Description copied from interface: ContextChecker
This method should return the adapted text of the text element if it occurs between the given tokens.

Specified by:
getTextInContext in interface ContextChecker
Parameters:
textElement - The text element whose text should be adapted to the context.
precedingText - The preceding token.
followingText - The following token.
Returns:
The adapted text.


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