Add question for plural form and irregular verbs.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Thu, 15 Sep 2016 19:58:01 +0300
changeset 556 78bf1097106a
parent 555 4a3188fc8951
child 557 d7a42a700255
Add question for plural form and irregular verbs.
py/gadict_srs_anki.py
--- a/py/gadict_srs_anki.py	Thu Sep 15 19:19:34 2016 +0300
+++ b/py/gadict_srs_anki.py	Thu Sep 15 19:58:01 2016 +0300
@@ -80,8 +80,11 @@
   color: black;
   background-color: white;
 }
+.ask {
+  margin-bottom: 1.2em;
+}
 span.headword {
-  font-style: italic;
+  font-weight: bolt;
 }
 .pron {
   color: magenta;
@@ -100,6 +103,9 @@
 .syn {
   color: blue;
 }
+.attrs {
+  color: blue;
+}
 """
 
         collection.models.addField(model, collection.models.newField('From'))
@@ -148,6 +154,8 @@
     for (headwords, translations) in DOM[1:]:
         identity = headwords[0].headword
         buf = []
+        v1, v2, v3 = (None, None, None)
+        singular, plural = (None, None)
         for hw in headwords:
             buf.append("<div clsas='headword'>")
             buf.append("<span clsas='headword'>")
@@ -163,6 +171,16 @@
                 buf.append("<span class='attrs'>")
                 buf.append(", ".join(l))
                 buf.append("</span>")
+            if 'v1' in hw.attrs:
+                v1 = (hw.headword, hw.pron)
+            if 'v2' in hw.attrs:
+                v2 = (hw.headword, hw.pron)
+            if 'v3' in hw.attrs:
+                v3 = (hw.headword, hw.pron)
+            if 's' in hw.attrs:
+                singular = (hw.headword, hw.pron)
+            if 'pl' in hw.attrs:
+                plural = (hw.headword, hw.pron)
             buf.append("</div>")
         direct_from = "".join(buf)
         buf = []
@@ -201,6 +219,23 @@
         direct_to = "".join(buf)
         builder.add_note("en->tr", identity, direct_from, direct_to)
         builder.add_note("tr->en", identity, direct_to, 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])
+            riddle2 = u"<span class='headword'>{}</span> <span class='pron'>[{}]</span> <span class='attrs'>v2</span>".format(v2[0], v2[1])
+            riddle3 = u"<span class='headword'>{}</span> <span class='pron'>[{}]</span> <span class='attrs'>v3</span>".format(v3[0], v3[1])
+            answer = u"{}<br>{}<br>{}<br>{}".format(riddle1, riddle2, riddle3, direct_to)
+            builder.add_note("irregular1", identity, question + riddle1, answer)
+            builder.add_note("irregular2", identity, question + riddle2, answer)
+            builder.add_note("irregular3", identity, question + riddle3, answer)
+        if singular and plural:
+            question = u"<div class='ask'>Find plural:</div>"
+            riddle_s = u"<span class='headword'>{}</span> <span class='pron'>[{}]</span> <span class='attrs'>s</span>".format(singular[0], singular[1])
+            riddle_pl = u"<span class='headword'>{}</span> <span class='pron'>[{}]</span> <span class='attrs'>pl</span>".format(plural[0], plural[1])
+            answer = u"{}<br>{}<br>{}".format(riddle_s, riddle_pl, direct_to)
+            builder.add_note("singular", identity, question + riddle_s, answer)
+            builder.add_note("plural", identity, question + riddle_pl, answer)
+
 
     builder.export(FONAME)
 finally: