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
Fields -
Constructor Summary
Constructors -
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) 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 voidwriteLanguageSection(com.fasterxml.jackson.core.JsonGenerator g, DetectedLanguage detectedLang) private voidwriteMatchesSection(String sectionName, com.fasterxml.jackson.core.JsonGenerator g, List<RuleMatch> matches, AnnotatedText text, ContextTools contextTools) private voidwriteReplacements(com.fasterxml.jackson.core.JsonGenerator g, RuleMatch match) private voidprivate voidwriteSoftwareSection(com.fasterxml.jackson.core.JsonGenerator g) 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 -
compactMode
private final int compactMode
-
-
Constructor Details
-
RuleMatchesAsJsonSerializer
public RuleMatchesAsJsonSerializer() -
RuleMatchesAsJsonSerializer
public RuleMatchesAsJsonSerializer(int compactMode) - Since:
- 4.7
-
-
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) - 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
-
writeSoftwareSection
- 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<RuleMatch> matches, AnnotatedText text, ContextTools contextTools) 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
-