--- a/py/gadict_srs_tab.py Thu Sep 15 15:42:52 2016 +0300
+++ b/py/gadict_srs_tab.py Thu Sep 15 17:48:20 2016 +0300
@@ -38,46 +38,21 @@
else:
FOUT = codecs.open(FONAME, "w", "utf-8")
-def attr_key(item):
- (word, (pron, attrs)) = item
- if not attrs:
- return "zzz"
- best_vattr = None
- for attr in attrs:
- if attr in ["v1", "v2", "v3"]:
- if not best_vattr or (best_vattr and best_vattr > attr):
- best_vattr = attr
- if best_vattr:
- return best_vattr
- for attr in attrs: # single/plural
- if attr in ["s"]:
- return attr
- for attr in attrs: # comparative/superlative
- if attr in ["comp"]:
- return attr
- for attr in attrs: # Am/Br/Au
- if attr in ["Am"]:
- return attr
- return "zzz"
-
-for idx in range(1, len(DOM)):
- article = DOM[idx]
- defs = article[0].items()
- defs = sorted(defs, key = attr_key)
+for (headwords, translations) in DOM[1:]:
lines = []
- for (word, (pron, attrs)) in defs:
- line = "<b>"+word+"</b>"
- if pron:
- line += " ["+pron+"]"
- if len(attrs) > 0:
- attrs = [" «"+x+"»" for x in attrs]
+ for hw in headwords:
+ line = "<b>"+hw.headword+"</b>"
+ if hw.pron:
+ line += " ["+hw.pron+"]"
+ if len(hw.attrs) > 0:
+ attrs = [" «"+x+"»" for x in hw.attrs]
attrs.sort()
line += ",".join(attrs)
lines.append(line)
question = "<br>".join(lines)
FOUT.write(question)
FOUT.write("\t")
- for sense in article[1]:
+ for sense in translations:
if not sense:
raise Exception("""Empty sense for article: """ + article[0].__iter__().__next__())
if sense.pos: