Browse Source

second round of debugging of this prototype, removing functions that are not used, and displaying the search bar only on the index page

master
manetta 6 years ago
parent
commit
b0bdf1cdb0
  1. 40
      cross-reader.tfidf/readings.py
  2. 1
      cross-reader.tfidf/start.py
  3. 23
      cross-reader.tfidf/static/css/stylesheet.css
  4. 9
      cross-reader.tfidf/templates/base.html
  5. 10
      cross-reader.tfidf/templates/index.html

40
cross-reader.tfidf/readings.py

@ -179,46 +179,6 @@ def request_results(query):
return filenames, results, analytics
def get_tfidflistings():
index = load_index()
languages = set([index[document]['language'] for document in index.keys()])
tfidflistings = {}
for language in languages:
tfidflistings[language] = []
for document in index.keys():
if index[document]['language'] == language:
for word, value in index[document]['tfidf'].items():
tfidflistings[language].append([value, word])
tfidflistings[language].sort(reverse=True)
# pp.pprint(tfidflistings)
print('*tfidflistings returned*')
return tfidflistings
def get_tfidfcontext(query):
tfidflistings = get_tfidflistings()
tfidfcontext = {}
context_reach = 3
for language in tfidflistings.keys():
index = 0
tfidfcontext[language] = []
for value, word in tfidflistings[language]:
if word.lower() == query.lower():
for x in range(1, context_reach):
cprev = tfidflistings[language][index - x]
cnext = tfidflistings[language][index + x]
tfidfcontext[language].append(cprev)
if x == 1:
tfidfcontext[language].append([value, word])
tfidfcontext[language].append(cnext)
break
index += 1
tfidfcontext[language].sort(reverse=True)
# pp.pprint(tfidfcontext)
print('*tfidfcontext returned*')
return tfidfcontext
def request_mappings(mapping_type):
index = load_index()
filenames = [document for document, _ in index.items()]

1
cross-reader.tfidf/start.py

@ -38,7 +38,6 @@ def index():
if request.args.get('q', ''):
filenames, results, analytics = readings.request_results(query)
tfidfcontext = readings.get_tfidfcontext(query)
return flask.render_template('results.html', query=query, results=results, filenames=filenames, suggestions=suggestions, analytics=analytics)
else:

23
cross-reader.tfidf/static/css/stylesheet.css

@ -1,10 +1,4 @@
@font-face{
font-family: 'unifont';
src:url('fonts/unifont-11.0.03.ttf');
}
body{
/*background-color: rgba(220,220,220,0.6);*/
margin:20px;
font-size: 16px;
line-height: 22px;
@ -28,7 +22,6 @@ a, a:active, a:hover{
margin:0;
}
#nav-wrapper{
z-index: -1;
}
@ -72,13 +65,10 @@ a, a:active, a:hover{
cursor: pointer;
}
#txt-list{
position: fixed;
position: absolute;
width:250px;
right: 0px;
top:-7px;
margin:20px;
font-size: 16px;
line-height: 1.2;
right: 0;
top:0;
z-index: 3;
}
#txt-list ul{
@ -96,10 +86,10 @@ a, a:active, a:hover{
border: 0;
}
#suggestions{
position: fixed;
position: absolute;
width: 250px;
right: 300px;
top:12px;
top:0;
z-index: 2;
}
@ -124,6 +114,9 @@ a, a:active, a:hover{
margin:-9.7em -6em -10.5em -6em;
}
#mappings{
line-height: 1.5;
}
#analytics{
margin:2em 0;
}

9
cross-reader.tfidf/templates/base.html

@ -20,12 +20,6 @@
<!-- https://fsymbols.com/generators/tarty/ -->
</a>
</div>
<div id="search">
<form action="" method="GET">
<input id="query" name="q" value="{{query}}"/>
<input id="submit" type="submit" value="➜"/>
</form>
</div>
<div id="txt-list">
<p>Sear%r%rching <em>and cross-reading through</em> the following files:</p>
<ul>
@ -52,7 +46,10 @@
</div>
</div>
{% block navwrapper %}
{% endblock %}
</div>
<div id="wrapper">
<div id="content">
{% block content %}

10
cross-reader.tfidf/templates/index.html

@ -1,5 +1,15 @@
{% extends "base.html" %}
{% block navwrapper %}
<div id="search">
<form action="" method="GET">
<input id="query" name="q" value="{{query}}"/>
<input id="submit" type="submit" value="➜"/>
</form>
</div>
{% endblock %}
{% block results %}
<div id="intro">
<p>This Sear%r%rch tool only works with <strong>one word</strong>.</p>

Loading…
Cancel
Save