Coverage for src/wiktextract/extractor/fr/tags.py: 87%

42 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-11-03 05:44 +0000

1# Grammatical glossary appendix: 

2# https://fr.wiktionary.org/wiki/Annexe:Glossaire_grammatical 

3# List of templates: 

4# https://fr.wiktionary.org/wiki/Wiktionnaire:Liste_de_tous_les_modèles 

5from .models import WordEntry 

6 

7# https://en.wikipedia.org/wiki/Grammatical_gender 

8GENDER_TAGS: dict[str, str | list[str]] = { 

9 "commun": "common", 

10 "féminin": "feminine", 

11 "masculin": "masculine", 

12 "neutre": "neuter", 

13 # https://fr.wiktionary.org/wiki/Modèle:mf 

14 "masculin et féminin identiques": ["masculine", "feminine"], 

15 # table header: https://fr.wiktionary.org/wiki/Modèle:fr-rég 

16 "masculin et féminin": ["masculine", "feminine"], 

17 # "Modèle:mf ?", "Modèle:fm ?" 

18 "masculin ou féminin (l’usage hésite)": ["masculine", "feminine"], 

19 "féminin ou masculin (l’usage hésite)": ["feminine", "masculine"], 

20 "invariable": "invariable", # Modèle:invar 

21 # Modèle:flex-ku-nommixt 

22 "masculin sing.": ["masculine", "singular"], 

23 "féminin sing.": ["feminine", "singular"], 

24 # Template:ja-flx-adj-な 

25 "neutre négatif": ["neuter", "negative"], 

26 "neutre passé": ["neuter", "past"], 

27 "neutre négatif passé": ["neuter", "negative", "past"], 

28 "poli négatif": ["polite", "negative"], 

29 "poli passé": ["polite", "past"], 

30 "poli négatif passé": ["polite", "negative", "past"], 

31 # Template:m 

32 "masculin animé": ["masculine", "animate"], 

33 "masculin inanimé": ["masculine", "inanimate"], 

34 # Template:f 

35 "féminin animé": ["feminine", "animate"], 

36 "féminin inanimé": ["feminine", "inanimate"], 

37 # Template:n 

38 "neutre animé": ["neuter", "animate"], 

39 "neutre inanimé": ["neuter", "inanimate"], 

40 # Template:fr-rég 

41 "masculin\net féminin": ["masculine", "feminine"], 

42} 

43 

44# https://en.wikipedia.org/wiki/Grammatical_number 

45NUMBER_TAGS: dict[str, str | list[str]] = { 

46 "singulier": "singular", 

47 "pluriel": "plural", 

48 "duel": "dual", 

49 "collectif": "collective", 

50 "singulatif": "singulative", 

51 "indénombrable": "uncountable", # sv-nom-c-ind 

52 "au singulier": "singular", 

53 "au singulier uniquement": "singular-only", 

54 "au pluriel": "plural", 

55 "au pluriel uniquement": "plural-only", 

56 "singulier et pluriel identiques": ["singular", "plural"], 

57 "nom collectif": "collective", 

58 # "générique": "", # Modèle:g 

59 # "nom d'unité": "", # Modèle:nu 

60 "généralement indénombrable": "uncountable", 

61 "dénombrable": "countable", 

62 # Modèle:br-nom 

63 "pluriel 1": "plural", 

64 "pluriel 2": "plural", 

65 "pluriel 3": "plural", 

66 "pluriel 4": "plural", 

67 # https://fr.wiktionary.org/wiki/Modèle:avk-tab-conjug 

68 "1": "first-person", 

69 "2": "second-person", 

70 "3": "third-person", 

71 "4": "fourth-person", 

72 # Template:nl-conj-cons 

73 # https://en.wikipedia.org/wiki/Dutch_grammar#Personal_pronouns 

74 "ik": ["first-person", "singular"], 

75 "jij": ["second-person", "singular", "informal"], 

76 "hij, zij, het": "third-person", 

77 "wij": ["first-person", "plural"], 

78 "jullie": ["second-person", "plural", "informal"], 

79 "zij": ["third-person", "plural"], 

80 "u": "second-person", 

81} 

