Overview
| Comment: | [core][fr] tests update |
|---|---|
| Downloads: | Tarball | ZIP archive | SQL archive |
| Timelines: | family | ancestors | descendants | both | trunk | fr | core |
| Files: | files | file ages | folders |
| SHA3-256: |
6639af3543877a405e4af8823aa698db |
| User & Date: | olr on 2020-11-21 21:42:51 |
| Other Links: | manifest | tags |
Context
|
2020-11-23
| ||
| 10:32 | [build] check token validity check-in: b5ee5c589f user: olr tags: trunk, build | |
|
2020-11-21
| ||
| 21:42 | [core][fr] tests update check-in: 6639af3543 user: olr tags: trunk, fr, core | |
| 21:42 | [fr] corrections des messages d’erreur + ajustements check-in: 84539a25d6 user: olr tags: trunk, fr | |
Changes
Modified gc_core/py/lang_core/tests_core.py from [b3d6379019] to [9e599f13ec].
| ︙ | ︙ | |||
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
class TestGrammarChecking (unittest.TestCase):
"Tests du correcteur grammatical"
@classmethod
def setUpClass (cls):
gc_engine.load()
cls._zError = re.compile(r"\{\{.*?\}\}")
cls._aTestedRules = set()
def test_parse (self):
zOption = re.compile("^__([a-zA-Z0-9]+)__ ")
spHere, _ = os.path.split(__file__)
spfParsingTest = os.path.join(spHere, "gc_test.txt")
if not os.path.exists(spfParsingTest):
| > | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
class TestGrammarChecking (unittest.TestCase):
"Tests du correcteur grammatical"
@classmethod
def setUpClass (cls):
gc_engine.load()
cls._zError = re.compile(r"\{\{.*?\}\}")
cls._zRuleEnd = re.compile(r"_a\d+_\d+$")
cls._aTestedRules = set()
def test_parse (self):
zOption = re.compile("^__([a-zA-Z0-9]+)__ ")
spHere, _ = os.path.split(__file__)
spfParsingTest = os.path.join(spHere, "gc_test.txt")
if not os.path.exists(spfParsingTest):
|
| ︙ | ︙ | |||
141 142 143 144 145 146 147 |
sListErr += " * {sLineId} / {sRuleId} at {nStart}:{nEnd}\n".format(**dErr)
lAllSugg.append("|".join(dErr["aSuggestions"]))
self._aTestedRules.add(dErr["sRuleId"].rstrip("0123456789"))
# test messages
if False:
aMsgErrs = gc_engine.parse(purgeMessage(dErr["sMessage"]))
if aMsgErrs or "<start>" in dErr["sMessage"] or "<end>" in dErr["sMessage"]:
| > > | < | | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
sListErr += " * {sLineId} / {sRuleId} at {nStart}:{nEnd}\n".format(**dErr)
lAllSugg.append("|".join(dErr["aSuggestions"]))
self._aTestedRules.add(dErr["sRuleId"].rstrip("0123456789"))
# test messages
if False:
aMsgErrs = gc_engine.parse(purgeMessage(dErr["sMessage"]))
if aMsgErrs or "<start>" in dErr["sMessage"] or "<end>" in dErr["sMessage"]:
aSelectedErrs = [ dMsgErr for dMsgErr in sorted(aMsgErrs, key=lambda d: d["nStart"]) if self._zRuleEnd.sub("", dMsgErr["sRuleId"]) != self._zRuleEnd.sub("", dErr["sRuleId"]) ]
if aSelectedErrs:
print("\n# Error in: <" + dErr["sMessage"] + ">\n " + dErr["sLineId"] + " / " + dErr["sRuleId"])
for dMsgErr in aSelectedErrs:
print(" error: {sLineId} / {sRuleId} at {nStart}:{nEnd}".format(**dMsgErr))
return sRes, sListErr, "|||".join(lAllSugg)
def _getExpectedErrors (self, sLine):
sRes = " " * len(sLine)
for i, m in enumerate(self._zError.finditer(sLine)):
nStart = m.start() - (4 * i)
|
| ︙ | ︙ |
Modified gc_lang/fr/modules/tests_modules.py from [88e56a7f78] to [f7e92c1ab0].
1 2 3 4 5 6 7 8 9 10 | #! python3 """ Grammar checker tests for French language """ import unittest import time from contextlib import contextmanager | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #! python3 """ Grammar checker tests for French language """ import unittest import time from contextlib import contextmanager from ..graphspell.spellchecker import SpellChecker from . import conj from . import phonet from . import mfsp @contextmanager def timeblock (label, hDst=None): |
| ︙ | ︙ | |||
28 29 30 31 32 33 34 |
class TestDictionary (unittest.TestCase):
"Test du correcteur orthographique"
@classmethod
def setUpClass (cls):
| | | | | | | | | > > > > > > > > > > > > | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
class TestDictionary (unittest.TestCase):
"Test du correcteur orthographique"
@classmethod
def setUpClass (cls):
cls.oSpellChecker = SpellChecker("fr")
def test_lookup (self):
for sWord in ["branche", "Émilie"]:
self.assertTrue(self.oSpellChecker.lookup(sWord), sWord)
def test_lookup_failed (self):
for sWord in ["Branche", "BRANCHE", "BranchE", "BRanche", "BRAnCHE", "émilie"]:
self.assertFalse(self.oSpellChecker.lookup(sWord), sWord)
def test_isvalidtoken (self):
for sWord in ["Branche", "branche", "BRANCHE", "Émilie", "ÉMILIE", "aujourd'hui", "aujourd’hui", "Aujourd'hui", "Aujourd’hui", "je-suis-vraiment-fatigué", ""]:
self.assertTrue(self.oSpellChecker.isValidToken(sWord), sWord)
def test_isvalid (self):
for sWord in ["Branche", "branche", "BRANCHE", "Émilie", "ÉMILIE", "aujourd’hui", "Aujourd’hui"]:
self.assertTrue(self.oSpellChecker.isValid(sWord), sWord)
def test_isvalid_failed (self):
for sWord in ["BranchE", "BRanche", "BRAnCHE", "émilie", "éMILIE", "émiLie", "aujourd'hui", "Aujourd'hui", ]:
self.assertFalse(self.oSpellChecker.isValid(sWord), sWord)
def test_suggest (self):
for sWord in [
"déelirranttesss", "vallidasion", "Emilie", "exibission", "ditirembique", "jai", "email",
"fatiqué", "coeur", "trèèèèèèèèès", "vraaaaiiiimeeeeennnt", "apele", "email", "Co2",
"emmppâiiiller", "testt", "apelaion", "exsepttion", "sintaxik", "ebriete", "ennormmement"
]:
aSugg = self.oSpellChecker.suggest(sWord)
#with timeblock(sWord):
# aSugg = self.oSpellChecker.suggest(sWord)
# print(sWord, "->", " ".join(aSugg))
def test_lemmas (self):
for sWord, sInfi in [
("jetez", "jeter"),
("finit", "finir"),
("mangé", "manger"),
("oubliait", "oublier"),
("arrivais", "arriver"),
("venait", "venir"),
("prendre", "prendre")
]:
self.assertIn(sInfi, self.oSpellChecker.getLemma(sWord))
class TestConjugation (unittest.TestCase):
"Tests des conjugaisons"
@classmethod
def setUpClass (cls):
pass
|
| ︙ | ︙ |