Package org.languagetool.tools
Class RuleMatchesAsJsonSerializer
java.lang.Object
org.languagetool.tools.RuleMatchesAsJsonSerializer
Write rule matches and some meta information as JSON.
- Since:
- 3.4, public since 3.6
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Patternprivate static final intprivate final intprivate Map<ConfidenceKey, Float> private static final com.fasterxml.jackson.core.JsonFactoryprivate final Languageprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final String -
Constructor Summary
ConstructorsConstructorDescriptionRuleMatchesAsJsonSerializer(int compactMode) RuleMatchesAsJsonSerializer(int compactMode, Language lang) -
Method Summary
Modifier and TypeMethodDescriptionprivate StringruleMatchesToJson(List<RuleMatch> matches, String text, int contextSize, DetectedLanguage detectedLang) ruleMatchesToJson(List<RuleMatch> matches, List<RuleMatch> hiddenMatches, String text, int contextSize, DetectedLanguage detectedLang, String incompleteResultsReason) ruleMatchesToJson(List<RuleMatch> matches, List<RuleMatch> hiddenMatches, AnnotatedText text, int contextSize, DetectedLanguage detectedLang, String incompleteResultsReason, boolean showPremiumHint) ruleMatchesToJson2(List<CheckResults> res, List<RuleMatch> hiddenMatches, AnnotatedText text, int contextSize, DetectedLanguage detectedLang, String incompleteResultsReason, boolean showPremiumHint, JLanguageTool.Mode mode) voidsetRuleIdToConfidenceMap(Map<ConfidenceKey, Float> confidenceMap) private voidwriteCategory(com.fasterxml.jackson.core.JsonGenerator g, Category category) private voidwriteContext(com.fasterxml.jackson.core.JsonGenerator g, RuleMatch match, AnnotatedText text, ContextTools contextTools) private voidwriteExtendedSentenceRanges(com.fasterxml.jackson.core.JsonGenerator g, List<CheckResults> res) private voidwriteIgnoreRanges(com.fasterxml.jackson.core.JsonGenerator g, List<CheckResults> res) private voidwriteLanguageSection(com.fasterxml.jackson.core.JsonGenerator g, DetectedLanguage detectedLang) private voidwriteMatchesSection(String sectionName, com.fasterxml.jackson.core.JsonGenerator g, List<CheckResults> res, AnnotatedText text, ContextTools contextTools) private voidwriteReplacements(com.fasterxml.jackson.core.JsonGenerator g, RuleMatch match) private voidprivate voidwriteSentenceRanges(com.fasterxml.jackson.core.JsonGenerator g, List<CheckResults> res) private voidwriteSoftwareSection(com.fasterxml.jackson.core.JsonGenerator g, boolean showPremiumHint) private voidwriteWarningsSection(com.fasterxml.jackson.core.JsonGenerator g, String incompleteResultsReason)
-
Field Details
-
API_VERSION
private static final int API_VERSION- See Also:
-
STATUS
- See Also:
-
PREMIUM_HINT
- See Also:
-
START_MARKER
- See Also:
-
factory
private static final com.fasterxml.jackson.core.JsonFactory factory -
SUGGESTION
- See Also:
-
SUGGESTION_END
- See Also:
-
ANYTHING_SLASH_PATTERN
-
compactMode
private final int compactMode -
lang
-
confidenceMap
-
-
Constructor Details
-
RuleMatchesAsJsonSerializer
public RuleMatchesAsJsonSerializer() -
RuleMatchesAsJsonSerializer
public RuleMatchesAsJsonSerializer(int compactMode) - Since:
- 4.7
-
RuleMatchesAsJsonSerializer
- Since:
- 5.1
-
-
Method Details
-
ruleMatchesToJson
public String ruleMatchesToJson(List<RuleMatch> matches, String text, int contextSize, DetectedLanguage detectedLang) -
ruleMatchesToJson
public String ruleMatchesToJson(List<RuleMatch> matches, List<RuleMatch> hiddenMatches, String text, int contextSize, DetectedLanguage detectedLang, String incompleteResultsReason) - Parameters:
incompleteResultsReason- use a string that explains why results are incomplete (e.g. due to a timeout) - a 'warnings' section will be added to the JSON. Usenullif results are complete.- Since:
- 3.7
-
ruleMatchesToJson
public String ruleMatchesToJson(List<RuleMatch> matches, List<RuleMatch> hiddenMatches, AnnotatedText text, int contextSize, DetectedLanguage detectedLang, String incompleteResultsReason, boolean showPremiumHint) - Parameters:
incompleteResultsReason- use a string that explains why results are incomplete (e.g. due to a timeout) - a 'warnings' section will be added to the JSON. Usenullif results are complete.- Since:
- 4.3
-
ruleMatchesToJson2
public String ruleMatchesToJson2(List<CheckResults> res, List<RuleMatch> hiddenMatches, AnnotatedText text, int contextSize, DetectedLanguage detectedLang, String incompleteResultsReason, boolean showPremiumHint, JLanguageTool.Mode mode) - Parameters:
incompleteResultsReason- use a string that explains why results are incomplete (e.g. due to a timeout) - a 'warnings' section will be added to the JSON. Usenullif results are complete.- Since:
- 5.3
-
writeSoftwareSection
private void writeSoftwareSection(com.fasterxml.jackson.core.JsonGenerator g, boolean showPremiumHint) throws IOException - Throws:
IOException
-
writeWarningsSection
private void writeWarningsSection(com.fasterxml.jackson.core.JsonGenerator g, String incompleteResultsReason) throws IOException - Throws:
IOException
-
writeLanguageSection
private void writeLanguageSection(com.fasterxml.jackson.core.JsonGenerator g, DetectedLanguage detectedLang) throws IOException - Throws:
IOException
-
writeMatchesSection
private void writeMatchesSection(String sectionName, com.fasterxml.jackson.core.JsonGenerator g, List<CheckResults> res, AnnotatedText text, ContextTools contextTools) throws IOException - Throws:
IOException
-
writeIgnoreRanges
private void writeIgnoreRanges(com.fasterxml.jackson.core.JsonGenerator g, List<CheckResults> res) throws IOException - Throws:
IOException
-
writeSentenceRanges
private void writeSentenceRanges(com.fasterxml.jackson.core.JsonGenerator g, List<CheckResults> res) throws IOException - Throws:
IOException
-
writeExtendedSentenceRanges
private void writeExtendedSentenceRanges(com.fasterxml.jackson.core.JsonGenerator g, List<CheckResults> res) throws IOException - Throws:
IOException
-
cleanSuggestion
-
writeReplacements
private void writeReplacements(com.fasterxml.jackson.core.JsonGenerator g, RuleMatch match) throws IOException - Throws:
IOException
-
writeContext
private void writeContext(com.fasterxml.jackson.core.JsonGenerator g, RuleMatch match, AnnotatedText text, ContextTools contextTools) throws IOException - Throws:
IOException
-
writeRule
private void writeRule(com.fasterxml.jackson.core.JsonGenerator g, RuleMatch match) throws IOException - Throws:
IOException
-
writeCategory
private void writeCategory(com.fasterxml.jackson.core.JsonGenerator g, Category category) throws IOException - Throws:
IOException
-
setRuleIdToConfidenceMap
-