Xinqi Bao's Git

first commit, implemented game wordscapes
[CheaterHub.git] / server / tools / generateDict.py
1 #! /usr/bin/python3
2 import os
3 import subprocess
4
5 workPath = "../wordscapes/"
6 dictPath = workPath + "dict/"
7
8 if __name__ == "__main__":
9
10 file_names = subprocess.Popen("ls " + dictPath, shell=True, stdout=subprocess.PIPE).communicate()[0].decode().split()
11
12 m_dict = set()
13 file_out = open(workPath + "myDictionary", "w")
14
15 for file_name in file_names:
16 file = open(dictPath + file_name, "r")
17
18 for word in file.readlines():
19 word = word.strip().lower()
20 if word.isalpha():
21 m_dict.add(word)
22
23 file_out.write('\n'.join(m_dict))