From e97c64ff3fbfdf0c66c38f281f84ecfa844cf487 Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Fri, 26 Feb 2016 10:16:15 +0100 Subject: dictionary-to-thesaurus.py: Put the better categorized words to the front. Change-Id: Ib5c77f185abeeaef5045780766514a813794c8e8 --- cs_CZ/thesaurus/dictionary-to-thesaurus.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'cs_CZ') diff --git a/cs_CZ/thesaurus/dictionary-to-thesaurus.py b/cs_CZ/thesaurus/dictionary-to-thesaurus.py index 63f906a..8b904d7 100755 --- a/cs_CZ/thesaurus/dictionary-to-thesaurus.py +++ b/cs_CZ/thesaurus/dictionary-to-thesaurus.py @@ -163,16 +163,22 @@ def buildThesaurus(synonyms, meanings, classification): if len(line) != 0: for t in types: if t in line: - if typ == '': - # classification is abmiguous, output the type too - output_lines.append(t + line[t]) - else: - output_lines.append(line[t]) + output_lines.append( (t, line[t]) ) if len(output_lines) > 0: print word + '|' + str(len(output_lines)) - for line in output_lines: - print line + + # those with existing classification are probably a better fit, + # put them to the front (even if we don't output the + # classification in the end) + for i in [0, 1]: + for (t, line) in output_lines: + # first pass only non-empty, 2nd pass only empty + if (i == 0 and t != '') or (i == 1 and t == ''): + if typ == '': + print t + line + else: + print line def main(args): if (len(args) != 3): -- cgit