second experiment as a flask interactive application to jump between recommended sentences using the similarity matrix

master
Dorian 2 years ago
parent 8ae06f04df
commit fb71713ade

@ -26,8 +26,8 @@ from wikipage.page import get_wikipage
# wikipedia_page = "forest"
# wikipedia_page = "warehouse"
# wikipedia_page = "river"
wikipedia_page = "elderflower"
wikipedia_page = "river"
# wikipedia_page = "elderflower"
# wikipedia_page = "mushroom"
TEMPLATE_PATH = 'template.html'
@ -136,14 +136,6 @@ def wiki_parse(sentences):
return new_sentences
# textrank
# ------------------------------------------------------------------------
def txt2rankedsentences(txt):
# from txt to ranked sentences
return scored_sentences(txt, split=True)
# main
# ------------------------------------------------------------------------
@ -168,7 +160,7 @@ if __name__ == '__main__':
# --- APPLY TEXTRANK ---
# apply textrank
sentences = txt2rankedsentences(text)
sentences = scored_sentences(text)
# print ranked sentences in terminal
print('--- SENTENCES ---')

@ -23,149 +23,149 @@
<h1>Sambucus</h1>
<span style="opacity:0.023354250368401927;">Sambucus is a genus of flowering plants in the family Adoxaceae.</span>
<span style="opacity:0.0286079876639931;">Sambucus is a genus of flowering plants in the family Adoxaceae.</span>
<span style="opacity:0.008019401476129553;">The various species are commonly called elder or elderberry.</span>
<span style="opacity:0.009856558540451301;">The various species are commonly called elder or elderberry.</span>
<span style="opacity:0.26031502027326375;">The genus was formerly placed in the honeysuckle family, Caprifoliaceae, but was reclassified as Adoxaceae due to genetic and morphological comparisons to plants in the genus Adoxa.</span>
<span style="opacity:0.31993164307709576;">The genus was formerly placed in the honeysuckle family, Caprifoliaceae, but was reclassified as Adoxaceae due to genetic and morphological comparisons to plants in the genus Adoxa.</span>
<h2 style="opacity:0.11901683057809066;">Description</h2>
<h2 style="opacity:0.162837987300005;">Description</h2>
<span style="opacity:0.34993223091241904;">The oppositely arranged leaves are pinnate with 59 leaflets (or, rarely, 3 or 11).</span>
<span style="opacity:0.4380243323528264;">The oppositely arranged leaves are pinnate with 59 leaflets (or, rarely, 3 or 11).</span>
<span style="opacity:0.6657790550844742;">Each leaf is 530 cm (212 in) long, and the leaflets have serrated margins.</span>
<span style="opacity:1;">Each leaf is 530 cm (212 in) long, and the leaflets have serrated margins.</span>
<span style="opacity:0.15164144458890563;">They bear large clusters of small white or cream-colored flowers in late spring; these are followed by clusters of small black, blue-black, or red berries (rarely yellow or white).</span>
<span style="opacity:0.18363553958943812;">They bear large clusters of small white or cream-colored flowers in late spring; these are followed by clusters of small black, blue-black, or red berries (rarely yellow or white).</span>
<h3 style="opacity:0.037512192700824155;">Color</h3>
<h3 style="opacity:0.04451206085045036;">Color</h3>
<span style="opacity:0.002234682837227867;">Sambucus fruit is rich in anthocyanidins that combine to give elderberry juice an intense blue-purple coloration that turns reddish on dilution with water.</span>
<span style="opacity:0.002478437033277918;">Sambucus fruit is rich in anthocyanidins that combine to give elderberry juice an intense blue-purple coloration that turns reddish on dilution with water.</span>
<span style="opacity:0.04596217339828307;">These pigments are used as colorants in various products, and "elderberry juice color" is listed by the US FDA as allowable in certified organic food products.</span>
<span style="opacity:0.05448329547995691;">These pigments are used as colorants in various products, and "elderberry juice color" is listed by the US FDA as allowable in certified organic food products.</span>
<span style="opacity:0.06433972186696155;">In Japan, elderberry juice is listed as an approved "natural color additive" under the Food and Sanitation Law. Fibers can be dyed with elderberry juice (using alum as a mordant) to give a light "elderberry" color.</span>
<span style="opacity:0.07657445003811625;">In Japan, elderberry juice is listed as an approved "natural color additive" under the Food and Sanitation Law. Fibers can be dyed with elderberry juice (using alum as a mordant) to give a light "elderberry" color.</span>
<h3 style="opacity:0.005859165534145169;">Toxicity</h3>
<h3 style="opacity:0.007204361161287866;">Toxicity</h3>
<span style="opacity:0.018703350472802083;">Although the cooked berries (pulp and skin) of most species of Sambucus are edible, the uncooked berries and other parts of plants from this genus are poisonous.</span>
<span style="opacity:0.023490284421853077;">Although the cooked berries (pulp and skin) of most species of Sambucus are edible, the uncooked berries and other parts of plants from this genus are poisonous.</span>
<span style="opacity:0.0;">Leaves, twigs, branches, seeds, roots, flowers, and berries of Sambucus plants produce cyanogenic glycosides, which have toxic properties.</span>
<span style="opacity:0.0024907571958084017;">Ingesting a sufficient quantity of cyanogenic glycosides from berry juice, flower tea, or beverages made from fresh leaves, branches, and fruit has been shown to cause illness, including nausea, vomiting, abdominal cramps, diarrhea, and weakness.</span>
<span style="opacity:0.002878506268462123;">Ingesting a sufficient quantity of cyanogenic glycosides from berry juice, flower tea, or beverages made from fresh leaves, branches, and fruit has been shown to cause illness, including nausea, vomiting, abdominal cramps, diarrhea, and weakness.</span>
<span style="opacity:0.004068285156595224;">In August 1983, a group of 25 people in Monterey County, California, became suddenly ill by ingesting elderberry juice pressed from fresh, uncooked Sambucus mexicana berries, leaves, and stems.</span>
<span style="opacity:0.0045381813641482555;">In August 1983, a group of 25 people in Monterey County, California, became suddenly ill by ingesting elderberry juice pressed from fresh, uncooked Sambucus mexicana berries, leaves, and stems.</span>
<span style="opacity:0.004033434845520135;">The density of cyanogenic glycosides is higher in tea made from flowers (or leaves) than from the berries.The seeds of Sambucus callicarpa are reported to be poisonous and may cause vomiting or diarrhea.</span>
<span style="opacity:0.005114833751975874;">The density of cyanogenic glycosides is higher in tea made from flowers (or leaves) than from the berries.The seeds of Sambucus callicarpa are reported to be poisonous and may cause vomiting or diarrhea.</span>
<h2 style="opacity:0.3047373240294963;">Taxonomy</h2>
<h2 style="opacity:0.375765724425612;">Taxonomy</h2>
<span style="opacity:0.1435576912325227;">The taxonomy of the genus Sambucus L., originally described by Carl Linnaeus and hence its botanical authority, has been complicated by its wide geographical distribution and morphological diversity.</span>
<span style="opacity:0.18226266693705534;">The taxonomy of the genus Sambucus L., originally described by Carl Linnaeus and hence its botanical authority, has been complicated by its wide geographical distribution and morphological diversity.</span>
<span style="opacity:0.4903541107710174;">This has led to overdescription of the species and infraspecific taxa (subspecies, varieties or forms).</span>
<span style="opacity:0.6002110503795715;">This has led to overdescription of the species and infraspecific taxa (subspecies, varieties or forms).</span>
<span style="opacity:0.28030017008494884;">The name comes from the Greek word sambuce, an ancient wind instrument, about the removal of pith from the twigs to make whistles.Species recognized in this genus are:</span>
<span style="opacity:0.34482345596020914;">The name comes from the Greek word sambuce, an ancient wind instrument, about the removal of pith from the twigs to make whistles.Species recognized in this genus are:</span>
<h2 style="opacity:0.3774205134479782;">Distribution and habitat</h2>
<h2 style="opacity:0.47891993125291393;">Distribution and habitat</h2>
<span style="opacity:0.5170795700859395;">The genus occurs in temperate to subtropical regions of the world.</span>
<span style="opacity:0.6340646004006701;">The genus occurs in temperate to subtropical regions of the world.</span>
<span style="opacity:0.7289657600921431;">More widespread in the Northern Hemisphere, its Southern Hemisphere occurrence is restricted to parts of Australasia and South America.</span>
<span style="opacity:1;">More widespread in the Northern Hemisphere, its Southern Hemisphere occurrence is restricted to parts of Australasia and South America.</span>
<span style="opacity:0.004931060704500269;">Many species are widely cultivated for their ornamental leaves, flowers, and fruit.</span>
<span style="opacity:0.006577897127889425;">Many species are widely cultivated for their ornamental leaves, flowers, and fruit.</span>
<h3 style="opacity:0.34774180081331607;">Habitat</h3>
<h3 style="opacity:0.4279492553104596;">Habitat</h3>
<span style="opacity:0.23667717197372362;">Elder commonly grows near farms and homesteads.</span>
<span style="opacity:0.2935407300197428;">Elder commonly grows near farms and homesteads.</span>
<span style="opacity:0.3192589413693254;">It is a nitrogen-dependent plant and thus is generally found near places of organic waste disposal.</span>
<span style="opacity:0.39261719565060105;">It is a nitrogen-dependent plant and thus is generally found near places of organic waste disposal.</span>
<span style="opacity:0.20272560262481226;">Elders are often grown as a hedgerow plant in Britain since they take very fast, can be bent into shape easily, and grow quite profusely, thus having gained the reputation of being 'an instant hedge'.</span>
<span style="opacity:0.2508533161051221;">Elders are often grown as a hedgerow plant in Britain since they take very fast, can be bent into shape easily, and grow quite profusely, thus having gained the reputation of being 'an instant hedge'.</span>
<span style="opacity:0.632305487285403;">It is not generally affected by soil type or pH level and will virtually grow anywhere sufficient sunlight is available.</span>
<span style="opacity:0.7747857794663724;">It is not generally affected by soil type or pH level and will virtually grow anywhere sufficient sunlight is available.</span>
<h2 style="opacity:0.36011640223198155;">Ecology</h2>
<h2 style="opacity:0.4029280133054107;">Ecology</h2>
<span style="opacity:0.09934447961441183;">In Northern California, elderberries are a food for migrating band-tailed pigeons.</span>
<span style="opacity:0.1210833322272863;">In Northern California, elderberries are a food for migrating band-tailed pigeons.</span>
<span style="opacity:0.10833689405967695;">Elders are used as food plants by the larvae of some Lepidoptera species including brown-tail, buff ermine, dot moth, emperor moth, engrailed moth, swallow-tailed moth and the V-pug.</span>
<span style="opacity:0.13336328161002614;">Elders are used as food plants by the larvae of some Lepidoptera species including brown-tail, buff ermine, dot moth, emperor moth, engrailed moth, swallow-tailed moth and the V-pug.</span>
<span style="opacity:0.40509224339149436;">The crushed foliage and immature fruit have a strong fetid smell.</span>
<span style="opacity:0.4939358172986964;">The crushed foliage and immature fruit have a strong fetid smell.</span>
<span style="opacity:0.16493413805985815;">Valley elderberry longhorn beetles in California are very often found around red or blue elderberry bushes.</span>
<span style="opacity:0.1984833655171955;">Valley elderberry longhorn beetles in California are very often found around red or blue elderberry bushes.</span>
<span style="opacity:1;">Females lay their eggs on the bark.</span>
<span style="opacity:0.38299065826644807;">The pith of elder has been used by watchmakers for cleaning tools before intricate work.</span>
<span style="opacity:0.47070228317926044;">The pith of elder has been used by watchmakers for cleaning tools before intricate work.</span>
<h2 style="opacity:0.4959298303208725;">Cultivation</h2>
<h2 style="opacity:0.5328226429779531;">Cultivation</h2>
<span style="opacity:0.0023273321750337233;">Traditional uses of Sambucus involved berries, seeds, leaves, and flowers or component extracts.</span>
<span style="opacity:0.0029047613907370105;">Traditional uses of Sambucus involved berries, seeds, leaves, and flowers or component extracts.</span>
<span style="opacity:0.021538616933372428;">Ornamental varieties of Sambucus are grown in gardens for their showy flowers, fruits and lacy foliage which support habitat for wildlife.</span>
<span style="opacity:0.026750701274888614;">Ornamental varieties of Sambucus are grown in gardens for their showy flowers, fruits and lacy foliage which support habitat for wildlife.</span>
<span style="opacity:0.37967191922582566;">Of the many native species, three are used as ornamentals, S.</span>
<span style="opacity:0.4650516000644545;">Of the many native species, three are used as ornamentals, S.</span>
<span style="opacity:0.5720411135910031;">nigra, S.</span>
<span style="opacity:0.7022287951376384;">nigra, S.</span>
<span style="opacity:1;">canadensis and S.</span>
<span style="opacity:1;">racemosa.</span>
<h2 style="opacity:0.26037935627574993;">Uses</h2>
<h2 style="opacity:0.32293888112850844;">Uses</h2>
<h3 style="opacity:0.17679277695747428;">Nutrition</h3>
<h3 style="opacity:0.21324852554375795;">Nutrition</h3>
<span style="opacity:0.16562834706461427;">Raw elderberries are 80% water, 18% carbohydrates, and less than 1% each of protein and fat (table).</span>
<span style="opacity:0.19955733248302873;">Raw elderberries are 80% water, 18% carbohydrates, and less than 1% each of protein and fat (table).</span>
<span style="opacity:0.1368265507355418;">In a 100-gram (3+12 oz) amount, elderberries supply 305 kilojoules (73 kcal) of food energy and are a rich source of vitamin C, providing 43% of the Daily Value (DV).</span>
<span style="opacity:0.16476119602897354;">In a 100-gram (3+12 oz) amount, elderberries supply 305 kilojoules (73 kcal) of food energy and are a rich source of vitamin C, providing 43% of the Daily Value (DV).</span>
<span style="opacity:0.2279234330722667;">Elderberries also have moderate contents of vitamin B6 (18% DV) and iron (12% DV), with no other nutrients in significant content.</span>
<span style="opacity:0.2754270481192716;">Elderberries also have moderate contents of vitamin B6 (18% DV) and iron (12% DV), with no other nutrients in significant content.</span>
<h3 style="opacity:0.2385522392706748;">Dietary supplement</h3>
<h3 style="opacity:0.2938276513914447;">Dietary supplement</h3>
<span style="opacity:0.007324180292626893;">Elderberry fruit or flowers are used as dietary supplements to prevent or provide relief from minor diseases, such as flu, colds, constipation, and other conditions, served as a tea, extract or in a capsule.</span>
<span style="opacity:0.008843944949325498;">Elderberry fruit or flowers are used as dietary supplements to prevent or provide relief from minor diseases, such as flu, colds, constipation, and other conditions, served as a tea, extract or in a capsule.</span>
<span style="opacity:0.07793442880325537;">The use of elderberry supplements increased early in the COVID-19 pandemic.</span>
<span style="opacity:0.09692802159994876;">The use of elderberry supplements increased early in the COVID-19 pandemic.</span>
<span style="opacity:0.5690343662424139;">There is insufficient research to establish its effectiveness for such uses, or its safety profile.</span>
<span style="opacity:0.7009586522740578;">There is insufficient research to establish its effectiveness for such uses, or its safety profile.</span>
<span style="opacity:0.3046053054729051;">The raw or unripe fruit of S.</span>
<span style="opacity:0.3708298870955282;">The raw or unripe fruit of S.</span>
<span style="opacity:0.23386291554217284;">nigra or its extracts may contain a cyanogenic glycoside that is potentially toxic.</span>
<span style="opacity:0.29157775103836303;">nigra or its extracts may contain a cyanogenic glycoside that is potentially toxic.</span>
<h3 style="opacity:0.30036772549577245;">Traditional medicine</h3>
<h3 style="opacity:0.3756752383995718;">Traditional medicine</h3>
<span style="opacity:0.12635509010408633;">Although practitioners of traditional medicine have used elderberry over centuries, there is no high-quality clinical evidence that such practices provide any benefit.</span>
<span style="opacity:0.15312147242489166;">Although practitioners of traditional medicine have used elderberry over centuries, there is no high-quality clinical evidence that such practices provide any benefit.</span>
<span style="opacity:0.04619027362780958;">The flowers of Sambucus nigra are used to produce elderflower cordial.</span>
<span style="opacity:0.059692742210825565;">The flowers of Sambucus nigra are used to produce elderflower cordial.</span>
<span style="opacity:0.5605661316829006;">St-Germain, a French liqueur, is made from elderflowers.</span>
<span style="opacity:0.6952577250945293;">St-Germain, a French liqueur, is made from elderflowers.</span>
<span style="opacity:0.6249597590948577;">Hallands Fläder, a Swedish akvavit, is flavoured with elderflowers.</span>
<span style="opacity:0.772149196516331;">Hallands Fläder, a Swedish akvavit, is flavoured with elderflowers.</span>
<span style="opacity:0.058473741273256635;">Hollowed elderberry twigs have traditionally been used as spiles to tap maple trees for syrup.</span>
<span style="opacity:0.07063443562347409;">Hollowed elderberry twigs have traditionally been used as spiles to tap maple trees for syrup.</span>
<span style="opacity:0.36742927908821876;">Additionally, they have been hollowed out and used as flutes, blowguns, and syringes.The fruit of S.</span>
<span style="opacity:0.4476112013602327;">Additionally, they have been hollowed out and used as flutes, blowguns, and syringes.The fruit of S.</span>
<span style="opacity:0.7665194357270494;">callicarpa is eaten by birds and mammals.</span>
<span style="opacity:1;">callicarpa is eaten by birds and mammals.</span>
<span style="opacity:0.04897270752302531;">It is inedible to humans when raw but can be made into wine.Elderberry twigs and fruit are employed in creating dyes for basketry.</span>
<span style="opacity:0.05855929701898997;">It is inedible to humans when raw but can be made into wine.Elderberry twigs and fruit are employed in creating dyes for basketry.</span>
<span style="opacity:0.10384311134074758;">These stems are dyed a very deep black by soaking them in a wash made from the berry stems of the elderberry.</span>
<span style="opacity:0.12405107534687186;">These stems are dyed a very deep black by soaking them in a wash made from the berry stems of the elderberry.</span>
<h2 style="opacity:0.1940215897275913;">In popular culture</h2>
<h2 style="opacity:0.23808695665803478;">In popular culture</h2>
<span style="opacity:0.26902332053709666;">Folklore related to elder trees is extensive and can vary according to region.</span>
<span style="opacity:0.33194437661756426;">Folklore related to elder trees is extensive and can vary according to region.</span>
<span style="opacity:0.042182724177350944;">In some traditions, the elder tree is thought to ward off evil and give protection from witches, while other beliefs say that witches often congregate under the plant, especially when it is full of fruit.</span>
<span style="opacity:0.052198247901650126;">In some traditions, the elder tree is thought to ward off evil and give protection from witches, while other beliefs say that witches often congregate under the plant, especially when it is full of fruit.</span>
<span style="opacity:0.24981940690065454;">If an elder tree was cut down, a spirit known as the Elder Mother would be released and take her revenge.</span>
<span style="opacity:0.3075423669066911;">If an elder tree was cut down, a spirit known as the Elder Mother would be released and take her revenge.</span>
<span style="opacity:0.18680917834736657;">The tree could only safely be cut while chanting a rhyme to the Elder Mother.Made from the branch of an elder tree, the Elder Wand plays a pivotal role in the final book of the Harry Potter series, which was nearly named Harry Potter and the Elder Wand before author J.</span>
<span style="opacity:0.23037929988653943;">The tree could only safely be cut while chanting a rhyme to the Elder Mother.Made from the branch of an elder tree, the Elder Wand plays a pivotal role in the final book of the Harry Potter series, which was nearly named Harry Potter and the Elder Wand before author J.</span>
<span style="opacity:0.22868031954081833;">K. Rowling decided on Harry Potter and the Deathly Hallows.Elton John's 1973 album Don't Shoot Me I'm Only the Piano Player features a song titled "Elderberry Wine".</span>
<span style="opacity:0.27690668211679204;">K. Rowling decided on Harry Potter and the Deathly Hallows.Elton John's 1973 album Don't Shoot Me I'm Only the Piano Player features a song titled "Elderberry Wine".</span>
<span style="opacity:0.1876145888622608;">In Monty Python and the Holy Grail, John Cleese as the French Taunter tells the knights of Camelot, "Your mother was a hamster, and your father smelt of elderberries."</span>
<span style="opacity:0.22955076651897152;">In Monty Python and the Holy Grail, John Cleese as the French Taunter tells the knights of Camelot, "Your mother was a hamster, and your father smelt of elderberries."</span>
<h2 style="opacity:NaN;">Gallery</h2>

