/
getTermsList.py
59 lines (53 loc) · 1.53 KB
/
getTermsList.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
import utils
import re
files = ["data/mobafire_CompletedPagesList.txt"]
pages = utils.load_list(files[0])
terms = set()
for p in pages:
words = p.split('/')
for w in words:
if '-' in w:
# replace '-' with ' '
w = w.split('-')
# remove the last part if it is a number or "guide"
if w[-1] == 'guide' or w[-1].isnumeric():
w = w[:-1]
w = " ".join(w)
terms.add(w.lower().strip())
mobafireTermsList = list(terms)
mobafireTermsList.sort()
file = "data/LeagueFandom_CompletedPagesList.txt"
pages = utils.load_list(file)
terms = set()
termsToReplace = [('_',' '),('%27','\''),('(item)',''),('%26','&')]
for p in pages:
if "Teamfight_Tactics" in p:
continue
words = p.split('/')
for w in words:
for t in termsToReplace:
w = w.replace(t[0],t[1])
w = re.sub('\(.*\)','',w)
terms.add(w.lower().strip())
fandomTermsList = list(terms)
fandomTermsList.sort()
# Gamepedia
file = "data/gamepedia_CompletedPagesList.txt"
pages = utils.load_list(file)
terms = set()
termsToReplace = [('_',' '),('%27','\''),('(item)',''),('%26','&')]
for p in pages:
if "Teamfight_Tactics" in p:
continue
words = p.split('/')
for w in words:
for t in termsToReplace:
w = w.replace(t[0],t[1])
w = re.sub('\(.*\)','',w)
terms.add(w.lower().strip())
gamepediaTermsList = list(terms)
gamepediaTermsList.sort()
terms = set.union(set(mobafireTermsList), set(fandomTermsList),set(gamepediaTermsList))
termsList = list(terms)
termsList.sort()
utils.write_list(termsList, "data/termsList.txt")