Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class GrammarChecker
- Object
- 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 types
interface GrammarChecker.Rule | One check over a text. |
Fields
public static final GrammarChecker.Rule REPEATED_WORD | A word written twice in a row. |
public static final GrammarChecker.Rule ARTICLE | “a” before a vowel sound and “an” before a consonant one. |
public static final GrammarChecker.Rule CAPITALIZATION | A sentence that starts in lower case. |
public static final GrammarChecker.Rule SPACING | A space before a comma, period or semicolon, and two spaces in a row. |
Constructors
public GrammarChecker() | A checker with no rules. |
public GrammarChecker(GrammarChecker.Rule... rules) | A checker with the given rules. |
Methods
Inherited methods
Field details
REPEATED_WORD
public static final GrammarChecker.Rule REPEATED_WORDA word written twice in a row.
ARTICLE
public static final GrammarChecker.Rule ARTICLE“a” before a vowel sound and “an” before a consonant one.
CAPITALIZATION
public static final GrammarChecker.Rule CAPITALIZATIONA sentence that starts in lower case.
SPACING
public static final GrammarChecker.Rule SPACINGA space before a comma, period or semicolon, and two spaces in a row.
Constructor details
GrammarChecker
public GrammarChecker()A checker with no rules.
GrammarChecker
public GrammarChecker(GrammarChecker.Rule... rules)A checker with the given rules.
Parameters
rulesGrammarChecker.Rule...- the rules, in order
Method details
english
public static GrammarChecker english()A checker with the English rules.
Returns
a new checker
addRule
public void addRule(GrammarChecker.Rule r)Adds a rule.
Parameters
rGrammarChecker.Rule- the rule
removeRule
public void removeRule(GrammarChecker.Rule r)Removes a rule.
Parameters
rGrammarChecker.Rule- the rule
getRules
public List<GrammarChecker.Rule> getRules()The rules, in order.
Returns
a copy of the list
check
public List<ProofIssue> check(String text)The problems every rule finds in a text.
Parameters
textString- the text, typically a paragraph
Returns
the issues, rule by rule