@ -0,0 +1,124 @@
from flask import Flask
from flask import request, render_template
from markdown import markdown
import sys
app = Flask("recommend")
# appending a path
sys.path.append('../')
# importing customised module
import summa.edits
from summa.edits import scored_sentences, similarity_graph
import wikipage
from wikipage.page import get_wikipage
context = {
'page_name' : "door",
'page' : None,
'graph' : None,
'sentences' : None,
'current_sentence' : None
}
# TextRank
# ------------------------------------------------------------------------
def get_similar_sentences(s0, sentences, graph):
# return a list of all the sentences ordered by similarity to s0
similar_sentences = sorted(sentences, key=lambda s: graph.edge_weight((s0.token, s.token)), reverse=True)
return similar_sentences
# main
# ------------------------------------------------------------------------
def new_page(page_name):
# from a pagename get
# 1. get the page text
# 2. graph and scored sentences
# --- WIKI REQUEST ---
# get text from wikipedia
print('--- WIKI ---')
context['page'] = get_wikipage(page_name)
if not context['page']:
sys.exit("--- STOP ---")
text = context['page'].content
# print text in terminal
print('--- TXT ---')
print(text)
# --- APPLY TEXTRANK ---
# apply textrank
context['sentences'] = scored_sentences(text)
context['graph'] = similarity_graph(text)
@app.route("/")
def index():
if 'token' in request.args:
token = request.args['token']
context['current_sentence'] = [s for s in context['sentences'] if s.token == token][0]
else:
new_page(context['page_name'])
sorted_sentences = sorted(context['sentences'], key=lambda s: s.score, reverse=True)
best_sentence = sorted_sentences[0]
print("--- START/BEST ---")
print(best_sentence.text)
context['current_sentence'] = best_sentence
# sentences ordered by similarity to the best one
similar_sentences = get_similar_sentences(context['current_sentence'] , context['sentences'], context['graph'])
current_sentence=context['current_sentence']
return render_template('index.html', current_sentence=current_sentence , similar_sentences=similar_sentences)
# # --- APPLY TEXTRANK ---
# # apply textrank
# sentences = scored_sentences(text)
# graph = similarity_graph(text)
# # print ranked sentences in terminal
# print('--- GRAPH ---')
# # notes:
# # * the matrix/graph does not contain the sentences but their .token
# sorted_sentences = sorted(sentences, key=lambda s: s.score, reverse=True)
# best_sentence = sorted_sentences[0]
# print("START/BEST: \n")
# print(best_sentence.text + "\n")
# # sentences ordered by similarity to the best one
# similar_sentences = similar_sentences(best_sentence, sentences, graph)
# for i in range(len(similar_sentences)):
# print(str(i) + ". " + similar_sentences[i].text)
# # for s1 in sentences:
# # for s2 in sentences:
# # if s1 != s2:
# # if graph.has_node(s1.token) and graph.has_node(s2.token):
# # weight = graph.edge_weight((s1.token, s2.token))
# # print('---')
# # print('1. ' + s1.text)
# # print('2. ' + s2.text)
# # print('similarity: ' + str(weight))