82 

83# https://en.wikipedia.org/wiki/Grammatical_mood 

84MOOD_TAGS: dict[str, str] = { 

85 "indicatif": "indicative", 

86 "subjonctif": "subjunctive", 

87 "conditionnel": "conditional", 

88 "impératif": "imperative", 

89 "volitif": "volitive", 

90 "déclaratif": "declarative", 

91 "interrogatif": "interrogative", 

92 "aperceptif": "apperceptive", 

93 "euphémique": "euphemistic", 

94 "évidentiel": "evidential", 

95 "spéculatif": "speculative", 

96 "assertif": "assertive", 

97 "hortatif": "hortative", 

98 "promissif": "promissive", 

99 "conditionnel / subjonctif": ["conditional", "subjunctive"], 

100 "conjonctif": "subjunctive", 

101 "provisionnel": "temporal", 

102 # Template:de-conj 

103 "subjonctif i": "subjunctive-i", 

104 "subjonctif ii": "subjunctive-ii", 

105 "conjectural/volitif": ["conjectural", "volitive"], 

106} 

107 

108VERB_FORM_TAGS: dict[str, str | list[str]] = { 

109 "participe": "participle", 

110 "imparfait": "imperfect", 

111 # Template:ku-conj-trans 

112 "parfait": "perfect", 

113 "imparfait narratif": ["imperfect", "narrative"], 

114 "infinitif": "infinitive", 

115 "gérondif": "gerund", 

116 # template "pt-verbe-flexion" 

117 "infinitif personnel": ["infinitive", "personal"], 

118 "supin": "supine", 

119 # Template:ko-conj 

120 "conjugaison": "conjugation", 

121 "radical": "radical", 

122 "formes finales": "final", 

123 "registre formel": "formal", 

124 "registre informel": "informal", 

125 "non poli": "impolite", 

126 "poli": "polite", 

127 "formes nominales": "nominal", 

128 "formes conjonctives": "subjunctive", 

129 # Template:ja-在る 

130 "formes de base": "base-form", 

131 "affirmatif": "affirmative", 

132 "négatif": "negative", 

133 "adverbial": "adverbial", 

134 # Template:bg-verbe186 

135 "aoriste": "aorist", 

136 "participe passé passif": ["participle", "past", "passive"], 

137 "participe passé actif": ["participle", "past", "active"], 

138 "participe imparfait": ["participle", "imperfect"], 

139 "auxiliaire": "auxiliary", 

140 "bitransitif": "ditransitive", 

141 "déterminé": "determinate", 

142 "indéterminé": "indeterminate", 

143 # Template:irrégulier 

144 "irrégulier": "irregular", 

145} 

146 

147# https://en.wikipedia.org/wiki/Grammatical_case 

148CASE_TAGS: dict[str, str | list[str]] = { 

149 "ablatif": "ablative", 

150 "accusatif": "accusative", 

151 "accusatif génitif": ["accusative", "genitive"], 

152 "nominatif": "nominative", 

153 "datif": "dative", 

154 "génitif": "genitive", 

155 "vocatif": "vocative", 

156 "instrumental": "instrumental", 

157 "locatif": "locative", 

158 "comitatif": "comitative", 

159 "essif": "essive", 

160 "illatif": "illative", 

161 # Template:ro-nom-tab 

162 "nominatif\naccusatif": ["nominative", "accusative"], 

163 "datif\ngénitif": ["dative", "genitive"], 

164 # Template:ko-nom 

165 "nominatif / attributif": ["nominative", "attributive"], 

166 # Modèle:fro-adj 

167 "sujet": "subject", 

168 "régime": "oblique", 

169} 

170 

171# https://en.wikipedia.org/wiki/Grammatical_tense 

