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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DisambiguationPatternRule.DisambiguatorAction
Possible disambiguator actions.
-
Field Summary
Fields Modifier and Type Field Description private DisambiguationPatternRule.DisambiguatorAction
disAction
private java.lang.String
disambiguatedPOS
private java.util.List<DisambiguatedExample>
examples
private Match
matchElement
private AnalyzedToken[]
newTokenReadings
private java.util.List<java.lang.String>
untouchedExamples
-
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(java.lang.String id, java.lang.String description, Language language, java.util.List<PatternToken> patternTokens, java.lang.String disambiguatedPOS, Match posSelect, DisambiguationPatternRule.DisambiguatorAction disambAction)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DisambiguationPatternRule.DisambiguatorAction
getAction()
@Nullable java.lang.String
getDisambiguatedPOS()
java.util.List<DisambiguatedExample>
getExamples()
@Nullable Match
getMatchElement()
AnalyzedToken[]
getNewTokenReadings()
java.util.List<java.lang.String>
getUntouchedExamples()
AnalyzedSentence
replace(AnalyzedSentence sentence)
Performs disambiguation on the source sentence.void
setExamples(java.util.List<DisambiguatedExample> examples)
void
setNewInterpretations(AnalyzedToken[] newReadings)
Used to add new interpretations.void
setUntouchedExamples(java.util.List<java.lang.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 Detail
-
disambiguatedPOS
private final java.lang.String disambiguatedPOS
-
matchElement
private final Match matchElement
-
disAction
private final DisambiguationPatternRule.DisambiguatorAction disAction
-
newTokenReadings
private AnalyzedToken[] newTokenReadings
-
examples
private java.util.List<DisambiguatedExample> examples
-
untouchedExamples
private java.util.List<java.lang.String> untouchedExamples
-
-
Constructor Detail
-
DisambiguationPatternRule
public DisambiguationPatternRule(java.lang.String id, java.lang.String description, Language language, java.util.List<PatternToken> patternTokens, java.lang.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 java.io.IOException
Performs disambiguation on the source sentence.- Parameters:
sentence
-AnalyzedSentence
Sentence to be disambiguated.- Returns:
AnalyzedSentence
Disambiguated sentence (might be unchanged).- Throws:
java.io.IOException
-
setExamples
public void setExamples(java.util.List<DisambiguatedExample> examples)
-
getExamples
public java.util.List<DisambiguatedExample> getExamples()
-
setUntouchedExamples
public void setUntouchedExamples(java.util.List<java.lang.String> untouchedExamples)
-
getUntouchedExamples
public java.util.List<java.lang.String> getUntouchedExamples()
-
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 java.lang.String getDisambiguatedPOS()
- Since:
- 2.3
-
-