-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME
More file actions
54 lines (39 loc) · 1.62 KB
/
Copy pathREADME
File metadata and controls
54 lines (39 loc) · 1.62 KB
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
README
Jordan Sanders
CSCE 5200
Final Project
Programs:
download.py
make_model.py
query.py
utils.py
Other files:
stop_words.txt
tfidf.pickle
To perform a query:
python query.py
To download 3000 webpages:
python download.py
To create the vector space model:
python make_model.py
Notes:
I have NLTK and one of its dependencies imported into the main project directory (Six)
tf and idf values have been pre-computed in the tfidf.pickle file for quick run time.
Descriptions:
query.py:
This program takes a query argument, preprocesses it, and then calculates the cosine similarity between
the query and all documents in the model. It then ranks them in descending order of similarity and outputs
the top 5 URLs with the highest similarity to the query. It then prompts the user to continue or end.
utils.py:
This file contains all functions written in this course. Specifically written for this
project was the checkURL and fixURL functions.
download.py:
This program uses the urllib2 and bs4 libraries to download webpages and parse them
for all links. Links are then added to a queue from the queue library using breadth first search.
All links already visited are not added to the queue. Downloaded pages are stripped of
all markup text and written to a cPickle binary file to be used for creating the model later.
make_model.py:
This program opens the pickled webpage text files and runs the tfidf_text function
that creates the vector space model using a dictionary that is then stored in a pickle
file called tfidf.
tfidf.pickle is the tf and idf dictionaries pre-computed for quick run time. Delete for re-compute