Class DisambiguationPatternRule
- java.lang.Object
-
- org.languagetool.rules.Rule
-
- org.languagetool.rules.patterns.AbstractPatternRule
-
- org.languagetool.tagging.disambiguation.rules.DisambiguationPatternRule
-
public class DisambiguationPatternRule extends AbstractPatternRule
A Rule that describes a pattern of words or part-of-speech tags used for disambiguation.- Author:
- Marcin MiĆkowski
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DisambiguationPatternRule.DisambiguatorAction
Possible disambiguator actions.
-
Field Summary
-
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
Constructors Constructor Description DisambiguationPatternRule(String id, String description, Language language, List<PatternToken> patternTokens, String disambiguatedPOS, Match posSelect, DisambiguationPatternRule.DisambiguatorAction disambAction)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DisambiguationPatternRule.DisambiguatorAction
getAction()
@Nullable String
getDisambiguatedPOS()
List<DisambiguatedExample>
getExamples()
@Nullable Match
getMatchElement()
AnalyzedToken[]
getNewTokenReadings()
List<String>
getUntouchedExamples()
AnalyzedSentence
replace(AnalyzedSentence sentence)
Performs disambiguation on the source sentence.void
setExamples(List<DisambiguatedExample> examples)
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
-
-
-
-
Constructor Detail
-
DisambiguationPatternRule
public DisambiguationPatternRule(String id, String description, Language language, List<PatternToken> patternTokens, String disambiguatedPOS, Match posSelect, DisambiguationPatternRule.DisambiguatorAction disambAction)
- Parameters:
id
- Id of the Rulelanguage
- Language of the Ruledescription
- Description to be shown (name)disambAction
- the action to be executed on found token(s)- Since:
- public since 2.5
-
-
Method Detail
-
setNewInterpretations
public final void setNewInterpretations(AnalyzedToken[] newReadings)
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
public final AnalyzedSentence replace(AnalyzedSentence sentence) throws IOException
Performs disambiguation on the source sentence.- Parameters:
sentence
-AnalyzedSentence
Sentence to be disambiguated.- Returns:
AnalyzedSentence
Disambiguated sentence (might be unchanged).- Throws:
IOException
-
setExamples
public void setExamples(List<DisambiguatedExample> examples)
-
getExamples
public List<DisambiguatedExample> getExamples()
-
getAction
public DisambiguationPatternRule.DisambiguatorAction getAction()
- Since:
- 2.3
-
getNewTokenReadings
public AnalyzedToken[] getNewTokenReadings()
- Since:
- 2.3
-
getMatchElement
@Nullable public @Nullable Match getMatchElement()
- Since:
- 2.3
-
getDisambiguatedPOS
@Nullable public @Nullable String getDisambiguatedPOS()
- Since:
- 2.3
-
-