172TENSE_TAGS: dict[str, str | list[str]] = { 

173 "présent": "present", 

174 "passé": "past", 

175 "passé simple": "past", 

176 "futur": "future", 

177 "futur simple": "future", 

178 # https://en.wikipedia.org/wiki/Passé_composé 

179 "passé composé": ["past", "multiword-construction"], 

180 "plus-que-parfait": "pluperfect", 

181 "passé antérieur": ["past", "anterior"], 

182 "futur antérieur": ["future", "perfect"], 

183 "prétérit": "preterite", 

184 "présent simple,\n3ᵉ pers. sing.": ["present", "third-person", "singular"], 

185 "participe passé": ["participle", "past"], 

186 "participe présent": ["participle", "present"], 

187 # Template:ku-conj-trans 

188 "présent progressif": ["present", "progressive"], 

189 "prétérit et imparfait": ["preterite", "imperfect"], 

190 "non passé": "non-past", 

191 "présent / futur": ["present", "future"], 

192 # Template:de-conj 

193 "futur i": "future-i", 

194 "futur ii": "future-ii", 

195 # Template:it-irrégulier-avere-1 

196 "présent affirmatif": ["present", "affirmative"], 

197 "présent négatif": ["present", "negative"], 

198} 

199 

200# https://en.wikipedia.org/wiki/Grammatical_person 

201PERSON_TAGS: dict[str, str | list[str]] = { 

202 "1ᵉ personne": "first-person", 

203 "1ʳᵉ personne": "first-person", 

204 "2ᵉ personne": "second-person", 

205 "3ᵉ personne": "third-person", 

206 # Modèle:avk-conj 

207 "1ʳᵉ du sing.": ["first-person", "singular"], 

208 "2ᵉ du sing.": ["second-person", "singular"], 

209 "3ᵉ du sing.": ["third-person", "singular"], 

210 "1ʳᵉ du plur.": ["first-person", "plural"], 

211 "2ᵉ du plur.": ["second-person", "plural"], 

212 "3ᵉ du plur.": ["third-person", "plural"], 

213 "4ᵉ du plur.": ["fourth-person", "plural"], 

214} 

215 

216SEMANTICS_TAGS: dict[str, str] = { 

217 # https://en.wikipedia.org/wiki/Definiteness 

218 "défini": "definite", 

219 "indéfini": "indefinite", 

220 # template:ro-nom-tab 

221 "articulé": "definite", 

222 "non articulé": "indefinite", 

223} 

224 

225COMPARISON_TAGS: dict[str, str] = { 

226 # https://en.wikipedia.org/wiki/Comparison_(grammar) 

227 "positif": "positive", 

228 "comparatif": "comparative", 

229 "superlatif": "superlative", 

230 "non comparable": "not-comparable", 

231 "superlatif absolu": ["superlative", "absolute"], 

232} 

233 

234# https://en.wikipedia.org/wiki/Occitan_language#Writing_system 

235OCCITAN_NORM_TAGS: dict[str, str] = { 

236 # https://fr.wiktionary.org/wiki/Modèle:oc-norme_mistralienne 

237 "graphie mistralienne": "Mistralian", 

238 # https://fr.wiktionary.org/wiki/Modèle:oc-norme_classique 

239 # "graphie normalisée": "", 

240 # Modèle:oc-norme bonnaudienne 

241 # "graphie bonnaudienne": "", 

242} 

243 

244# https://en.wikipedia.org/wiki/Breton_mutations 

245# https://fr.wiktionary.org/wiki/Modèle:br-nom 

246BRETON_MUTATION_TAGS: dict[str, str] = { 

247 "non muté": "unmutated", 

248 "adoucissante": "mutation-soft", 

249 "durcissante": "mutation-hard", 

250 "spirante": "mutation-spirant", 

251 "nasale": "mutation-nasal", 

252} 

253 

