de.danielnaber.languagetool.rules.patterns
Class PatternRule

Object
  extended by Rule
      extended by PatternRule

public class PatternRule
extends Rule

A Rule that describes a language error as a simple pattern of words or of part-of-speech tags.

Author:
Daniel Naber

Method Summary
 void addSuggestionMatch(Match m)
           
 String getDescription()
           
 String getId()
           
 String getMessage()
           
 String getSubId()
           
 boolean isWithComplexPhrase()
          Used for testing rules: only one of the set can match.
 RuleMatch[] match(AnalyzedSentence text)
          Check whether the given text matche this error rule, i.e. whether the text contains this error.
 void notComplexPhrase()
          Reset complex status - used for testing.
 void reset()
          If a rule keeps it state over more than the check of one sentence, this must be implemented so the internal state it reset.
 void setEndPositionCorrection(int endPositionCorrection)
           
 void setMessage(String message)
           
 void setStartPositionCorrection(int startPositionCorrection)
           
 void setSubId(String subId)
           
 String toPatternString()
          Return the pattern as a string.
 String toString()
           
 String toXML()
          Return the pattern as an XML string.
 
Methods inherited from class Rule
addRuleMatch, clearMatches, getCategory, getCorrectExamples, getIncorrectExamples, getMatches, getMatchesIndex, isDefaultOff, isInMatches, isInRemoved, isParagraphBackTrack, setAsDeleted, setCategory, setCorrectExamples, setDefaultOff, setIncorrectExamples, setParagraphBackTrack, supportsLanguage
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getId

public final String getId()
Specified by:
getId in class Rule

getDescription

public final String getDescription()
Specified by:
getDescription in class Rule

getSubId

public final String getSubId()

setSubId

public final void setSubId(String subId)

getMessage

public final String getMessage()

isWithComplexPhrase

public final boolean isWithComplexPhrase()
Used for testing rules: only one of the set can match.

Returns:
Whether the rule can non-match (as a member of disjunctive set of rules generated by phraseref in includephrases element).

notComplexPhrase

public final void notComplexPhrase()
Reset complex status - used for testing.


toString

public final String toString()
Overrides:
toString in class Object

toPatternString

public final String toPatternString()
Return the pattern as a string.

Since:
0.9.2

toXML

public final String toXML()
Return the pattern as an XML string. FIXME: this is not complete, information might be lost!

Since:
0.9.3

setMessage

public final void setMessage(String message)

setStartPositionCorrection

public final void setStartPositionCorrection(int startPositionCorrection)

setEndPositionCorrection

public final void setEndPositionCorrection(int endPositionCorrection)

match

public final RuleMatch[] match(AnalyzedSentence text)
                        throws IOException
Description copied from class: Rule
Check whether the given text matche this error rule, i.e. whether the text contains this error.

Specified by:
match in class Rule
Parameters:
text - a pre-analyzed sentence
Returns:
an array of RuleMatch object for each match.
Throws:
IOException

addSuggestionMatch

public final void addSuggestionMatch(Match m)

reset

public void reset()
Description copied from class: Rule
If a rule keeps it state over more than the check of one sentence, this must be implemented so the internal state it reset. It will be called before a new text is going to be checked.

Specified by:
reset in class Rule


Copyright © 2005-2007 Daniel Naber