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

Replace en_en.py

parent 966c7930
No related branches found
No related tags found
No related merge requests found
...@@ -41,6 +41,12 @@ class En_en_straktor(Wikstraktor): ...@@ -41,6 +41,12 @@ class En_en_straktor(Wikstraktor):
global debugEty global debugEty
debugEty += 1 debugEty += 1
return "Etymology" + str(debugEty) return "Etymology" + str(debugEty)
def process_POS(self,parsedwikitext):
pos = None
if parsedwikitext in self.constants['POS'].keys():
pos = self.constants['POS'][parsedwikitext]
return pos
def process_senses(self, entry, pos, sensesContent): def process_senses(self, entry, pos, sensesContent):
baseId = f"{entry}_{pos}_" baseId = f"{entry}_{pos}_"
...@@ -52,32 +58,38 @@ class En_en_straktor(Wikstraktor): ...@@ -52,32 +58,38 @@ class En_en_straktor(Wikstraktor):
if l[i].pattern == '\\# ': if l[i].pattern == '\\# ':
nombreDef += 1 nombreDef += 1
newSense = Sense(f"{baseId}{nombreDef}") newSense = Sense(f"{baseId}{nombreDef}")
if len(l[i].templates) > 0:
newSense.set_domain(l[i].templates[-1].arguments[-1].value)#We could use the second parameter for a comment
newSense.add_def(self.wiki_language, self.wtp.parse(l[i].items[0]).plain_text().strip()) newSense.add_def(self.wiki_language, self.wtp.parse(l[i].items[0]).plain_text().strip())
elif l[i].pattern == '\\#:': elif l[i].pattern == '\\#:':
for j in l[i].items: for j in l[i].items:
if len(self.wtp.parse(j).templates) > 0: k = 0
newSense.add_example(self.wtp.parse(j).templates[0].arguments[-1].value) isEx = 0
else: while k < len(self.wtp.parse(j).templates) and isEx == 0 :
if (self.wtp.parse(j).templates[k].normal_name() in self.constants['t_ex']):
newSense.add_example(self.wtp.parse(j).templates[0].arguments[-1].value)
isEx = 1
k += 1
if isEx == 0:
newSense.add_example(self.wtp.parse(j).plain_text().strip()) 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 == '\\## ': if i == len(l)-1 or l[i+1].pattern == '\\# ' or l[i+1].pattern == '\\## ':
senses.append(newSense) senses.append(newSense)
cnt = 0 cnt = 0
nombreSousDef = 0 nombreSousDef = 0
while l[i].level == 3 and i < len(l) : while i < len(l) and l[i].level == 3 :
cnt +=1 cnt +=1
if l[i].pattern == '\\## ': if l[i].pattern == '\\## ':
nombreSousDef += 1 nombreSousDef += 1
newSense2 = Sense(f"{baseId}{nombreDef}{nombreSousDef}") newSense2 = Sense(f"{baseId}{nombreDef}_{nombreSousDef}")
if len(l[i].templates) > 0:
newSense2.set_domain(l[i].templates[-1].arguments[-1].value)#We could use the second parameter for a comment
newSense2.add_def(self.wiki_language, self.wtp.parse(l[i].items[0]).plain_text().strip()) newSense2.add_def(self.wiki_language, self.wtp.parse(l[i].items[0]).plain_text().strip())
elif l[i].pattern == '\\##:': elif l[i].pattern == '\\##:':
for j in l[i].items: for j in l[i].items:
if len(self.wtp.parse(j).templates) > 0: k = 0
newSense2.add_example(self.wtp.parse(j).templates[0].arguments[-1].value) isEx = 0
else: while k < len(self.wtp.parse(j).templates) and isEx == 0 :
if (self.wtp.parse(j).templates[k].normal_name() in self.constants['t_ex']):
newSense2.add_example(self.wtp.parse(j).templates[0].arguments[-1].value)
isEx = 1
k += 1
if isEx == 0:
newSense2.add_example(self.wtp.parse(j).plain_text().strip()) 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 == '\\## ': if i == len(l)-1 or l[i+1].pattern == '\\# ' or l[i+1].pattern == '\\## ':
senses.append(newSense2) senses.append(newSense2)
......
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