def parse_main_dict_line(line):
"""Parses one line of a main dictionary file.
Changes to this function must be paired with changes to
write_main_dict_line below.
This should produce the same data structure that
_write_main_dict_line in indexer.py creates to write out each
line.
"""
split_chars = IndexStoreMainDict.sep_chars
line = line.rstrip('\n')
tmp = line.split(split_chars[0])
tok = unquote(tmp[0])
atl = tmp[1:]
res = []
for ati in atl:
tmp = ati.split(split_chars[1])
action_type = tmp[0]
stl = tmp[1:]
at_res = []
for sti in stl:
tmp = sti.split(split_chars[2])
subtype = tmp[0]
fvl = tmp[1:]
st_res = []
for fvi in fvl:
tmp = fvi.split(split_chars[3])
full_value = unquote(tmp[0])
pfl = tmp[1:]
fv_res = []
for pfi in pfl:
tmp = pfi.split(split_chars[4])
pfmri_index = int(tmp[0])
offsets = [
int(t) for t in tmp[1:]
]
fv_res.append(
(pfmri_index, offsets))
st_res.append((full_value, fv_res))
at_res.append((subtype, st_res))
res.append((action_type, at_res))
return tok, res
评论列表
文章目录