From 692ead37a58ca5ae80d735bab4f962e323f2f415 Mon Sep 17 00:00:00 2001
From: Mathieu Loiseau <mathieu.loiseau@liris.cnrs.fr>
Date: Fri, 9 Jun 2023 18:22:35 +0200
Subject: [PATCH] alternative spellings

---
 parsers/en_constants.py |   2 ++
 parsers/en_en.py        |   2 ++
 parsers/fr_constants.py |   2 ++
 wikstraktor.py          |   8 ++++++++
 wikstraktor.sqlite      | Bin 20480 -> 20480 bytes
 5 files changed, 14 insertions(+)

diff --git a/parsers/en_constants.py b/parsers/en_constants.py
index aab251e..76eca3e 100644
--- a/parsers/en_constants.py
+++ b/parsers/en_constants.py
@@ -7,6 +7,8 @@ string_values = {
 	"t_snd":"audio", #template for audio
 	"t_acc":"a", #template for accents
 	"t_deflabel":"lb",
+	"t_alt":"alternative spelling of",
+	"t_alt_param":1, #number of the parameter of t_alt containing the other spelling
 	"t_ex":["ux", "usex"],
 	"t_lbl":["lb","lbl", "label"], #template for labels
 	"regions":{
diff --git a/parsers/en_en.py b/parsers/en_en.py
index 80d0688..a721c9b 100644
--- a/parsers/en_en.py
+++ b/parsers/en_en.py
@@ -81,6 +81,8 @@ class En_en_straktor(Wikstraktor):
 		def_text = parsed_def.plain_text().strip()
 		templates = parsed_def.templates
 		the_def = self.parse_template_1(templates)
+		if the_def == None:
+			the_def = self.parse_alt_spell(templates)
 		if the_def == None:
 			the_def = Definition(self.entry_language, def_text)
 		if the_def == None:
diff --git a/parsers/fr_constants.py b/parsers/fr_constants.py
index b769bba..66915f4 100644
--- a/parsers/fr_constants.py
+++ b/parsers/fr_constants.py
@@ -4,6 +4,8 @@ string_values = {
 "en":" {{langue|en}} ",
 "fr":"Français",
 "t_deflabel":["lexique", "info lex"],
+"t_alt":"variante de",
+"t_alt_param":0, #number of the parameter of t_alt containing the other spelling
 "t_ex":"exemple",
 	#Inexistants
 "t_ipa":"pron", #template for transcription
diff --git a/wikstraktor.py b/wikstraktor.py
index 7c1803a..f541cd4 100755
--- a/wikstraktor.py
+++ b/wikstraktor.py
@@ -623,6 +623,14 @@ class Wikstraktor:
 	def process_etymology(self, parsedwikitext):
 		pass#in subclass
 
+	def parse_alt_spell(self, templates):
+		the_def = None
+		for t in templates:
+			if t.normal_name() == self.constants['t_alt']:
+				the_def = Definition(self.entry_language, f"Alternate spelling of “{t.arguments[self.constants['t_alt_param']].value}”")
+				break
+		return the_def
+
 	#can be overloaded
 	def process_example(self, example_wiki_text):
 		k = 0
diff --git a/wikstraktor.sqlite b/wikstraktor.sqlite
index 4bd4ff7ed7864b28501c509097276c377e190f0f..b60d5703a8684738f7a25ed782234ade2c97f3c3 100644
GIT binary patch
delta 276
zcmZozz}T>Wae_3X@kAMCM&peMOYDW%xjr)RJM&HEeafrBlg+)3>*L14+gu)vRz_UL
zv4VoiES`;`Mg~U4x&~&t29^qjW>$ulR;K33hN-4zsfi}3W=Uoy#>QqA7RF}D28ITv
w=Bb8BM&=fYX-O$Y=H?cY3w+Dmtqk#)WoSy8Sq3=Gvam8H$z7W@eXlbC03x?X&Hw-a

delta 49
zcmZozz}T>Wae_3X!9*EnMuUwBOYC`Acr_UKo%ts7KIPTeSSZ2E+-Rjgd84=3W=G%s
FOaNf24sHMd

-- 
GitLab