-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddwtj.py
66 lines (47 loc) · 1.45 KB
/
addwtj.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from MyModules import Aj
import json
# import sys
# from os.path import dirname, abspath
# d = dirname(dirname(abspath(__file__)))
# sys.path.append(d)
with open('./Databases/Database.json') as file:
DBjson = json.loads(file.read())
words = list(DBjson[1]['Words Repeat Time'])
with open('./Databases/words_to_join.json') as file:
wtjjson = json.loads(file.read())
with open('Databases/text.txt') as file:
string = file.read().lower()
deleted = list(('-', '\n', ',', '.', ';', ':', '?'))
for char in deleted:
string = string.replace(char, ' ')
while ' ' in string:
string = string.replace(' ', ' ')
arr = string.split(' ')
Aj.SeparateAllShort(arr)
newarr = []
for element in arr:
if element.lower() not in words and element.lower() not in wtjjson and element not in newarr and "'" not in element:
newarr.append(element.lower())
def printArr(arr):
n = 0
for element in arr:
print(n, element, sep=': ')
n += 1
printArr(newarr)
def getInput():
Input = input('\n')
if Input == '':
for element in newarr:
wtjjson.update({element: [""]})
with open('./Databases/words_to_join.json', 'w') as file:
json.dump(wtjjson, file)
return 0
else:
if Input.isnumeric():
if int(Input) < len(newarr):
newarr.remove(newarr[int(Input)])
printArr(newarr)
else:
exit()
getInput()
getInput()