Package org.languagetool.rules.patterns
Class XMLRuleHandler
java.lang.Object
org.xml.sax.helpers.DefaultHandler
org.languagetool.rules.patterns.XMLRuleHandler
- All Implemented Interfaces:
ContentHandler,DTDHandler,EntityResolver,ErrorHandler
- Direct Known Subclasses:
DisambiguationRuleHandler,FalseFriendRuleHandler,PatternRuleHandler
XML rule handler that loads rules from XML and throws
exceptions on errors and warnings.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected intprotected static final Stringprotected static final Stringprotected booleanprotected ChunkTagprotected static final Stringprotected StringBuilderprotected List<CorrectExample> protected static final Stringprotected StringBuilderprotected intprotected StringBuilderprotected List<ErrorTriggeringExample> protected static final Stringprotected StringBuilderprotected static final Stringprotected Booleanprotected booleanprotected booleanprotected booleanprotected Stringprotected StringBuilderprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected static final Stringprotected Stringstatic final Stringprotected static final Stringprotected booleanprotected StringBuilderprotected booleanprotected List<IncorrectExample> protected booleanprotected booleanprotected static final Stringprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected booleanprotected Languageprotected booleantrue when phraseref is the last element in the rule.protected static final Stringprotected static final Stringprotected StringBuilderprotected static final Stringprotected static final Stringprotected intprotected StringBuilderprotected static final Stringprotected static final Stringprotected intstatic final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected intprotected static final Stringprotected PatternTokenprotected List<PatternToken> List of elements as specified by tokens.protected StringCurrent phrase ID.protected StringID reference to the phrase.protected Map<String, List<List<PatternToken>>> Phrase store - elementLists keyed by phraseIds.protected List<ArrayList<PatternToken>> Logically forking element list, used for including multiple phrases in the current one.protected static final Stringprotected Locatorprotected booleanprotected booleanprotected static final Stringprotected static final Stringprotected Stringprotected StringBuilderprotected booleanprotected XMLRuleHandler.RegexpModeprotected static final Stringprotected intprotected booleanprotected static final Stringprotected static final Stringprotected Stringprotected List<AbstractPatternRule> protected static final Stringprotected static final Stringprotected StringBuilderprotected StringBuilderprotected static final Stringprotected intprotected static final Stringprotected intprotected static final Stringprotected StringBuilderprotected static final Stringprotected static final Stringprotected static final Stringprotected intprotected booleanprotected booleanprotected booleanprotected booleanprotected Matchprotected booleanprotected booleanprotected static final Stringprotected Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected booleanprotected StringBuilderprotected StringBuilderprotected Stringprotected static final StringDefinitions of values in XML files. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddLegacyMatches(List<Match> existingSugMatches, String messageStr, boolean inMessage) Adds Match objects for all references to tokens (including '\1' and the like).private voidcheckNumber(Attributes attrs) private voidcheckRefNumber(int refNumber) voidprotected voidprotected voidprotected voidgetRules()protected voidpreparePhrase(Attributes attrs) protected voidprocessElement(List<PatternToken> patternTokens) Calculates the offset of the match reference (if any) in case the match element has been used in the group.protected voidprotected voidvoidsetDocumentLocator(Locator locator) protected voidsetExceptions(Attributes attrs) protected voidsetMatchElement(Attributes attrs) protected voidsetRuleFilter(String filterClassName, String filterArgs, AbstractPatternRule rule) protected voidsetToken(Attributes attrs) protected voidstartPattern(Attributes attrs) voidMethods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startElement, startPrefixMapping, unparsedEntityDeclMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.xml.sax.ContentHandler
declaration
-
Field Details
-
ID
- See Also:
-
NAME
- See Also:
-
YES
Definitions of values in XML files.- See Also:
-
OFF
- See Also:
-
TEMP_OFF
- See Also:
-
ON
- See Also:
-
POSTAG
- See Also:
-
CHUNKTAG
- See Also:
-
POSTAG_REGEXP
- See Also:
-
REGEXP
- See Also:
-
NEGATE
- See Also:
-
INFLECTED
- See Also:
-
NEGATE_POS
- See Also:
-
MARKER
- See Also:
-
DEFAULT
- See Also:
-
TYPE
- See Also:
-
SPACEBEFORE
- See Also:
-
EXAMPLE
- See Also:
-
SCOPE
- See Also:
-
IGNORE
- See Also:
-
SKIP
- See Also:
-
MIN
- See Also:
-
MAX
- See Also:
-
TOKEN
- See Also:
-
FEATURE
- See Also:
-
UNIFY
- See Also:
-
UNIFY_IGNORE
- See Also:
-
AND
- See Also:
-
OR
- See Also:
-
EXCEPTION
- See Also:
-
CASE_SENSITIVE
- See Also:
-
MARK
- See Also:
-
PATTERN
- See Also:
-
ANTIPATTERN
- See Also:
-
MATCH
- See Also:
-
UNIFICATION
- See Also:
-
RULE
- See Also:
-
RULES
- See Also:
-
RULEGROUP
- See Also:
-
NO
- See Also:
-
PHRASES
- See Also:
-
MESSAGE
- See Also:
-
SUGGESTION
- See Also:
-
TABNAME
- See Also:
-
rules
-
language
-
correctExample
-
incorrectExample
-
errorTriggerExample
-
exampleCorrection
-
message
-
suggestionsOutMsg
-
match
-
elements
-
exceptions
-
correctExamples
-
incorrectExamples
-
errorTriggeringExamples
-
inPattern
protected boolean inPattern -
inCorrectExample
protected boolean inCorrectExample -
inIncorrectExample
protected boolean inIncorrectExample -
inErrorTriggerExample
protected boolean inErrorTriggerExample -
inMessage
protected boolean inMessage -
inSuggestion
protected boolean inSuggestion -
inMatch
protected boolean inMatch -
inRuleGroup
protected boolean inRuleGroup -
inToken
protected boolean inToken -
inException
protected boolean inException -
inPhrases
protected boolean inPhrases -
inAndGroup
protected boolean inAndGroup -
inOrGroup
protected boolean inOrGroup -
tokenSpaceBefore
protected boolean tokenSpaceBefore -
tokenSpaceBeforeSet
protected boolean tokenSpaceBeforeSet -
posToken
-
chunkTag
-
posNegation
protected boolean posNegation -
posRegExp
protected boolean posRegExp -
caseSensitive
protected boolean caseSensitive -
regExpression
protected boolean regExpression -
tokenNegated
protected boolean tokenNegated -
tokenInflected
protected boolean tokenInflected -
tokenLevelCaseSensitive
protected boolean tokenLevelCaseSensitive -
tokenLevelCaseSet
protected boolean tokenLevelCaseSet -
exceptionPosToken
-
exceptionStringRegExp
protected boolean exceptionStringRegExp -
exceptionStringNegation
protected boolean exceptionStringNegation -
exceptionStringInflected
protected boolean exceptionStringInflected -
exceptionPosNegation
protected boolean exceptionPosNegation -
exceptionPosRegExp
protected boolean exceptionPosRegExp -
exceptionValidNext
protected boolean exceptionValidNext -
exceptionValidPrev
protected boolean exceptionValidPrev -
exceptionSet
protected boolean exceptionSet -
exceptionSpaceBefore
protected boolean exceptionSpaceBefore -
exceptionSpaceBeforeSet
protected boolean exceptionSpaceBeforeSet -
exceptionLevelCaseSensitive
-
exceptionLevelCaseSet
protected boolean exceptionLevelCaseSet -
patternTokens
List of elements as specified by tokens. -
lastPhrase
protected boolean lastPhrasetrue when phraseref is the last element in the rule. -
phraseIdRef
ID reference to the phrase. -
phraseId
Current phrase ID. -
skipPos
protected int skipPos -
minOccurrence
protected int minOccurrence -
maxOccurrence
protected int maxOccurrence -
ruleGroupId
-
id
-
patternToken
-
tokenReference
-
suggestionMatches
-
suggestionMatchesOutMsg
-
pLocator
-
startPositionCorrection
protected int startPositionCorrection -
endPositionCorrection
protected int endPositionCorrection -
tokenCounter
protected int tokenCounter -
phraseMap
Phrase store - elementLists keyed by phraseIds. -
phrasePatternTokens
Logically forking element list, used for including multiple phrases in the current one. -
andGroupCounter
protected int andGroupCounter -
orGroupCounter
protected int orGroupCounter -
inUrl
protected boolean inUrl -
inUrlForRuleGroup
protected boolean inUrlForRuleGroup -
url
-
urlForRuleGroup
-
inRegex
protected boolean inRegex -
regex
-
regexMode
-
regexCaseSensitive
protected boolean regexCaseSensitive -
regexpMark
protected int regexpMark -
inShortMessage
protected boolean inShortMessage -
inShortMessageForRuleGroup
protected boolean inShortMessageForRuleGroup -
shortMessage
-
shortMessageForRuleGroup
-
inUnification
protected boolean inUnification -
inMarker
protected boolean inMarker -
inUnificationDef
protected boolean inUnificationDef -
uniNegation
protected boolean uniNegation -
inUnificationNeutral
protected boolean inUnificationNeutral -
uFeature
-
uType
-
uTypeList
-
equivalenceFeatures
-
-
Constructor Details
-
XMLRuleHandler
public XMLRuleHandler()
-
-
Method Details
-
getRules
-
warning
- Specified by:
warningin interfaceErrorHandler- Overrides:
warningin classDefaultHandler- Throws:
SAXException
-
error
- Specified by:
errorin interfaceErrorHandler- Overrides:
errorin classDefaultHandler- Throws:
SAXException
-
setDocumentLocator
- Specified by:
setDocumentLocatorin interfaceContentHandler- Overrides:
setDocumentLocatorin classDefaultHandler
-
resetToken
protected void resetToken() -
resetException
protected void resetException() -
preparePhrase
-
finalizePhrase
protected void finalizePhrase() -
startPattern
- Throws:
SAXException
-
processElement
Calculates the offset of the match reference (if any) in case the match element has been used in the group.- Parameters:
patternTokens- token list where the match element was used. It is directly changed.
-
setMatchElement
- Throws:
SAXException
-
checkNumber
- Throws:
SAXException
-
checkRefNumber
- Throws:
SAXException
-
setExceptions
-
finalizeExceptions
protected void finalizeExceptions() -
setToken
-
addLegacyMatches
@Nullable protected @Nullable List<Match> addLegacyMatches(List<Match> existingSugMatches, String messageStr, boolean inMessage) Adds Match objects for all references to tokens (including '\1' and the like). -
finalizeTokens
- Throws:
SAXException
-
setRuleFilter
-