Add syntax for glossary/explanation.
--- 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
--- a/py/gadict_c5.py Wed Sep 21 22:09:37 2016 +0300
+++ b/py/gadict_c5.py Wed Sep 21 22:40:23 2016 +0300
@@ -128,3 +128,12 @@
FOUT.write("⇒ ")
FOUT.write(tr)
FOUT.write("\n")
+ for (lang, tr) in sense.glos_list or []:
+ if LANGS and not (lang in LANGS):
+ continue
+ FOUT.write(" ")
+ if not LANGS or len(LANGS) > 1:
+ FOUT.write(lang)
+ FOUT.write("↦ ")
+ FOUT.write(tr)
+ FOUT.write("\n")
--- a/py/gadict_srs_anki.py Wed Sep 21 22:09:37 2016 +0300
+++ b/py/gadict_srs_anki.py Wed Sep 21 22:40:23 2016 +0300
@@ -113,6 +113,9 @@
font-style: italic;
font-size: .85em;
}
+span.glos {
+ font-size: .85em;
+}
"""
collection.models.addField(model, collection.models.newField('From'))
@@ -225,6 +228,15 @@
buf.append(tr)
buf.append("</span>")
buf.append("</div>")
+ for (lang, tr) in sense.glos_list or []:
+ buf.append("<div class='glos'>")
+ buf.append(" <span class='lang'>")
+ buf.append(lang)
+ buf.append("</span>")
+ buf.append(" <span class='glos'>")
+ buf.append(tr)
+ buf.append("</span>")
+ buf.append("</div>")
direct_to = "".join(buf)
buf = []
for sense in translations:
--- a/www/HACKING.rst Wed Sep 21 22:09:37 2016 +0300
+++ b/www/HACKING.rst Wed Sep 21 22:40:23 2016 +0300
@@ -122,13 +122,19 @@
Synonyms marked by ``syn:``, antonyms marked by ``ant:``, related (see also)
terms marked by ``rel:``, topics/tags marked by ``topic:``.
-Translation marked by lowercase ISO 639-1 code, like:
+Translation marked by lowercase ISO 639-1 code with ``:`` (colon) character,
+like:
* ``en:`` - English
* ``ru:`` - Russian
* ``uk:`` - Ukrainian
* ``la:`` - Latin
+Example marked by lowercase ISO 639-1 code with ``>`` (greater) character.
+
+Explanation or glossary marked by lowercase ISO 639-1 code with ``=`` (equal)
+character.
+
Pronunciation variants marked by:
* ``Am`` - American