Skip to content

Commit 448ed22

Browse files
committed
Fix antonym quizzes of concepts with multiple grammatical forms.
When quizzing the antonym of one grammatical form of a concept with multiple grammatical forms, Toisto would accept all grammatical forms of the antonym concept. For example, when quizzing the antonym of halvempi in Finnish (cheaper), Toisto would accept kallis (expensive), kalliimpi (more expensive), and kallein (most expensive) as answer. Fixed to only accept the same grammatical form of the antonym concept, kalliimpi (more expensive) in the example. Fixes #893.
1 parent 77ae8e4 commit 448ed22

File tree

3 files changed

+57
-10
lines changed

3 files changed

+57
-10
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to Toisto will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [Unreleased]
8+
9+
### Fixed
10+
11+
- When quizzing the antonym of one grammatical form of a concept with multiple grammatical forms, Toisto would accept all grammatical forms of the antonym concept. For example, when quizzing the antonym of halvempi in Finnish (cheaper), Toisto would accept kallis (expensive), kalliimpi (more expensive), and kallein (most expensive) as answer. Fixed to only accept the same grammatical form of the antonym concept, kalliimpi (more expensive) in the example. Fixes [#893](https://github.com/fniessink/toisto/issues/893).
12+
713
## 0.29.0 - 2024-11-02
814

915
### Added

src/toisto/model/quiz/quiz_factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def related_concept_quizzes(
195195
Labels(),
196196
Labels(meanings),
197197
)
198-
for label in concept.labels(target_language).non_colloquial
198+
for label in concept.own_labels(target_language).non_colloquial
199199
)
200200

201201
def order_quizzes(self, concept: Concept, previous_quizzes: Quizzes, min_word_count: int = 5) -> Quizzes:

tests/toisto/model/quiz/test_quiz_factory.py

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,16 @@ def create_verb_with_infinitive_and_number_and_person(self) -> Concept:
115115
),
116116
)
117117

118-
def create_adjective_with_degrees_of_comparison(self) -> Concept:
118+
def create_adjective_with_degrees_of_comparison(self, antonym: str = "") -> Concept:
119119
"""Create an adjective with degrees of comparison."""
120-
return self.create_concept(
121-
"big",
122-
{
123-
"positive degree": dict(en="big", nl="groot"),
124-
"comparative degree": dict(en="bigger", nl="groter"),
125-
"superlative degree": dict(en="biggest", nl="grootst"),
126-
},
127-
)
120+
big: dict[str, object] = {
121+
"positive degree": dict(en="big", nl="groot"),
122+
"comparative degree": dict(en="bigger", nl="groter"),
123+
"superlative degree": dict(en="biggest", nl="grootst"),
124+
}
125+
if antonym:
126+
big["antonym"] = antonym
127+
return self.create_concept("big", big)
128128

129129
def create_noun(self) -> Concept:
130130
"""Create a simple noun."""
@@ -540,6 +540,47 @@ def test_degrees_of_comparison_with_synonyms(self):
540540
create_quizzes(FI_EN, concept),
541541
)
542542

543+
def test_degrees_of_comparison_with_antonym(self):
544+
"""Test that quizzes can be generated for degrees of comparison with antonym."""
545+
self.language_pair = NL_EN
546+
concept = self.create_adjective_with_degrees_of_comparison(antonym="small")
547+
self.create_concept(
548+
"small",
549+
{
550+
"antonym": "big",
551+
"positive degree": dict(en="small", nl="klein"),
552+
"comparative degree": dict(en="smaller", nl="kleiner"),
553+
"superlative degree": dict(en="smallest", nl="kleinst"),
554+
},
555+
)
556+
positive_degree, comparative_degree, superlative_degree = concept.leaf_concepts(NL)
557+
self.assertSetEqual(
558+
{
559+
self.create_quiz(positive_degree, "groot", ["big"], READ),
560+
self.create_quiz(positive_degree, "groot", ["groot"], DICTATE),
561+
self.create_quiz(positive_degree, "groot", ["big"], INTERPRET),
562+
self.create_quiz(positive_degree, "big", ["groot"], WRITE),
563+
self.create_quiz(comparative_degree, "groter", ["bigger"], READ),
564+
self.create_quiz(comparative_degree, "groter", ["groter"], DICTATE),
565+
self.create_quiz(comparative_degree, "groter", ["bigger"], INTERPRET),
566+
self.create_quiz(comparative_degree, "bigger", ["groter"], WRITE),
567+
self.create_quiz(superlative_degree, "grootst", ["biggest"], READ),
568+
self.create_quiz(superlative_degree, "grootst", ["grootst"], DICTATE),
569+
self.create_quiz(superlative_degree, "grootst", ["biggest"], INTERPRET),
570+
self.create_quiz(superlative_degree, "biggest", ["grootst"], WRITE),
571+
self.create_quiz(concept, "groot", ["groter"], COMPARATIVE_DEGREE),
572+
self.create_quiz(concept, "groot", ["grootst"], SUPERLATIVE_DEGREE),
573+
self.create_quiz(concept, "groot", ["klein"], ANTONYM),
574+
self.create_quiz(concept, "groter", ["groot"], POSITIVE_DEGREE),
575+
self.create_quiz(concept, "groter", ["grootst"], SUPERLATIVE_DEGREE),
576+
self.create_quiz(concept, "groter", ["kleiner"], ANTONYM),
577+
self.create_quiz(concept, "grootst", ["groot"], POSITIVE_DEGREE),
578+
self.create_quiz(concept, "grootst", ["groter"], COMPARATIVE_DEGREE),
579+
self.create_quiz(concept, "grootst", ["kleinst"], ANTONYM),
580+
},
581+
create_quizzes(NL_EN, concept),
582+
)
583+
543584
def test_grammatical_person(self):
544585
"""Test that quizzes can be generated for grammatical person."""
545586
self.language_pair = NL_EN

0 commit comments

Comments
 (0)