Skip to content

Commit 0072e73

Browse files
committed
Add enable_spellchecking() and disable_spellchecking() methods
to the LanguageTool class. Add --spell-check option to the command-line tool.
1 parent 84d2bbb commit 0072e73

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎language_tool/__init__.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,22 @@ def reset_enabled(self):
278278
"""
279279
self.enabled = None
280280

281+
def enable_spellchecking(self):
282+
"""Enable spell-checking rules.
283+
"""
284+
if self.disabled is None:
285+
return
286+
for rule in self.spell_checking_rules:
287+
self.disabled.remove(rule)
288+
289+
def disable_spellchecking(self):
290+
"""Disable spell-checking rules.
291+
"""
292+
if self.disabled is None:
293+
self.disabled = set()
294+
for rule in self.spell_checking_rules:
295+
self.disabled.add(rule)
296+
281297
@classmethod
282298
def _get_languages(cls):
283299
if not cls._server_is_alive():

‎language_tool/__main__.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def parse_args():
3636
help="print LanguageTool version number")
3737
parser.add_argument("--apply", action="store_true",
3838
help="automatically apply suggestions if available")
39+
parser.add_argument("--spell-check", action="store_true",
40+
help="enable spell-checking rules")
3941
return parser.parse_args()
4042

4143

@@ -93,6 +95,8 @@ def main():
9395
print("Language: {}".format(lang_tool.language))
9496
text = get_text(file, encoding)
9597

98+
if args.spell_check:
99+
lang_tool.enable_spellchecking()
96100
if args.disable is not None:
97101
lang_tool.disable(args.disable)
98102
if args.enable is not None:

0 commit comments

Comments
 (0)