Skip to content
Snippets Groups Projects
Commit dc24ceae authored by Mathieu Loiseau's avatar Mathieu Loiseau
Browse files

accentS in wk_en

parent f391b7f3
No related branches found
No related tags found
No related merge requests found
......@@ -21,17 +21,19 @@ class En_en_straktor(Wikstraktor):
while i < len(l.fullitems):
p = Pronunciation()
templates = self.wtp.parse(l.fullitems[i]).templates
a = None
acc = None
for j, t in enumerate(templates):
if (t.normal_name() == self.constants['t_acc'] and templates[j+1].normal_name()!= self.constants['t_acc']):
a = t.arguments[0].value
acc = t.arguments
elif t.normal_name() == self.constants['t_ipa']:
p.set_transcription(t.arguments[1].value)
p.set_accent(a)
if acc != None:
for a in acc:
p.set_accent(a.value)
elif t.normal_name() == self.constants['t_snd']:
p.add_sound(self.get_file_url(t.arguments[1].value), a)
p.add_sound(self.get_file_url(t.arguments[1].value), t.arguments[2].value)
if j==len(templates)-1 or templates[j+1].normal_name()== self.constants['t_acc'] :
if p.ipa != None or p.accent != None:
if p.ipa != None or p.has_accents():
pronunciations.append(p)
p = Pronunciation()
i += 1
......
......@@ -64,13 +64,16 @@ class Pronunciation(SubInfo):
super().__init__(prefix)
self.ipa = None
self.sounds = []
self.accent = None
self.accents = set()
def set_transcription(self, tscpt):
self.ipa = tscpt
def set_accent(self, accent):
self.accent = accent
self.accents.add(accent)
def has_accents(self):
return len(self.accents) > 0
def add_sound(self, url, accent=None):
self.sounds.append(Sound(url,accent))
......@@ -81,8 +84,8 @@ class Pronunciation(SubInfo):
snds.append(s.serializable())
res = super().serializable(prefix)
res['transcript'] = self.ipa
if self.accent != None:
res['accent'] = self.accent
if self.has_accents():
res['accents'] = list(self.accents)
res['sounds'] = snds
return res
......@@ -90,7 +93,7 @@ class Pronunciation(SubInfo):
return json.dumps(self.serializable(''))
def __eq__(self, other):
res = isinstance(other, self.__class__) and self.ipa == other.ipa and self.accent == other.accent and len(self.sounds)==len(other.sounds)
res = isinstance(other, self.__class__) and self.ipa == other.ipa and self.accents == other.accents and len(self.sounds)==len(other.sounds)
i = 0
while res and i<len(self.sounds):
res = self.sounds[i] == other.sounds[i]
......
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