french-wiktionary-flashcards

Easily create Anki flashcards from Wiktionary data.
Log | Files | Refs | README

commit 53c51980818258036297986ef3d315c0009ead91
parent 8f308d86f0157584181afadcd3b3f122690eb32a
Author: David Schlachter <t480-debian-git@schlachter.ca>
Date:   Sun, 11 Jan 2026 14:09:13 -0500

Fix genders bug and add number

Diffstat:
MREADME.md | 4++--
Msetup.go | 23+++++++++++++++++++----
2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md @@ -84,8 +84,8 @@ Usage of french-wiktionary-flashcards: # TODO - Include context hints (e.g. see entry for 'panais', which has "Agriculture", - "Par métonomie", etc) in definitions; and maybe the "singular and plural" box - as well + "Par métonomie", etc) in definitions (tricky because the tags are in english + and I would want to display them in the target language). - allow setting the language for initial processing, so that we could support languages other than French - general code cleanup & organization diff --git a/setup.go b/setup.go @@ -141,13 +141,28 @@ func populateDictionary(rawDictionary string, db *sql.DB) error { if len(result.Sounds) > 0 { entry.Sound = result.Sounds[0].IPA } + + var genders, numbers []string for _, r := range result.Tags { - var genders []string - if r == "masculine" || r == "feminine" { - genders = append(genders, r) + switch r { + case "masculine": + genders = append(genders, "masculin") + case "feminine": + genders = append(genders, "féminin") + case "plural": + numbers = append(numbers, "pluriel") + case "singular": + numbers = append(numbers, "singulier") } - entry.Gender = strings.Join(genders, " / ") } + entry.Gender = strings.Join( + []string{ + strings.Join(genders, " / "), + strings.Join(numbers, " et "), + }, + " ", + ) + for _, s := range result.Senses { var example string if len(s.Examples) > 0 {