From 86daa52ac451c2d74d1a158894281edc54086c09 Mon Sep 17 00:00:00 2001
From: Enzo Simonnet <enzosim@laposte.net>
Date: Thu, 20 Oct 2022 08:33:11 +0000
Subject: [PATCH] =?UTF-8?q?def=20+=20exemples=20OK=20(sauf=20exemples=20no?=
 =?UTF-8?q?n=20labell=C3=A9s)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 parsers/en_en.py | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/parsers/en_en.py b/parsers/en_en.py
index a2e0b8e..32c9392 100644
--- a/parsers/en_en.py
+++ b/parsers/en_en.py
@@ -51,19 +51,25 @@ class En_en_straktor(Wikstraktor):
 		while i < len(l.fullitems):
 			newSense = Sense(f"{baseId}{i}")
 			li = self.wtp.parse(l.fullitems[i])
-			j=0
+			j = 0
 			while j < len(li.templates) and li.templates[j].normal_name() != self.constants['t_deflabel']:
 				j += 1
 			if j < len(li.templates):
-				newSense.set_domain(li.templates[j].arguments[1].value)#We could use the second parameter for a comment
+				newSense.set_domain(li.templates[j].arguments[-1].value)#We could use the second parameter for a comment
 				newSense.add_def(self.wiki_language, self.wtp.parse(li.get_lists()[0].items[0]).plain_text().strip())
+				while j < len(li.templates)-1 and li.templates[j+1].normal_name() == self.constants['t_ex']:
+					newSense.add_example(li.templates[j+1].arguments[1].value)
+					j += 1
 				senses.append(newSense)
-				if len(li.get_lists(pattern = '##')) > 0:
-					for j, k in enumerate(li.get_lists(pattern = '##')[0].items):
-						if self.wtp.parse(k).templates[0].normal_name() == self.constants['t_deflabel']:
-							newSense2 = Sense(f"{baseId}{i}{j}")
-							newSense2.set_domain(self.wtp.parse(k).templates[0].arguments[1].value)#We could use the second parameter for a comment
-							newSense2.add_def(self.wiki_language, self.wtp.parse(k).plain_text().strip())
+				if len(li.get_lists(pattern = '##')) > 0 :
+					for cnt, k in enumerate (li.get_lists(pattern = '##')[0].items):
+							if self.wtp.parse(k).templates[0].normal_name() == self.constants['t_deflabel']:
+								newSense2 = Sense(f"{baseId}{i}{cnt}")
+								newSense2.set_domain(self.wtp.parse(k).templates[0].arguments[-1].value)#We could use the second parameter for a comment
+								newSense2.add_def(self.wiki_language, self.wtp.parse(k).plain_text().strip())
+							for a in self.wtp.parse(li.get_lists(pattern = '##')[0].fullitems[cnt]).templates:
+								if a.normal_name() == self.constants['t_ex']:
+									newSense2.add_example(a.arguments[-1].value)
 							senses.append(newSense2)
 			# TODO: process examples
 			i += 1
-- 
GitLab