-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit.py
More file actions
25 lines (20 loc) · 715 Bytes
/
split.py
File metadata and controls
25 lines (20 loc) · 715 Bytes
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
# It update the index to include all of the word occurences found in the
# page content by adding the url to the word's associated url list.
def add_to_index(index,keyword,url):
for entry in index:
if entry[0] == keyword:
entry[1].append(url)
return
index.append([keyword,[url]])
def add_page_to_index(index,url,content):
new_list = content.split(" ")
for i in new_list:
add_to_index(index,i,url)
def main():
index = []
add_page_to_index(index,'fake.text',"This is a test")
print(index)
#>>> [['This', ['fake.text']], ['is', ['fake.text']], ['a', ['fake.text']],
#>>> ['test',['fake.text']]]
if __name__ == '__main__':
main()