summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2016-02-26 10:16:15 +0100
committerJan Holesovsky <kendy@collabora.com>2016-02-26 10:22:28 +0100
commite97c64ff3fbfdf0c66c38f281f84ecfa844cf487 (patch)
tree1b56a1c9ca228ed4662d2ebd4cd59a88b462fa80
parentc32de9bba681bcc7becc64f0ea3b605ff2b38266 (diff)
dictionary-to-thesaurus.py: Put the better categorized words to the front.
Change-Id: Ib5c77f185abeeaef5045780766514a813794c8e8
-rwxr-xr-xcs_CZ/thesaurus/dictionary-to-thesaurus.py20
1 files changed, 13 insertions, 7 deletions
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):