This is a repository full of Flask fun, created for the GDA sprint in March 2020 by Danny & Manetta.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
def search(query):
|
|
|
|
|
|
|
|
query = query.strip()
|
|
|
|
query = query.lower()
|
|
|
|
|
|
|
|
filename = '1989_RIOT_GRRRL_MANIFESTO_[EN].txt'
|
|
|
|
path = './manifestos/'+filename
|
|
|
|
file = open(path, 'r')
|
|
|
|
manifesto = file.read()
|
|
|
|
manifesto = manifesto.replace('\n', ' ')
|
|
|
|
manifesto = manifesto.lower()
|
|
|
|
words = manifesto.split(' ')
|
|
|
|
# print(words)
|
|
|
|
|
|
|
|
if query in words:
|
|
|
|
result = words.count(query)
|
|
|
|
else:
|
|
|
|
result = 0
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
query = 'test'
|
|
|
|
result = search(query)
|
|
|
|
print('query:', query)
|
|
|
|
print('result:', result)
|