Class GrammarChecker
java.lang.Object
com.codename1.spellcheck.GrammarChecker
Checks text against a list of grammar and style rules. english() holds the rules English
text gets by default -- a repeated word, "a" against "an", a sentence that starts in lower
case, a space before punctuation, a doubled space -- and an application adds its own
Rules or replaces the list.
GrammarChecker g = GrammarChecker.english();
for (ProofIssue i : g.check("This is is an test.")) {
// "Repeated word" over "is is", "Use a before a consonant sound" over "an"
}
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final GrammarChecker.Rule"a" before a vowel sound and "an" before a consonant one.static final GrammarChecker.RuleA sentence that starts in lower case.static final GrammarChecker.RuleA word written twice in a row.static final GrammarChecker.RuleA space before a comma, period or semicolon, and two spaces in a row. -
Constructor Summary
ConstructorsConstructorDescriptionA checker with no rules.GrammarChecker(GrammarChecker.Rule... rules) A checker with the given rules. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a rule.The problems every rule finds in a text.static GrammarCheckerenglish()A checker with the English rules.getRules()The rules, in order.voidRemoves a rule.
-
Field Details
-
REPEATED_WORD
A word written twice in a row. -
ARTICLE
"a" before a vowel sound and "an" before a consonant one. -
CAPITALIZATION
A sentence that starts in lower case. -
SPACING
A space before a comma, period or semicolon, and two spaces in a row.
-
-
Constructor Details
-
GrammarChecker
public GrammarChecker()A checker with no rules. -
GrammarChecker
A checker with the given rules.
Parameters
rules: the rules, in order
-
-
Method Details
-
english
A checker with the English rules.
Returns
a new checker
-
addRule
Adds a rule.
Parameters
r: the rule
-
removeRule
Removes a rule.
Parameters
r: the rule
-
getRules
The rules, in order.
Returns
a copy of the list
-
check
The problems every rule finds in a text.
Parameters
text: the text, typically a paragraph
Returns
the issues, rule by rule
-