diff --git a/.DS_Store b/.DS_Store index b96aa7e..85257df 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/backend/backendInterface.pyc b/backend/backendInterface.pyc index 735b78e..1deb5a3 100644 Binary files a/backend/backendInterface.pyc and b/backend/backendInterface.pyc differ diff --git a/backend/crawler1.py b/backend/crawler1.py index 4ef1812..cf9c050 100644 --- a/backend/crawler1.py +++ b/backend/crawler1.py @@ -95,7 +95,7 @@ def crawl(self, depth = 2): pages = newpages if __name__=="__main__": - #crawler().crawl() + crawler().crawl() print "CRAWLER FINISHED" print "BEGINNING PAGERANK ALGORITHM" diff --git a/backend/cursorhelpers.py b/backend/cursorhelpers.py index 7b90698..4e15318 100644 --- a/backend/cursorhelpers.py +++ b/backend/cursorhelpers.py @@ -7,7 +7,6 @@ """In general, Inserts return true or false. Searches return a value or None""" class DataBase(object): - @classmethod def drop_tables(cls): try: @@ -22,12 +21,15 @@ def drop_tables(cls): @classmethod def create_tables(cls): - connection.cursor().execute('CREATE TABLE lexicon ( word_id INTEGER PRIMARY KEY ASC AUTOINCREMENT, word VARCHAR(100) UNIQUE NOT NULL)') - connection.cursor().execute('CREATE TABLE document (url_id INTEGER PRIMARY KEY ASC AUTOINCREMENT, url VARCHAR(255) UNIQUE NOT NULL)') - connection.cursor().execute('CREATE TABLE link ( from_doc_id INTEGER NOT NULL REFERENCES document(url_id), to_doc_id INTEGER NOT NULL REFERENCES document(url_id), freq UNSIGNED INTEGER, PRIMARY KEY(from_doc_id, to_doc_id))') - connection.cursor().execute('CREATE TABLE doc_word_index ( doc_id INTEGER REFERENCES document(url_id), word_id INTEGER REFERENCES lexicon(word_id), freq UNSIGNED INTEGER, PRIMARY KEY(doc_id, word_id))') - connection.cursor().execute('CREATE TABLE page_rank(doc_id INTEGER REFERENCES document(url_id), page_rank INTEGER, PRIMARY KEY(doc_id))') - connection.commit() + try: + connection.cursor().execute('CREATE TABLE lexicon ( word_id INTEGER PRIMARY KEY ASC AUTOINCREMENT, word VARCHAR(100) UNIQUE NOT NULL)') + connection.cursor().execute('CREATE TABLE document (url_id INTEGER PRIMARY KEY ASC AUTOINCREMENT, url VARCHAR(255) UNIQUE NOT NULL)') + connection.cursor().execute('CREATE TABLE link ( from_doc_id INTEGER NOT NULL REFERENCES document(url_id), to_doc_id INTEGER NOT NULL REFERENCES document(url_id), freq UNSIGNED INTEGER, PRIMARY KEY(from_doc_id, to_doc_id))') + connection.cursor().execute('CREATE TABLE doc_word_index ( doc_id INTEGER REFERENCES document(url_id), word_id INTEGER REFERENCES lexicon(word_id), freq UNSIGNED INTEGER, PRIMARY KEY(doc_id, word_id))') + connection.cursor().execute('CREATE TABLE page_rank(doc_id INTEGER REFERENCES document(url_id), page_rank INTEGER, PRIMARY KEY(doc_id))') + connection.commit() + except: + print "Error in trying to create tables!\n" class DocLexBaseDB(object): @@ -98,6 +100,9 @@ class Document(DocLexBaseDB): MAXWORDLEN = 255 + + + class LinkWordIndexBaseDB(object): """The doc_word_index and link databases are very similar This class fulfills the functionalities of both. Variable names diff --git a/db/repo.db b/db/repo.db index c8dcb6e..3c371b7 100755 Binary files a/db/repo.db and b/db/repo.db differ diff --git a/frontend/__init__.pyc b/frontend/__init__.pyc index cc9b3e6..60d5fd9 100644 Binary files a/frontend/__init__.pyc and b/frontend/__init__.pyc differ diff --git a/frontend/core.py b/frontend/core.py index c0a35a0..a0b7d3d 100644 --- a/frontend/core.py +++ b/frontend/core.py @@ -18,7 +18,7 @@ def index(): @view('results') def results(): keyword = request.GET.get('keyword') - print search_query(keyword) - return dict(keyword=keyword, val=6) + results = search_query(keyword) + return dict(keyword=keyword, results=results) run(host='localhost', port=8080) \ No newline at end of file diff --git a/frontend/views/index.tpl b/frontend/views/index.tpl index c644c45..8c5b6d0 100644 --- a/frontend/views/index.tpl +++ b/frontend/views/index.tpl @@ -24,7 +24,7 @@