py/gadict_srs_anki.py
changeset 560 dad049a0f585
parent 559 2b03300f610c
child 561 a96c5bad041f
equal deleted inserted replaced
559:2b03300f610c 560:dad049a0f585
   103 .syn {
   103 .syn {
   104   color: blue;
   104   color: blue;
   105 }
   105 }
   106 .attrs {
   106 .attrs {
   107   color: blue;
   107   color: blue;
       
   108 }
       
   109 span.ex {
       
   110   font-style: italic;
       
   111   font-size: .85em;
   108 }
   112 }
   109 """
   113 """
   110 
   114 
   111         collection.models.addField(model, collection.models.newField('From'))
   115         collection.models.addField(model, collection.models.newField('From'))
   112         collection.models.addField(model, collection.models.newField('To'))
   116         collection.models.addField(model, collection.models.newField('To'))
   207                 buf.append(" <span class='tr'>")
   211                 buf.append(" <span class='tr'>")
   208                 buf.append(tr)
   212                 buf.append(tr)
   209                 buf.append("</span>")
   213                 buf.append("</span>")
   210                 if len(sense.tr_list) > 1:
   214                 if len(sense.tr_list) > 1:
   211                     buf.append("</div>")
   215                     buf.append("</div>")
       
   216             for (lang, tr) in sense.ex_list or []:
       
   217                 buf.append("<div class='ex'>")
       
   218                 buf.append(" <span class='lang'>")
       
   219                 buf.append(lang)
       
   220                 buf.append("</span>")
       
   221                 buf.append(" <span class='ex'>")
       
   222                 buf.append(tr)
       
   223                 buf.append("</span>")
       
   224                 buf.append("</div>")
   212         direct_to = "".join(buf)
   225         direct_to = "".join(buf)
       
   226         buf = []
       
   227         for sense in translations:
       
   228             buf.append("<div class='sense'>")
       
   229             if sense.pos:
       
   230                 buf.append("<span class='pos'>")
       
   231                 buf.append(sense.pos)
       
   232                 buf.append("</span>")
       
   233             if sense.ant_list and len(sense.ant_list) > 0:
       
   234                 buf.append("<span class='ant'>ant: ")
       
   235                 buf.append("; ".join(["{"+s+"}" for s in sense.ant_list]))
       
   236                 buf.append("</span>")
       
   237             if sense.syn_list and len(sense.syn_list) > 0:
       
   238                 buf.append("<span class='syn'>syn: ")
       
   239                 buf.append("; ".join(["{"+s+"}" for s in sense.syn_list]))
       
   240                 buf.append("</span>")
       
   241             for (lang, tr) in sense.tr_list:
       
   242                 if len(sense.tr_list) > 1:
       
   243                     buf.append("<div class='sense'>")
       
   244                 buf.append(" <span class='lang'>")
       
   245                 buf.append(lang)
       
   246                 buf.append("</span>")
       
   247                 buf.append(" <span class='tr'>")
       
   248                 buf.append(tr)
       
   249                 buf.append("</span>")
       
   250                 if len(sense.tr_list) > 1:
       
   251                     buf.append("</div>")
       
   252         reverse_from = "".join(buf)         # without examples!!
   213         builder.add_note("en->tr", identity, direct_from, direct_to)
   253         builder.add_note("en->tr", identity, direct_from, direct_to)
   214         builder.add_note("tr->en", identity, direct_to, direct_from)
   254         builder.add_note("tr->en", identity, reverse_from, direct_from)
   215         if v1 and v2 and v3:
   255         if v1 and v2 and v3:
   216             question = u"<div class='ask'>Find irregular verb:</div>"
   256             question = u"<div class='ask'>Find irregular verb:</div>"
   217             riddle1 = u"<span class='headword'>{}</span> <span class='pron'>[{}]</span> <span class='attrs'>v1</span>".format(v1[0], v1[1])
   257             riddle1 = u"<span class='headword'>{}</span> <span class='pron'>[{}]</span> <span class='attrs'>v1</span>".format(v1[0], v1[1])
   218             riddle2 = u"<span class='headword'>{}</span> <span class='pron'>[{}]</span> <span class='attrs'>v2</span>".format(v2[0], v2[1])
   258             riddle2 = u"<span class='headword'>{}</span> <span class='pron'>[{}]</span> <span class='attrs'>v2</span>".format(v2[0], v2[1])
   219             riddle3 = u"<span class='headword'>{}</span> <span class='pron'>[{}]</span> <span class='attrs'>v3</span>".format(v3[0], v3[1])
   259             riddle3 = u"<span class='headword'>{}</span> <span class='pron'>[{}]</span> <span class='attrs'>v3</span>".format(v3[0], v3[1])