254JA_TAGS: dict[str, str] = { 

255 # https://fr.wiktionary.org/wiki/Modèle:ja-trans 

256 "kanji": "kanji", 

257 "hiragana": "hiragana", 

258 "katakana": "katakana", 

259 "transcription": "transcription", 

260} 

261 

262OTHER_GRAMMATICAL_TAGS: dict[str, str] = { 

263 # https://fr.wiktionary.org/wiki/Modèle:be-tab-cas 

264 "prépositionnel": "prepositional", 

265 "anglicisme": "Anglicism", 

266 "pronominal": "pronominal", 

267 "diminutif": "diminutive", 

268 "réfléchi": "reflexive", # Modèle:réfl 

269 "réciproque": "reciprocal", # Modèle:réciproque 

270 "impersonnel": "impersonal", # Modèle:impers 

271 "transitif": "transitive", # Modèle:t 

272 "transitif indirect": ["transitive", "indirect"], # Modèle:transitif indir 

273 "intransitif": "intransitive", # Modèle:i 

274 "injurieux": "offensive", # Modèle:injurieux 

275 # Modèle:zh-formes 

276 "simplifié": "Simplified-Chinese", 

277 "traditionnel": "Traditional-Chinese", 

278 # Modèle:flex-ku-nomf 

279 "ézafé principal": ["ezafe", "primary"], 

280 "ézafé secondaire": ["ezafe", "secondary"], 

281 "cas oblique": "oblique", 

282 # Modèle:ku-conj-trans 

283 "forme affirmative": "affirmative", 

284 "forme négative": "negative", 

285 # Modèle:bg-nom 

286 "forme de base": "base-form", 

287 "pluriel numéral": ["plural", "numeral"], 

288 "animé": "animate", 

289 "inanimé": "inanimate", 

290 # Template:ko-nom 

291 "hangeul": "hangeul", 

292 "hanja": "hanja", 

293 "avec clitique": "clitic", 

294 "indéclinable": "indeclinable", 

295 "toponyme": "toponymic", 

296 "applicatif": "applicative", 

297 "causatif": "causative", 

298 "sigle": "abbreviation", 

299 "attributif": "attributive", 

300 "prédicatif": "predicative", 

301 # Template:cy-mut 

302 "non muté": "unmutated", 

303 "lénition": "lenition", 

304 "nasalisation": "nasalization", 

305 "syllabaire": "Syllabics", 

306 "par ellipse": "ellipsis", # Template:ellipse 

307 "ironique": "ironic", 

308 "suffixe": "suffix", 

309 # Template:avk-tab-conjug 

310 "conjugaison présent indicatif": ["present", "indicative"], 

311 # Modèle:de-adjectif-déclinaisons 

312 "déclinaison forte": "strong", 

313 "déclinaison faible": "weak", 

314 "déclinaison mixte": "mixed", 

315 "singulier / pluriel": ["singular", "plural"], 

316 # Template:ja-する 

317 "inaccompli": "uncompleted", 

318 "imperfectif (未然形, mizen-kei)": "imperfective", 

319 "continuatif (連用形, ren'yō-kei)": "continuative", 

320 "conclusif (終止形, shūshi-kei)": "terminal", 

321 "attributif (連体形, rentai-kei)": "attributive", 

322 "hypothétique (仮定形, katei-kei)": "hypothetical", 

323 "impératif (命令形, meirei-kei)": "imperative", 

324 "forme en -te": "gerund", 

325 "désidératif adjectif variable (flexions)": ["desiderative", "adjective"], 

326 # Template:ja-flx-adj-な 

327 "imperfectif (未然形)": "imperfective", 

328 "continuatif (連用形)": "continuative", 

329 "conclusif (終止形)": "terminal", 

330 "attributif (連体形)": "attributive", 

331 "hypothétique (仮定形)": "hypothetical", 

332 "impératif (命令形)": "imperative", 

333 # Template:ko-nom 

334 "avec\nclitique": "clitic", 

335 "thème": "stem", 

336 "nominatif\n/ attributif": ["nominative", "attributive"], 

337 "seulement": "exclusive", 

338} 

339 

340# template text before gloss 

341SENSE_TAGS: dict[str, str] = { 

342 # https://fr.wiktionary.org/wiki/Modèle:figuré 

343 # https://fr.wiktionary.org/wiki/Catégorie:Modèles_de_relation_entre_les_définitions 

344 # Catégorie:Modèles de genre textuel 

345 # Catégorie:Modèles de registre 

346 "sens figuré": "figuratively", 

347 "sens propre": "literally", 

348 "par métonymie": "metonymically", # Modèle:par métonymie 

349 "par hyperbole": "hyperbole", 

350 "par extension": "broadly", 

351 "par analogie": "analogy", 

352 "en particulier": "especially", 

353 "par litote": "litotes", 

354 "par euphémisme": "euphemism", 

355 "spécifiquement": "specifically", 

356 "génériquement": "generically", 

357 "spécialement": "especially", 

358 "généralement": "generally", 

359 "enclise": "enclitic", 

360 "idiotisme": "idiomatic", 

361 "péjoratif": "pejorative", 

362 "désuet": "obsolete", 

363 "archaïsme": "archaic", 

364 "vieilli": "dated", 

365 "néologisme": "neologism", 

366 "argot": "slang", 

367 "rare": "rare", 

368 # "plus rare": "rare", 

369 "littéraire": "literary", # Modèle:littéraire 

370 "poétique": "poetic", # Modèle:poétique 

371 # "didactique": "", # Modèle:didactique 

372 "soutenu": "formal", # Modèle:soutenu 

373 "informel": "informal", # Modèle:informel 

374 "familier": "familiar", # Modèle:familier 

375 "très familier": "very-familiar", # Modèle:très familier 

376 "populaire": "colloquial", # Modèle:populaire 

377 "vulgaire": "vulgar", # Modèle:vulgaire 

378 "langage enfantin": "childish", # Modèle:enfantin 

379 # Catégorie:Modèles de thématique 

380 "anglicisme informatique": "Anglicism", 

381 "proverbe": "proverb", 

382 "collectivement": "collectively", 

383 "courant": "common", # Modèle:courant 

384 "adjectif attribut": ["adjective", "attributive"], 

385} 

386 

387# https://en.wikipedia.org/wiki/Voice_(grammar) 

388VOICE_TAGS: dict[str, str | list[str]] = { 

389 # https://fr.wiktionary.org/wiki/Modèle:eo-conj 

390 "participe actif": ["participle", "active"], 

391 "participe passif": ["participle", "passive"], 

392 "adverbe actif": ["adverb", "active"], 

393 "adverbe passif": ["adverb", "passive"], 

394 "substantif\nactif": ["subsuntive", "active"], 

395 "substantif\npassif": ["subsuntive", "passive"], 

396 "actif": "active", 

397 "passif": "passive", 

398 "adverbe": "adverb", 

399} 

400 

401# Module:lexique/data 

402LEXIQUE_TAGS = { 

403 "hindouisme": "Hinduism", 

404 "judaïsme": "Judaism", 

405 "marxisme": "Marxism", 

406 "nazisme": "Nazism", 

407 "physique": "physical", 

408 "rhétorique": "rhetoric", 

409 "antiquité": "Ancient", 

410 "antiquité grecque": "Ancient-Greek", 

411 "antiquité romaine": "Ancient-Roman", 

412 "bible": "Biblical", 

413 "moyen âge": "Middle-Ages", 

414 "union européenne": "European-Union", 

415 "analyse": "analytic", 

416} 

417 

418# Template:cmn-pron 

419# https://fr.wiktionary.org/wiki/自由 

