Add verb conjugation module

This commit is contained in:
Griatch 2021-03-22 00:46:04 +01:00
parent 2c7163ba74
commit 24a6d2cfab
10 changed files with 10193 additions and 22 deletions

View file

@ -0,0 +1,237 @@
"""
Unit tests for verb conjugation.
"""
from parameterized import parameterized
from django.test import TestCase
from . import conjugate
class TestVerbConjugate(TestCase):
"""
Test the conjugation.
"""
@parameterized.expand([
("have", "have"),
("swim", "swim"),
("give", "give"),
("given", "give"),
("am", "be"),
("doing", "do"),
("are", "be"),
])
def test_verb_infinitive(self, verb, expected):
"""
Test the infinite-getter.
"""
self.assertEqual(expected, conjugate.verb_infinitive(verb))
@parameterized.expand([
("inf", "have", "have"),
("inf", "swim", "swim"),
("inf", "give", "give"),
("inf", "given", "give"),
("inf", "am", "be"),
("inf", "doing", "do"),
("inf", "are", "be"),
("2sgpres", "am", "are"),
("3sgpres", "am", "is"),
])
def test_verb_conjugate(self, tense, verb, expected):
"""
Test conjugation for different tenses.
"""
self.assertEqual(expected, conjugate.verb_conjugate(verb, tense=tense))
@parameterized.expand([
("1st", "have", "have"),
("1st", "swim", "swim"),
("1st", "give", "give"),
("1st", "given", "give"),
("1st", "am", "am"),
("1st", "doing", "do"),
("1st", "are", "am"),
("2nd", "were", "are"),
("3rd", "am", "is"),
])
def test_verb_present(self, person, verb, expected):
"""
Test the present.
"""
self.assertEqual(expected, conjugate.verb_present(verb, person=person))
@parameterized.expand([
("have", "having"),
("swim", "swimming"),
("give", "giving"),
("given", "giving"),
("am", "being"),
("doing", "doing"),
("are", "being"),
])
def test_verb_present_participle(self, verb, expected):
"""
Test the present_participle
"""
self.assertEqual(expected, conjugate.verb_present_participle(verb))
@parameterized.expand([
("1st", "have", "had"),
("1st", "swim", "swam"),
("1st", "give", "gave"),
("1st", "given", "gave"),
("1st", "am", "was"),
("1st", "doing", "did"),
("1st", "are", "was"),
("2nd", "were", "were"),
])
def test_verb_past(self, person, verb, expected):
"""
Test the past getter.
"""
self.assertEqual(expected, conjugate.verb_past(verb, person=person))
@parameterized.expand([
("have", "had"),
("swim", "swum"),
("give", "given"),
("given", "given"),
("am", "been"),
("doing", "done"),
("are", "been"),
])
def test_verb_past_participle(self, verb, expected):
"""
Test the past participle.
"""
self.assertEqual(expected, conjugate.verb_past_participle(verb))
def test_verb_get_all_tenses(self):
"""
Test getting all tenses.
"""
self.assertEqual(list(conjugate.verb_tenses_keys.keys()), conjugate.verb_all_tenses())
@parameterized.expand([
("have", "infinitive"),
("swim", "infinitive"),
("give", "infinitive"),
("given", "past participle"),
("am", "1st singular present"),
("doing", "present participle"),
("are", "2nd singular present"),
])
def test_verb_tense(self, verb, expected):
"""
Test the tense retriever.
"""
self.assertEqual(expected, conjugate.verb_tense(verb))
@parameterized.expand([
("inf", "have", True),
("inf", "swim", True),
("inf", "give", True),
("inf", "given", False),
("inf", "am", False),
("inf", "doing", False),
("inf", "are", False),
])
def test_verb_is_tense(self, tense, verb, expected):
"""
Test the tense-checker
"""
self.assertEqual(expected, conjugate.verb_is_tense(verb, tense))
@parameterized.expand([
("1st", "have", False),
("1st", "swim", False),
("1st", "give", False),
("1st", "given", False),
("1st", "am", True),
("1st", "doing", False),
("1st", "are", False),
("1st", "had", False),
])
def test_verb_is_present(self, person, verb, expected):
"""
Test the tense-checker
"""
self.assertEqual(expected, conjugate.verb_is_present(verb, person=person))
@parameterized.expand([
("have", False),
("swim", False),
("give", False),
("given", False),
("am", False),
("doing", True),
("are", False),
])
def test_verb_is_present_participle(self, verb, expected):
"""
Test the tense-checker
"""
self.assertEqual(expected, conjugate.verb_is_present_participle(verb))
@parameterized.expand([
("1st", "have", False),
("1st", "swim", False),
("1st", "give", False),
("1st", "given", False),
("1st", "am", False),
("1st", "doing", False),
("1st", "are", False),
("2nd", "were", True),
])
def test_verb_is_past(self, person, verb, expected):
"""
Test the tense-checker
"""
self.assertEqual(expected, conjugate.verb_is_past(verb, person=person))
@parameterized.expand([
("have", False),
("swimming", False),
("give", False),
("given", True),
("am", False),
("doing", False),
("are", False),
("had", False),
])
def test_verb_is_past_participle(self, verb, expected):
"""
Test the tense-checker
"""
self.assertEqual(expected, conjugate.verb_is_past_participle(verb))
@parameterized.expand([
("have", ("have", "has")),
("swimming", ("swimming", "swimming")),
("give", ("give", "gives")),
("given", ("given", "given")),
("am", ("are", "is")),
("doing", ("doing", "doing")),
("are", ("are", "is")),
("had", ("had", "had")),
])
def test_verb_actor_stance_components(self, verb, expected):
"""
Test the tense-checker
"""
self.assertEqual(expected, conjugate.verb_actor_stance_components(verb))