Skip to content

Commit

Permalink
Add ApertiumLintBear
Browse files Browse the repository at this point in the history
ApertiumLintBear is a bear which uses
apertium-lint to lint 4 file types namely
dictionaries, transfer, modes and tagger.

Closes coala#1320
  • Loading branch information
Techievena authored and jayvdb committed May 31, 2017
1 parent aa547dd commit 95b85f5
Show file tree
Hide file tree
Showing 9 changed files with 437 additions and 0 deletions.
1 change: 1 addition & 0 deletions .ci/generate_bear_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
PINNED_PACKAGES = (
'radon',
'click',
'lxml',
)

env = Environment(loader=FileSystemLoader(THIS_DIR))
Expand Down
2 changes: 2 additions & 0 deletions bear-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
apertium-lint~=0.29
autoflake~=0.6.6
autopep8~=1.2
bandit~=1.2
Expand All @@ -11,6 +12,7 @@ guess-language-spirit~=0.5.2
html-linter~=0.3.0
isort~=4.2
language-check~=1.0
lxml==3.6.0
munkres3~=1.0
mypy-lang~=0.4.6
nbformat~=4.1
Expand Down
364 changes: 364 additions & 0 deletions bears/apertium/ApertiumLintBear.py

Large diffs are not rendered by default.

Empty file added bears/apertium/__init__.py
Empty file.
37 changes: 37 additions & 0 deletions tests/apertium/ApertiumLintBearTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import os
from queue import Queue

from bears.apertium.ApertiumLintBear import ApertiumLintBear
from coalib.testing.BearTestHelper import generate_skip_decorator
from coalib.testing.LocalBearTestHelper import LocalBearTestHelper
from coalib.settings.Section import Section
from coalib.settings.Setting import Setting


@generate_skip_decorator(ApertiumLintBear)
class ApertiumLintBearTest(LocalBearTestHelper):

def setUp(self):
self.section = Section('test section')
self.uut = ApertiumLintBear(self.section, Queue())
test_files = os.path.join(os.path.dirname(__file__), 'test_files')
self.good_file = os.path.join(test_files, 'apertium-go-od.en.dix')
self.bad_file = os.path.join(test_files, 'apertium-ba-ad.en.dix')
self.config_file = os.path.join(test_files, 'apertium_config.json')

def test_run(self):
self.section.append(Setting('apertiumlint_config', ''))
self.check_validity(self.uut, [], self.good_file)

self.section.append(Setting('apertiumlint_config', self.config_file))
self.check_validity(self.uut, [], self.good_file)

self.section.append(Setting('apertiumlint_config', ''))
self.check_validity(self.uut, [], self.bad_file, valid=False)

self.section.append(Setting('apertiumlint_config', self.config_file))
self.check_validity(self.uut, [], self.bad_file, valid=False)

def test_paradigm_names(self):
self.section.append(Setting('paradigm_names', 'False'))
self.check_validity(self.uut, [], self.bad_file)
Empty file added tests/apertium/__init__.py
Empty file.
12 changes: 12 additions & 0 deletions tests/apertium/test_files/apertium-ba-ad.en.dix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<dictionary>
<alphabet>·ÀÁÂÄÇÈÉÊËÌÍÎÏÑÒÓÔÖÙÚÛÜÚāàáâäçèéêëìíîïīñòóôöõùúûüABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ş</alphabet>
<pardefs>

<pardef n="ö">
<e> <p><l>ö</l> <r>ö</r></p></e>
<e r="LR"><p><l>oe</l> <r>ö</r></p></e>
</pardef>

</pardefs>
</dictionary>
13 changes: 13 additions & 0 deletions tests/apertium/test_files/apertium-go-od.en.dix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<dictionary>
<alphabet>·ÀÁÂÄÇÈÉÊËÌÍÎÏÑÒÓÔÖÙÚÛÜÚāàáâäçèéêëìíîïīñòóôöõùúûüABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789ş</alphabet>
<pardefs>

<pardef n="zero__n">
<e> <p><l></l> <r><s n="n"/><s n="sg"/></r></p></e>
<e> <p><l>es</l> <r><s n="n"/><s n="pl"/></r></p></e>
<e r="LR"><p><l>s</l> <r><s n="n"/><s n="pl"/></r></p></e>
</pardef>

</pardefs>
</dictionary>
8 changes: 8 additions & 0 deletions tests/apertium/test_files/apertium_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"monodix": {
"paradigmNames":{
"message": "Warning : Improper paradigm name found :",
"enable" : true
}
}
}

0 comments on commit 95b85f5

Please sign in to comment.