Skip to content

Instantly share code, notes, and snippets.

@AWtnb
Last active June 27, 2025 13:03
Show Gist options
  • Select an option

  • Save AWtnb/d8721a07ec82b2fed93ed7076de0b700 to your computer and use it in GitHub Desktop.

Select an option

Save AWtnb/d8721a07ec82b2fed93ed7076de0b700 to your computer and use it in GitHub Desktop.
skk dict chaos handler
import sys
from pathlib import Path
def main(bigger_dict_path, smaller_dict_path):
smaller_set = set(
Path(smaller_dict_path).read_text(encoding="utf-16-le").splitlines()
)
output_path = Path(bigger_dict_path).with_stem("sieved")
with Path(bigger_dict_path).open(encoding="utf-16-le") as infile, output_path.open(
"w", encoding="utf-8"
) as outfile:
for line in infile:
counter += 1
line = line.strip()
if line not in smaller_set:
outfile.write(line + "\n")
if __name__ == "__main__":
main(sys.argv[1], sys.argv[2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment