-
Notifications
You must be signed in to change notification settings - Fork 0
/
searchDict.py
142 lines (124 loc) · 4.74 KB
/
searchDict.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
with open("./wordsToSearch/threeLetterWords.txt", "r") as f:
threeWords = f.read().split("\n")
with open("./wordsToSearch/customThreeLetterWords.txt", "r") as f:
customThreeWords = f.read().split("\n")
with open("./wordsToSearch/customFourLetterWords.txt", "r") as f:
customFourWords = f.read().split("\n")
with open("./wordsToSearch/common3Words.txt", "r") as f:
commonWords = f.read().split("\n")
with open("./wordsToSearch/fourLetterWords.txt", "r") as f:
fourWords = f.read().split(" ")
with open("./out/allLinks.txt", "r") as f:
links = f.read().split("\n")
print(f"Processing {len(links)} links")
# making sure file starts out empty
with open("./out/foundLinks.txt", "w") as f:
f.write("")
# writing all user defined threee letter words on the start or end of the link
with open("./out/foundLinks.txt", "a+") as f:
f.write(f"Custom 3 letter combos\n")
i = 0
for word in list(set(customThreeWords)):
for link in list(set(links)):
code = link[-12:]
start = code[:3]
mid = code[4:8]
end = code[-3:]
if word == start or word == end:
i += 1
with open("./out/foundLinks.txt", "a+") as f:
f.write(f"{link} -- custom 3 letter combo\n")
print(f"{i} custom three letter words found")
# writing all user defined four letter words in the middle of the link
with open("./out/foundLinks.txt", "a+") as f:
f.write(f"\ncustomFourWords\n")
i = 0
for link in list(set(links)):
for word in list(set(customFourWords)):
code = link[-12:]
start = code[:3]
mid = code[4:8]
end = code[-3:]
if word == mid:
i += 1
with open("./out/foundLinks.txt", "a+") as f:
f.write(f"{link} -- customFourWords\n")
print(f"{i} custom four letter words found")
# writing all user defined four letter words in the middle of the link
with open("./out/foundLinks.txt", "a+") as f:
f.write(f"\nStart and end custom\n")
i = 0
for link in list(set(links)):
for word1 in list(set(customThreeWords)):
code = link[-12:]
start = code[:3]
mid = code[4:8]
end = code[-3:]
for word2 in list(set(customThreeWords)):
if (word1 == start and word2 == end) or (word2 == start and word1 == end):
i += 1
with open("./out/foundLinks.txt", "a+") as f:
f.write(f"{link} -- customThreeWords start and end\n")
print(f"{i} Start and end custom codes found")
# # writing all user defined four letter words in the middle of the link
# with open("./out/foundLinks.txt", "a+") as f:
# f.write(f"\ncommonWords\n")
# i = 0
# for link in list(set(links)):
# code = link[-12:]
# start = code[:3]
# mid = code[4:8]
# end = code[-3:]
# for word1 in list(set(commonWords)):
# for word2 in list(set(commonWords)):
# if (word1 == start and word2 == end) or (word2 == start and word1 == end):
# print(f"{link} -- commonWords\n")
# i += 1
# with open("./out/foundLinks.txt", "a+") as f:
# f.write(f"{link} -- commonWords\n")
# print(f"{i} commonWords")
# # writing four letter words in the middle of the link
# with open("./out/foundLinks.txt", "a+") as f:
# f.write(f"Middle\n")
# i = 0
# for link in list(set(links)):
# for word in list(set(fourWords)):
# code = link[-12:]
# start = code[:3]
# mid = code[4:8]
# end = code[-3:]
# if word == mid:
# i += 1
# with open("./out/foundLinks.txt", "a+") as f:
# f.write(f"{link} -- Middle\n")
# print(f"{i} four letter words from dictionary found")
# # writing three letter words at the start or end of link
# with open("./out/foundLinks.txt", "a+") as f:
# f.write(f"Start\n")
# i = 0
# for link in list(set(links)):
# for word in list(set(threeWords)):
# code = link[-12:]
# start = code[:3]
# mid = code[4:8]
# end = code[-3:]
# if word == start:
# i += 1
# with open("./out/foundLinks.txt", "a+") as f:
# f.write(f"{link} -- Start\n")
# print(f"{i} three letter words from dictionary found at the start of the link")
# # writing three letter words at the end of link
# with open("./out/foundLinks.txt", "a+") as f:
# f.write(f"End\n")
# i = 0
# for link in list(set(links)):
# for word in list(set(threeWords)):
# code = link[-12:]
# start = code[:3]
# mid = code[4:8]
# end = code[-3:]
# if word == end:
# i += 1
# with open("./out/foundLinks.txt", "a+") as f:
# f.write(f"{link} -- End\n")
# print(f"{i} three letter words from dictionary found at the end of the link")