420ZH_PRON_TAGS = { 

421 "pinyin": "Pinyin", 

422 "efeo": "EFEO", # https://en.wikipedia.org/wiki/EFEO_Chinese_transcription 

423 "wade-giles": "Wade-Giles", 

424 "yale": "Yale", 

425 "zhuyin": "Bopomofo", 

426 "mandarin": "Mandarin", 

427 "cantonais": "Cantonese", 

428 "cantonais (yue)": "Cantonese", 

429 "jyutping": "Jyutping", 

430 "hakka": "Hakka", 

431 "pha̍k-fa-sṳ": "Phak-fa-su", 

432 "meixian, guangdong": ["Meixian", "Guangdong"], 

433 "jin": "Jin", 

434 "mindong": "Min-Dong", 

435 # https://en.wikipedia.org/wiki/Bàng-uâ-cê 

436 "bàng-uâ-cê (fuzhou)": ["Bang-ua-ce", "Fuzhou"], 

437 "minnan": "Min-Nan", 

438 "pe̍h-ōe-jī (hokkien : fujian, taïwan)": [ 

439 "Peh-oe-ji", 

440 "Hokkien", 

441 "Fujian", 

442 "Taiwan", 

443 ], 

444 "chaozhou, peng'im": ["Chaozhou", "Peng'im"], 

445 "wu": "Wu", 

446 "shanghai": "Shanghai", 

447 "chinois médiéval": "Medieval-Chinese", 

448 "chinois archaïque": "Old-Chinese", 

449 "baxter-sagart": "Baxter-Sagart", 

450 "zhengzhang": "Zhengzhang", 

451} 

452 

453ASPECT_TAGS = { 

454 "perfectif": "perfective", # Modèle:perfectif 

455 "imperfectif": "imperfective", # Modèle:imperfectif 

456} 

457 

458GRAMMATICAL_TAGS: dict[str, str | list[str]] = { 

459 **GENDER_TAGS, 

460 **NUMBER_TAGS, 

461 **MOOD_TAGS, 

462 **VERB_FORM_TAGS, 

463 **CASE_TAGS, 

464 **TENSE_TAGS, 

465 **PERSON_TAGS, 

466 **SEMANTICS_TAGS, 

467 **COMPARISON_TAGS, 

468 **OCCITAN_NORM_TAGS, 

469 **BRETON_MUTATION_TAGS, 

470 **JA_TAGS, 

471 **OTHER_GRAMMATICAL_TAGS, 

472 **SENSE_TAGS, 

473 **VOICE_TAGS, 

474 **LEXIQUE_TAGS, 

475 **ZH_PRON_TAGS, 

476 **ASPECT_TAGS, 

477} 

478 

479 

480def translate_raw_tags(data: WordEntry) -> WordEntry: 

481 from .topics import SLANG_TOPICS, TOPIC_TAGS 

482 

483 raw_tags = [] 

484 for raw_tag in data.raw_tags: 

485 raw_tag_lower = raw_tag.lower() 

486 if raw_tag_lower in GRAMMATICAL_TAGS: 

487 tr_tag = GRAMMATICAL_TAGS[raw_tag_lower] 

488 if isinstance(tr_tag, str) and tr_tag not in data.tags: 

489 data.tags.append(tr_tag) 

490 elif isinstance(tr_tag, list): 490 ↛ 484line 490 didn't jump to line 484 because the condition on line 490 was always true

491 for t in tr_tag: 

492 if t not in data.tags: 492 ↛ 491line 492 didn't jump to line 491 because the condition on line 492 was always true

493 data.tags.append(t) 

494 elif hasattr(data, "topics") and raw_tag_lower in TOPIC_TAGS: 

495 data.topics.append(TOPIC_TAGS[raw_tag_lower]) 

496 elif hasattr(data, "topics") and raw_tag_lower in SLANG_TOPICS: 496 ↛ 497line 496 didn't jump to line 497 because the condition on line 496 was never true

497 data.topics.append(SLANG_TOPICS[raw_tag_lower]) 

498 if "slang" not in data.tags: 

499 data.tags.append("slang") 

500 else: 

501 raw_tags.append(raw_tag) 

502 data.raw_tags = raw_tags 

503 return data