py/gadict.py
changeset 566 0bba61492c37
parent 565 ac68f2680ea0
child 568 4b610eaaf4be
--- a/py/gadict.py	Wed Sep 21 22:09:37 2016 +0300
+++ b/py/gadict.py	Wed Sep 21 22:40:23 2016 +0300
@@ -45,7 +45,7 @@
 
 class Sense:
 
-    def __init__(self, pos, tr_list = None, ex_list = None, ant_list = None, syn_list = None, rel_list = None, topic_list = None):
+    def __init__(self, pos, tr_list = None, ex_list = None, glos_list = None, ant_list = None, syn_list = None, rel_list = None, topic_list = None):
         if not pos:
             raise ParseException("Part of speech expected...\n")
         self.pos = pos
@@ -53,6 +53,7 @@
         if not tr_list:
             self.tr_list = []
         self.ex_list = ex_list
+        self.glos_list = glos_list
         self.ant_list = ant_list
         self.syn_list = syn_list
         self.rel_list = rel_list
@@ -67,6 +68,12 @@
         else:
             self.ex_list = [ex]
 
+    def add_glos(self, glos):
+        if self.glos_list:
+            self.glos_list.append(glos)
+        else:
+            self.glos_list = [glos]
+
     def add_ant(self, ant):
         if self.ant_list:
             self.ant_list.append(ant)
@@ -111,6 +118,7 @@
     TRANSL_POS_RE = regex.compile(u"^n|det|pron|adj|v|adv|prep|conj|num|int|phr|phr\\.v|contr|abbr|prefix$")
     TRANSL_RE = regex.compile(u"^(ru|uk|la|en): ([\\p{L}(].*)$")
     TRANSL_EX_RE = regex.compile(u"^(ru|uk|la|en)> ([-\\p{L}].*)$")
+    TRANSL_GLOS_RE = regex.compile(u"^(ru|uk|la|en)= ([-\\p{L}].*)$")
     TOPIC_RE = regex.compile(u"^topic: (\\p{L}.*)$")
     SYN_RE = regex.compile(u"^syn: (\\p{L}.*)$")
     ANT_RE = regex.compile(u"^ant: (\\p{L}.*)$")
@@ -341,5 +349,10 @@
                 sense.add_ex((m.group(1), m.group(2) + self.parse_translation_continuation()))
                 read = False
                 continue
+            m = self.TRANSL_GLOS_RE.match(self.line)
+            if m is not None:
+                sense.add_glos((m.group(1), m.group(2) + self.parse_translation_continuation()))
+                read = False
+                continue
             raise ParseException("""Uknown syntax...""")
         self.tran = senses