Skip to content
Snippets Groups Projects
Commit bd4c7d91 authored by Enzo Simonnet's avatar Enzo Simonnet
Browse files

def + exemples OK

exemples pas imbriqués comme il faut
N° des defs pas bon
parent 1f3789ad
No related branches found
No related tags found
No related merge requests found
...@@ -44,34 +44,42 @@ class En_en_straktor(Wikstraktor): ...@@ -44,34 +44,42 @@ class En_en_straktor(Wikstraktor):
def process_senses(self, entry, pos, sensesContent): def process_senses(self, entry, pos, sensesContent):
baseId = f"{entry}_{pos}_" baseId = f"{entry}_{pos}_"
#here we don't look at l = sensesContent.get_lists(('\\# ', '\\#:','\\## ', '\\##:' ))
l = sensesContent.get_lists()[0]
i = 0 i = 0
senses = [] senses = []
while i < len(l.fullitems): while i < len(l):
newSense = Sense(f"{baseId}{i}") if l[i].pattern == '\\# ':
li = self.wtp.parse(l.fullitems[i]) newSense = Sense(f"{baseId}{i}")
j = 0 if len(l[i].templates) > 0:
while j < len(li.templates) and li.templates[j].normal_name() != self.constants['t_deflabel']: newSense.set_domain(l[i].templates[-1].arguments[-1].value)#We could use the second parameter for a comment
j += 1 newSense.add_def(self.wiki_language, self.wtp.parse(l[i].items[0]).plain_text().strip())
if j < len(li.templates): elif l[i].pattern == '\\#:':
newSense.set_domain(li.templates[j].arguments[-1].value)#We could use the second parameter for a comment for j in l[i].items:
newSense.add_def(self.wiki_language, self.wtp.parse(li.get_lists()[0].items[0]).plain_text().strip()) if len(self.wtp.parse(j).templates) > 0:
while j < len(li.templates)-1 and li.templates[j+1].normal_name() == self.constants['t_ex']: newSense.add_example(self.wtp.parse(j).templates[0].arguments[-1].value)
newSense.add_example(li.templates[j+1].arguments[1].value) else:
j += 1 newSense.add_example(self.wtp.parse(j).plain_text().strip())
if i == len(l)-1 or l[i+1].pattern == '\\# ' or l[i+1].pattern == '\\## ':
senses.append(newSense) senses.append(newSense)
if len(li.get_lists(pattern = '##')) > 0 : cnt = 0
for cnt, k in enumerate (li.get_lists(pattern = '##')[0].items): while l[i].level == 3 and i < len(l) :
if self.wtp.parse(k).templates[0].normal_name() == self.constants['t_deflabel']: cnt +=1
newSense2 = Sense(f"{baseId}{i}{cnt}") if l[i].pattern == '\\## ':
newSense2.set_domain(self.wtp.parse(k).templates[0].arguments[-1].value)#We could use the second parameter for a comment newSense2 = Sense(f"{baseId}{i}{cnt}")
newSense2.add_def(self.wiki_language, self.wtp.parse(k).plain_text().strip()) if len(l[i].templates) > 0:
for a in self.wtp.parse(li.get_lists(pattern = '##')[0].fullitems[cnt]).templates: newSense2.set_domain(l[i].templates[-1].arguments[-1].value)#We could use the second parameter for a comment
if a.normal_name() == self.constants['t_ex']: newSense2.add_def(self.wiki_language, self.wtp.parse(l[i].items[0]).plain_text().strip())
newSense2.add_example(a.arguments[-1].value) elif l[i].pattern == '\\##:':
senses.append(newSense2) for j in l[i].items:
# TODO: process examples if len(self.wtp.parse(j).templates) > 0:
newSense2.add_example(self.wtp.parse(j).templates[0].arguments[-1].value)
else:
newSense2.add_example(self.wtp.parse(j).plain_text().strip())
if i == len(l)-1 or l[i+1].pattern == '\\# ' or l[i+1].pattern == '\\## ':
senses.append(newSense2)
i += 1
if cnt > 0:
i -= 1
i += 1 i += 1
return senses return senses
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment