From 2f2bb91d0f80385fa8f42adc5a5bb46a51b7f198 Mon Sep 17 00:00:00 2001 From: Ozbolt Menegatti Date: Tue, 12 Feb 2019 17:38:32 +0100 Subject: [PATCH] Supporting different xml:id variations --- wani.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/wani.py b/wani.py index 734d297..7ce397f 100644 --- a/wani.py +++ b/wani.py @@ -145,12 +145,13 @@ class Order(Enum): else: return Order.Any + def match(self, from_w, to_w): if self is Order.Any: return True - fi = int(from_w.id.split('.')[-1][1:]) - ti = int(to_w.id.split('.')[-1][1:]) + fi = from_w.int_id + ti = to_w.int_id if self is Order.FromTo: return fi < ti @@ -717,6 +718,11 @@ class Word: self.text = xml.text self.links = defaultdict(list) + last_num = self.id.split('.')[-1] + if last_num[0] not in '0123456789': + last_num = last_num[1:] + self.int_id = int(last_num) + assert(None not in (self.id, self.lemma, self.msd)) @staticmethod