-
Notifications
You must be signed in to change notification settings - Fork 581
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
natural_language: Add SpellCheckBear
This bear uses ``scspell`` to check for spelling mistakes. Closes #629
- Loading branch information
1 parent
8a3d7fd
commit b3be8f3
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from coalib.bearlib.abstractions.Linter import linter | ||
from coalib.bears.requirements.PipRequirement import PipRequirement | ||
|
||
|
||
@linter(executable='scspell', | ||
use_stderr=True, | ||
output_format='regex', | ||
output_regex=r'(?P<filename>.*):(?P<line>.\d*):\s*(?P<message>.*)') | ||
class SpellCheckBear: | ||
""" | ||
Lints files to check for incorrect spellings using ``scspell``. | ||
See <https://pypi.python.org/pypi/scspell> for more information. | ||
""" | ||
LANGUAGES = {"Natural Language"} | ||
REQUIREMENTS = {PipRequirement('scspell3k', '2.0')} | ||
AUTHORS = {'The coala developers'} | ||
AUTHORS_EMAILS = {'[email protected]'} | ||
LICENSE = 'AGPL-3.0' | ||
CAN_DETECT = {'Spelling'} | ||
|
||
@staticmethod | ||
def create_arguments(filename, file, config_file): | ||
return '--report-only', filename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import platform | ||
import unittest | ||
|
||
from bears.natural_language.SpellCheckBear import SpellCheckBear | ||
from tests.LocalBearTestHelper import verify_local_bear | ||
|
||
good_file = "This is correct spelling." | ||
|
||
bad_file = "tihs si surly som incoreclt speling." | ||
|
||
|
||
SpellCheckLintBearTest = unittest.skipIf( | ||
platform.system() == "Windows", | ||
"SpellCheckBear doesn't work on windows")( | ||
verify_local_bear(SpellCheckBear, | ||
valid_files=(good_file,), | ||
invalid_files=(bad_file,))) |