Skip to content

Commit b3be8f3

Browse files
mr-karanAbdealiLoKo
authored andcommitted
natural_language: Add SpellCheckBear
This bear uses ``scspell`` to check for spelling mistakes. Closes #629
1 parent 8a3d7fd commit b3be8f3

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from coalib.bearlib.abstractions.Linter import linter
2+
from coalib.bears.requirements.PipRequirement import PipRequirement
3+
4+
5+
@linter(executable='scspell',
6+
use_stderr=True,
7+
output_format='regex',
8+
output_regex=r'(?P<filename>.*):(?P<line>.\d*):\s*(?P<message>.*)')
9+
class SpellCheckBear:
10+
"""
11+
Lints files to check for incorrect spellings using ``scspell``.
12+
13+
See <https://pypi.python.org/pypi/scspell> for more information.
14+
"""
15+
LANGUAGES = {"Natural Language"}
16+
REQUIREMENTS = {PipRequirement('scspell3k', '2.0')}
17+
AUTHORS = {'The coala developers'}
18+
AUTHORS_EMAILS = {'coala-devel@googlegroups.com'}
19+
LICENSE = 'AGPL-3.0'
20+
CAN_DETECT = {'Spelling'}
21+
22+
@staticmethod
23+
def create_arguments(filename, file, config_file):
24+
return '--report-only', filename

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ pyyaml==3.*
2828
vulture==0.10.*
2929
nbformat>=4.*
3030
pyflakes==1.2.* # Although we don't need this directly, solves a dep conflict
31+
scspell3k==2.*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import platform
2+
import unittest
3+
4+
from bears.natural_language.SpellCheckBear import SpellCheckBear
5+
from tests.LocalBearTestHelper import verify_local_bear
6+
7+
good_file = "This is correct spelling."
8+
9+
bad_file = "tihs si surly som incoreclt speling."
10+
11+
12+
SpellCheckLintBearTest = unittest.skipIf(
13+
platform.system() == "Windows",
14+
"SpellCheckBear doesn't work on windows")(
15+
verify_local_bear(SpellCheckBear,
16+
valid_files=(good_file,),
17+
invalid_files=(bad_file,)))

0 commit comments

Comments
 (0)