Include examples into dictionary articles and Packaged Anki Desk files.
--- a/py/gadict_c5.py Fri Sep 16 00:44:40 2016 +0300
+++ b/py/gadict_c5.py Fri Sep 16 01:10:21 2016 +0300
@@ -98,18 +98,23 @@
if sense.syn_list and len(sense.syn_list) > 0:
FOUT.write(" syn: ")
FOUT.write("; ".join(["{"+s+"}" for s in sense.syn_list]))
- FOUT.write("\n")
+ if not LANGS or len(LANGS) != 1:
+ FOUT.write("\n")
for (lang, tr) in sense.tr_list:
+ if LANGS and not (lang in LANGS):
+ continue
FOUT.write(" ")
- if LANGS is None:
+ if not LANGS or len(LANGS) > 1:
FOUT.write(lang)
FOUT.write("→ ")
- FOUT.write(tr)
- elif lang in LANGS:
- if len(LANGS) == 1:
- FOUT.write(tr)
- else:
- FOUT.write(lang)
- FOUT.write("→ ")
- FOUT.write(tr)
+ FOUT.write(tr)
FOUT.write("\n")
+ for (lang, tr) in sense.ex_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 Fri Sep 16 00:44:40 2016 +0300
+++ b/py/gadict_srs_anki.py Fri Sep 16 01:10:21 2016 +0300
@@ -106,6 +106,10 @@
.attrs {
color: blue;
}
+span.ex {
+ font-style: italic;
+ font-size: .85em;
+}
"""
collection.models.addField(model, collection.models.newField('From'))
@@ -209,9 +213,45 @@
buf.append("</span>")
if len(sense.tr_list) > 1:
buf.append("</div>")
+ for (lang, tr) in sense.ex_list or []:
+ buf.append("<div class='ex'>")
+ buf.append(" <span class='lang'>")
+ buf.append(lang)
+ buf.append("</span>")
+ buf.append(" <span class='ex'>")
+ buf.append(tr)
+ buf.append("</span>")
+ buf.append("</div>")
direct_to = "".join(buf)
+ buf = []
+ for sense in translations:
+ buf.append("<div class='sense'>")
+ if sense.pos:
+ buf.append("<span class='pos'>")
+ buf.append(sense.pos)
+ buf.append("</span>")
+ if sense.ant_list and len(sense.ant_list) > 0:
+ buf.append("<span class='ant'>ant: ")
+ buf.append("; ".join(["{"+s+"}" for s in sense.ant_list]))
+ buf.append("</span>")
+ if sense.syn_list and len(sense.syn_list) > 0:
+ buf.append("<span class='syn'>syn: ")
+ buf.append("; ".join(["{"+s+"}" for s in sense.syn_list]))
+ buf.append("</span>")
+ for (lang, tr) in sense.tr_list:
+ if len(sense.tr_list) > 1:
+ buf.append("<div class='sense'>")
+ buf.append(" <span class='lang'>")
+ buf.append(lang)
+ buf.append("</span>")
+ buf.append(" <span class='tr'>")
+ buf.append(tr)
+ buf.append("</span>")
+ if len(sense.tr_list) > 1:
+ buf.append("</div>")
+ reverse_from = "".join(buf) # without examples!!
builder.add_note("en->tr", identity, direct_from, direct_to)
- builder.add_note("tr->en", identity, direct_to, direct_from)
+ builder.add_note("tr->en", identity, reverse_from, direct_from)
if v1 and v2 and v3:
question = u"<div class='ask'>Find irregular verb:</div>"
riddle1 = u"<span class='headword'>{}</span> <span class='pron'>[{}]</span> <span class='attrs'>v1</span>".format(v1[0], v1[1])
--- a/www/CHANGES.rst Fri Sep 16 00:44:40 2016 +0300
+++ b/www/CHANGES.rst Fri Sep 16 01:10:21 2016 +0300
@@ -23,6 +23,7 @@
================
* Generating Packaged Anki Desk files for Anki space repetition software.
+ * Include examples into dictionary articles and Packaged Anki Desk files.
v0.8, 2016-09-11
================