de.danielnaber.languagetool.rules.patterns
Class PatternRule

Object
  extended by Rule
      extended by AbstractPatternRule
          extended by PatternRule

public class PatternRule
extends AbstractPatternRule

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)
           
 List<Element> getElements()
          For testing only.
 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 matches this error rule, i.e. whether the text contains this error.
 void notComplexPhrase()
          Reset complex status - used for testing.
 void setMessage(String message)
           
 void setSubId(String subId)
           
 String toPatternString()
          Return the pattern as a string.
 String toXML()
          Return the pattern as an XML string.
 
Methods inherited from class AbstractPatternRule
getDescription, getId, reset, setEndPositionCorrection, setStartPositionCorrection, toString
 
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

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.


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)

match

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

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

addSuggestionMatch

public final void addSuggestionMatch(Match m)

getElements

public final List<Element> getElements()
For testing only.



Copyright © 2005-2009 Daniel Naber