Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ritute committed Dec 6, 2011
1 parent d2092ee commit e5b3bb9
Show file tree
Hide file tree
Showing 23 changed files with 2,135 additions and 14 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified backend/backendInterface.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion backend/crawler1.py
Expand Up @@ -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"
Expand Down
19 changes: 12 additions & 7 deletions backend/cursorhelpers.py
Expand Up @@ -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:
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand Down
Binary file modified db/repo.db
Binary file not shown.
Binary file modified frontend/__init__.pyc
Binary file not shown.
4 changes: 2 additions & 2 deletions frontend/core.py
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion frontend/views/index.tpl
Expand Up @@ -24,7 +24,7 @@
<ul>
<li>
<label for="keyword" class="infield">Search for keyword</label>
<input type="text" name="keyword" id="keyword" maxlength="" tabindex="1"/>
<input type="text" name="keyword" id="keyword" maxlength="100" tabindex="1"/>
</li>
<li>
<input type="submit" value="Fetch »" tabindex="2"/>
Expand Down
6 changes: 3 additions & 3 deletions frontend/views/results.tpl
Expand Up @@ -25,7 +25,7 @@
<ul>
<li>
<label for="keyword" class="infield">Search for keyword</label>
<input type="text" name="keyword" id="keyword" maxlength="" tabindex="1" value="{{ keyword }}"/>
<input type="text" name="keyword" id="keyword" maxlength="100" tabindex="1" value="{{ keyword }}"/>
</li>
<li>
<input type="submit" value="Fetch »" tabindex="2"/>
Expand All @@ -41,10 +41,10 @@
</tr>
</thead>
<tbody>
%for i in range(val):
%for result in results:
<tr class="link">
<td class="titlelink">
<a class="title" href="#"><b>JKL</b> Components Corporation</a>
<a class="title" href="#">{{ result[3] }}</a>
<div class="url">www.jkllamps.com/</div>
<div class="description"><b>JKL</b> Components Corporation is a lighting solutions provider offering LED, fluorescent, incandescent and ultra-violet technologies. A wide assortment of ...</div>
</td>
Expand Down
Binary file added helpers copy/.cursorhelpers.py.swl
Binary file not shown.
Binary file added helpers copy/.cursorhelpers.py.swm
Binary file not shown.
Binary file added helpers copy/.cursorhelpers.py.swn
Binary file not shown.
Binary file added helpers copy/.cursorhelpers.py.swo
Binary file not shown.

0 comments on commit e5b3bb9

Please sign in to comment.