Class DisambiguationPatternRule
java.lang.Object
org.languagetool.rules.Rule
org.languagetool.rules.patterns.AbstractPatternRule
org.languagetool.tagging.disambiguation.rules.DisambiguationPatternRule
A Rule that describes a pattern of words or part-of-speech tags used for
disambiguation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Possible disambiguator actions. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DisambiguationPatternRule.DisambiguatorAction
private final String
private List
<DisambiguatedExample> private final Match
private AnalyzedToken[]
Fields inherited from class org.languagetool.rules.patterns.AbstractPatternRule
antiPatterns, endPositionCorrection, filter, filterArgs, language, message, patternTokens, regex, regexMark, sentStart, sourceFile, startPositionCorrection, subId, suggestionMatches, suggestionMatchesOutMsg, suggestionsOutMsg, testUnification
-
Constructor Summary
ConstructorsConstructorDescriptionDisambiguationPatternRule
(String id, String description, Language language, List<PatternToken> patternTokens, String disambiguatedPOS, Match posSelect, DisambiguationPatternRule.DisambiguatorAction disambAction) -
Method Summary
Modifier and TypeMethodDescription@Nullable String
@Nullable Match
final AnalyzedSentence
replace
(AnalyzedSentence sentence) Performs disambiguation on the source sentence.void
setExamples
(List<DisambiguatedExample> examples) final void
setNewInterpretations
(AnalyzedToken[] newReadings) Used to add new interpretations.void
setUntouchedExamples
(List<String> untouchedExamples) Methods inherited from class org.languagetool.rules.patterns.AbstractPatternRule
addSuggestionMatch, addSuggestionMatchOutMsg, getAntiPatterns, getDescription, getEndPositionCorrection, getFilter, getFilterArguments, getFullId, getId, getLanguage, getMessage, getPatternRuleId, getPatternTokens, getSourceFile, getStartPositionCorrection, getSubId, getSuggestionsOutMsg, isGetUnified, isGroupsOrUnification, isSentStart, isTestUnification, match, setAntiPatterns, setEndPositionCorrection, setFilter, setFilterArguments, setMessage, setStartPositionCorrection, setSubId, supportsLanguage, toString
Methods inherited from class org.languagetool.rules.Rule
addExamplePair, estimateContextForSureMatch, getCategory, getConfigureText, getCorrectExamples, getDefaultValue, getErrorTriggeringExamples, getIncorrectExamples, getLocQualityIssueType, getMaxConfigurableValue, getMinConfigurableValue, getSentenceWithImmunization, getUrl, hasConfigurableValue, isDefaultOff, isDefaultTempOff, isDictionaryBasedSpellingRule, isOfficeDefaultOff, isOfficeDefaultOn, makeAntiPatterns, setCategory, setCorrectExamples, setDefaultOff, setDefaultOn, setDefaultTempOff, setErrorTriggeringExamples, setIncorrectExamples, setLocQualityIssueType, setOfficeDefaultOff, setOfficeDefaultOn, setUrl, toRuleMatchArray, useInOffice
-
Field Details
-
disambiguatedPOS
-
matchElement
-
disAction
-
newTokenReadings
-
examples
-
untouchedExamples
-
-
Constructor Details
-
DisambiguationPatternRule
public DisambiguationPatternRule(String id, String description, Language language, List<PatternToken> patternTokens, String disambiguatedPOS, Match posSelect, DisambiguationPatternRule.DisambiguatorAction disambAction) - Parameters:
id
- Id of the Ruledescription
- Description to be shown (name)language
- Language of the RuledisambAction
- the action to be executed on found token(s)- Since:
- public since 2.5
-
-
Method Details
-
setNewInterpretations
Used to add new interpretations.- Parameters:
newReadings
- An array of AnalyzedTokens. The length of the array should be the same as the number of the tokens matched and selected by<marker>...</marker>
elements.
-
replace
Performs disambiguation on the source sentence.- Parameters:
sentence
-AnalyzedSentence
Sentence to be disambiguated.- Returns:
AnalyzedSentence
Disambiguated sentence (might be unchanged).- Throws:
IOException
-
setExamples
-
getExamples
-
setUntouchedExamples
-
getUntouchedExamples
-
getAction
- Since:
- 2.3
-
getNewTokenReadings
- Since:
- 2.3
-
getMatchElement
- Since:
- 2.3
-
getDisambiguatedPOS
- Since:
- 2.3
-