Skip to content

Commit

Permalink
Fix end count bug in Kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickgold committed Feb 27, 2021
1 parent cc712ff commit 84ee42c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions clb.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ def cBpack(lang_code, src_path, swear_path, dst_path):
for innerlist in data_sanitized:
freq = __freq_for_index(index, len_list)
for word in innerlist:
adjusted_freq = freq
for swear_word in swear_words:
if swear_word in word:
adjusted_freq = 0
if word in swear_words:
adjusted_freq = 0
else:
adjusted_freq = freq
f_dst.write(" word={},f={}\n".format(word, adjusted_freq))
index += 1
24 changes: 12 additions & 12 deletions flict.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,20 @@ def encode(self, byte_arr: bytearray):
FlictSpec.writeCmd(byte_arr, FlictSpec.CMDB_BEGIN_PTREE_NODE,
size=len(token_arr)-1, type=self.type, order=self.order-1, freq=self.freq)
byte_arr.extend(token_arr)
is_last_byte_end = False
for child_node in self.children.values():
child_node.encode(byte_arr)
# if (byte_arr[-1] & FlictSpec.MASK_END) == FlictSpec.CMDB_END:
# last_end_count = (byte_arr[-1] & FlictSpec.ATTR_END_COUNT)
# if last_end_count < FlictSpec.ATTR_END_COUNT_MAX:
# del byte_arr[-1]
# end_count = last_end_count + 1
# else:
# end_count = 1
# else:
# end_count = 1
## end_count always 1 on purpose because else there's a severe bug
## TODO: fix it
FlictSpec.writeCmd(byte_arr, FlictSpec.CMDB_END, end_count=1)
is_last_byte_end = True
if is_last_byte_end:
last_end_count = (byte_arr[-1] & FlictSpec.ATTR_END_COUNT)
if last_end_count < FlictSpec.ATTR_END_COUNT_MAX:
end_count = last_end_count + 1
del byte_arr[-1]
else:
end_count = 1
else:
end_count = 1
FlictSpec.writeCmd(byte_arr, FlictSpec.CMDB_END, end_count=end_count)

def __repr__(self) -> str:
return f"FlictNode {{ order={self.order}, children={repr(self.children)} }}"
Expand Down

0 comments on commit 84ee42c

Please sign in to comment.