@ -1,56 +0,0 @@
from jinja2 import Template
from markdown import markdown
import sys
# appending a path
sys.path.append('../')
# importing customised module
import summa.edits
from summa.edits import scored_sentences, similarity_graph
import wikipage
from wikipage.page import get_wikipage
wikipedia_page = "mushroom"
# main
# ------------------------------------------------------------------------
if __name__ == '__main__':
# --- WIKI REQUEST ---
# get text from wikipedia
print('--- WIKI ---')
page = get_wikipage(wikipedia_page)
if not page:
sys.exit("--- STOP ---")
title = '<h1>'+page.title+'</h1>'
text = page.content
# print text in terminal
print('--- TXT ---')
print(text)
# --- APPLY TEXTRANK ---
# apply textrank
graph = similarity_graph(text)
# print ranked sentences in terminal
print('--- GRAPH ---')
# for i in len(graph.nodes()):
# for j in len(graph.nodes()):
# s1 = graph.nodes()[i]
# s2 = graph.nodes()[j]
# weight = graph.edge_weight((i, j))
# print('---')
# print('1. ' + s1)
# print('2. ' + s1)
# print('similarity: ' + weight)

@ -0,0 +1,4 @@
export FLASK_APP=app
export FLASK_ENV=development
flask run

@ -0,0 +1,47 @@
:root{
--lh: 1.35;
}
body{
line-height: var(--lh);
display: grid;
grid-template-columns: 2fr 1fr;
gap: 6em;
}
main{
padding: 6em;
padding-right: 0;
}
main p{
border: thin solid lightgrey;
box-sizing: border-box;
border-radius: 1em;
padding: 4em;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
aside{
font-size: 0.8em;
box-sizing: border-box;
padding: 2em 0;
padding-left: 0;
padding-right: 6em;
height: 100vh;
overflow: auto;
}
aside li{
padding: 2em 0;
}
h2{
font-weight: bold;
}

@ -0,0 +1,48 @@
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}

@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Recommended Reading</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="static/css/reset.css" />
<link rel="stylesheet" type="text/css" href="static/css/main.css" />
</head>
<body>
<main>
<p>
{{ current_sentence.text }}
</p>
</main>
<aside>
<nav>
<h2>recommended:</h2>
<ul>
{% for s in similar_sentences %}
<li>
<a href="/?token={{ s.token }}">{{ s.text }}</a>
</li>
{% endfor %}
</ul>
</nav>
</aside>
</body>
</html>
Loading…
Cancel
Save