summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-03-20 17:15:40 -0700
committerAlex Yatskov <alex@foosoft.net>2016-03-20 17:15:40 -0700
commitd8a630fa2881a0cf012c6548706dde7c4740fe14 (patch)
tree80a4cc60c491373154d5c39146b3c0dac9eb3840 /util
parent7208872b9fee135318b8a1a8b4483547b3986c89 (diff)
Simple lookup now works.
Diffstat (limited to 'util')
-rwxr-xr-xutil/compile.py28
1 files changed, 8 insertions, 20 deletions
diff --git a/util/compile.py b/util/compile.py
index 7991f6c1..485537dc 100755
--- a/util/compile.py
+++ b/util/compile.py
@@ -158,27 +158,15 @@ def parse_edict(path):
defs.append((term, reading, glossary, tags))
- term_indices = {}
- reading_indices = {}
-
+ indices = {}
for i, d in enumerate(defs):
- term, reading = d[:2]
-
- if term is not None:
- term_list = term_indices.get(term, [])
- term_list.append(i)
- term_indices[term] = term_list
-
- if reading is not None:
- reading_list = reading_indices.get(reading, [])
- reading_list.append(i)
- reading_indices[reading] = reading_list
-
- return {
- 'defs': defs,
- 't_idx': term_indices,
- 'r_idx': reading_indices
- };
+ for key in d[:2]:
+ if key is not None:
+ values = indices.get(key, [])
+ values.append(i)
+ indices[key] = values
+
+ return {'defs': defs, 'indices': indices}
def build_dict(output_dir, input_file, parser):