Changes to poster export

master^2
jvdhorst 6 years ago
parent 1179c8451b
commit 0b520856e4

@ -1,101 +1,21 @@
Any one is one having been that one Any one is such a one.
Any one having been that one is one remembering something oi such a thing, is one
remembering having been that one.
Each one having been one is being one having been that one. Each one haying been
one is remembering something of this thing, is remembering something or haying been
that one
Each one is one. Each one has been one. Each one being one, each one havrng been
one is remembering something or that thing.
Each one is one. Each one has been one. Each one is remembering that thing.
Each one is one. Each one has been one. That is something that any one haying been
one, any one being one is having happen Each one being one is haying it happen that
that one is being that one. Each one having been one is one havrng had it happen that
that one has been that one.
Each one is one. Any one is the one that one is Each one is one.
One who is one is remembering that she is one forgetting anything. One who is one is
remembering that she is forgetting everything again and again She is remembering
this thing She is not interested in this thing She is remembering this thing and she is
remembering that this is a quite necessary thing, it is quite a necessary thing that she IS
remembering that she is iorgetting anything.
She is to getting anything This is not a disturbing thing, this is not a distressing thing,
this is not an important thing She is iorgetting anything and she is remembering that
thing, she is remembering that she is forgetting anything.
She is ore being one remembering that she is forgetting anything She is one not
objecting to being one remembering that thing, remembering that she is forgetting
anything She is one objecting to there being some objecting to being ones forgetting
anything She is one objecting to any one being one remembering that they are not
iorgetting anything She is one objecting to any one objecting to her being one
forgetting anything She is not one remembering being one objecting to any one
objecting to her being one iorgetting anything She is one remembering that she is one
objecting to being one remembering that they are not forgetting anything. She is one
remembering something of being one objecting to some being one objecting to
forgetting anything
She is one forgetting anything. She is one remembering something of this thing She is
one repeating this thing repeating remembering something of forgetting anything,
She is one remembering that she has been having something. She is one remembering
something of this thing She has been having something, she is having something, she
is remembering something of this thing. She is not objecting to having something, she
is having something she is remembering something of this thing
She is one being that one being one having something and remembering something of
that thing She is one being one and she is iorgetting anything and she is remembering
being one forgetting anything.
Any one she is kissing is one she is kissing then, not kissing again and again, not
fissing and kissing, any one she is kissing is one she kissed then, is one she did kiss
then. one she kissed some then
Any one she is kissing is one needing something then, needing kissing, needing
anytinng first then, needing some kissing then. Any one she is kissing is one having
been kissed then, having been kissed some then and she was the one who was kissing
that one some just then Any one she was kissing was one whom she was kissing just
from hows Vests to i narrating Ouhry
that Any one she was kissing was one who might have been needing something then,
needing anything then, needing kissing then, needing a little kissing then, needing any ‘»
Mtg anything then, needing kissing then, needing a little kissing then, needing any
kiss!!!) then, needing something then, needing kissing then
She was one living and remembering that she had enough for this thing, enough for
than She was one remembering that she had enough for being livrng and she was
runemben'ng that she could always be needing that thing needing having enough to be
m She could remembering to remind herself and any one of this thing, she could
W that thing, she could remember to be reminded of that thing. She could
W to beone reminding herself, she could remember to be one havmg any one
rewind her quite often of this thing that she could remember that she had enough and
wot“ be always having enough to be livrng. She could remembering that she was
needing this thing needing having enough always enough for livmg. She could
rentemtler enough oi reminding any one of this thing. She could remember this thing
rectum reminding herself of this thing. She could remember something of being
rein-Iced of this thing. She could remember this thing, she could remember a good
deal of knowing that she was havmg enough for berng living and that she could always
be neodng having enough for liVing. She could remember this thing, she could qurte
new that thing.
She was one forgetting anything. She was remembering something of that thing of
toasting anything She could always remember something of that thing, remember
m of forgetting anything.
in giving she was giving what she had then remembered to give then In gwing she
Write it down quickly
before I forget
in the car with D. and N.
cutting across Americas seasons
muggy sunlight in Santa Barbara
wet snow in Denver
and in every Best Western hotel
the TVs flickering light
on her dear sleeping face
like a young girl once again
but writing down the words
alters what I want to remember
that which had no words
was a living breathing image
so now I have two versions of the same
today I can superimpose them
but tomorrow when Im gone
only the words are left
signs evoking something
that no eye sees any more

@ -0,0 +1,97 @@
@page {
/* dimensions for the whole page */
size: 297mm 420mm;
margin: 7rem 2rem 7rem 2rem;
background-color: #d9d9d6; /* To emulate #dfdfdf on print at PZI Canon MFP */
position: absolute;
display: table;
@bottom-center {
content: 'make reading_structure';
font-family: 'Ubuntu Mono', monospace;
white-space: pre;
color: #000;
padding-bottom: 3em;
}
}
/* ---
ELEMENTS TO CHANGE HIDDEN WORDS AND ACCENT COLOR
--- */
span.word_label, .adjective .word, .adverb .word {
display: block;
opacity: 0;
width: 100%;
font-size: 1rem;
}
.adjective > .pos, .adverb > .pos {
color: #8e445e;
}
/* ---
BASIC ELEMENTS
--- */
body {
background-color: transparent !important;
font-size: 20px;
}
.container {
margin: 0 auto;
padding: 3rem 2.5rem;
max-width: 100% !important;
height: 100px !important;
background-color: transparent !important;
border: none !important;
}
span.wrapper {
display: inline-block;
font-family: 'PT Serif', serif;
font-size: 1.5rem;
text-align:center;
position: relative;
margin-bottom: 1rem;
color: #000;
}
.action-container {
display: none;
}
/* ---
ELEMENTS IN .WRAPPER
--- */
.word, .tag {
display: block;
position: relative;
margin: 0 auto;
clear:both;
}
.word {
margin-top: 0.2rem;
}
span.invisible {
}
span.tag {
color: #fff;
font-family: 'Ubuntu Mono', monospace;
font-size: 0.8rem;
}

@ -0,0 +1,97 @@
@page {
/* dimensions for the whole page */
size: 297mm 420mm;
margin: 7rem 2rem 7rem 2rem;
background-color: #d9d9d6; /* To emulate #dfdfdf on print at PZI Canon MFP */
position: absolute;
display: table;
@bottom-center {
content: 'make reading_structure';
font-family: 'Ubuntu Mono', monospace;
white-space: pre;
color: #000;
padding-bottom: 3em;
}
}
/* ---
ELEMENTS TO CHANGE HIDDEN WORDS AND ACCENT COLOR
--- */
span.word_label, .pronoun .word, .determiner .word, .to .word, .preposition .word {
display: block;
opacity: 0;
width: 100%;
font-size: 1rem;
}
.pronoun > .pos, .determiner > .pos, .to > .pos, .preposition > .pos {
color: #2f7f40;
}
/* ---
BASIC ELEMENTS
--- */
body {
background-color: transparent !important;
font-size: 20px;
}
.container {
margin: 0 auto;
padding: 3rem 2.5rem;
max-width: 100% !important;
height: 100px !important;
background-color: transparent !important;
border: none !important;
}
span.wrapper {
display: inline-block;
font-family: 'PT Serif', serif;
font-size: 1.5rem;
text-align:center;
position: relative;
margin-bottom: 1rem;
color: #000;
}
.action-container {
display: none;
}
/* ---
ELEMENTS IN .WRAPPER
--- */
.word, .tag {
display: block;
position: relative;
margin: 0 auto;
clear:both;
}
.word {
margin-top: 0.2rem;
}
span.invisible {
}
span.tag {
color: #fff;
font-family: 'Ubuntu Mono', monospace;
font-size: 0.8rem;
}

@ -0,0 +1,97 @@
@page {
/* dimensions for the whole page */
size: 297mm 420mm;
margin: 7rem 2rem 7rem 2rem;
background-color: #d9d9d6; /* To emulate #dfdfdf on print at PZI Canon MFP */
position: absolute;
display: table;
@bottom-center {
content: 'make reading_structure';
font-family: 'Ubuntu Mono', monospace;
white-space: pre;
color: #000;
padding-bottom: 3em;
}
}
/* ---
ELEMENTS TO CHANGE HIDDEN WORDS AND ACCENT COLOR
--- */
span.word_label, .neutral .word {
display: block;
opacity: 0;
width: 100%;
font-size: 1rem;
}
.neutral > .sentiment {
color: #8491a5;
}
/* ---
BASIC ELEMENTS
--- */
body {
background-color: transparent !important;
font-size: 20px;
}
.container {
margin: 0 auto;
padding: 3rem 2.5rem;
max-width: 100% !important;
height: 100px !important;
background-color: transparent !important;
border: none !important;
}
span.wrapper {
display: inline-block;
font-family: 'PT Serif', serif;
font-size: 1.5rem;
text-align:center;
position: relative;
margin-bottom: 1rem;
color: #000;
}
.action-container {
display: none;
}
/* ---
ELEMENTS IN .WRAPPER
--- */
.word, .tag {
display: block;
position: relative;
margin: 0 auto;
clear:both;
}
.word {
margin-top: 0.2rem;
}
span.invisible {
}
span.tag {
color: #fff;
font-family: 'Ubuntu Mono', monospace;
font-size: 0.8rem;
}

@ -0,0 +1,97 @@
@page {
/* dimensions for the whole page */
size: 297mm 420mm;
margin: 7rem 2rem 7rem 2rem;
background-color: #d9d9d6; /* To emulate #dfdfdf on print at PZI Canon MFP */
position: absolute;
display: table;
@bottom-center {
content: 'make output/reading_structure';
font-family: 'Ubuntu Mono', monospace;
white-space: pre;
color: #000;
padding-bottom: 3em;
}
}
/* ---
ELEMENTS TO CHANGE HIDDEN WORDS AND ACCENT COLOR
--- */
span.word_label, .noun .word {
display: block;
opacity: 0;
width: 100%;
font-size: 1rem;
}
.noun > .pos {
color: #003cb3;
}
/* ---
BASIC ELEMENTS
--- */
body {
background-color: transparent !important;
font-size: 20px;
}
.container {
margin: 0 auto;
padding: 3rem 2.5rem;
max-width: 100% !important;
height: 100px !important;
background-color: transparent !important;
border: none !important;
}
span.wrapper {
display: inline-block;
font-family: 'PT Serif', serif;
font-size: 1.5rem;
text-align:center;
position: relative;
margin-bottom: 1rem;
color: #000;
}
.action-container {
display: none;
}
/* ---
ELEMENTS IN .WRAPPER
--- */
.word, .tag {
display: block;
position: relative;
margin: 0 auto;
clear:both;
}
.word {
margin-top: 0.2rem;
}
span.invisible {
}
span.tag {
color: #fff;
font-family: 'Ubuntu Mono', monospace;
font-size: 0.8rem;
}

@ -0,0 +1,101 @@
@page {
/* dimensions for the whole page */
size: 297mm 420mm;
margin: 7rem 2rem 7rem 2rem;
background-color: #d9d9d6; /* To emulate #dfdfdf on print at PZI Canon MFP */
position: absolute;
display: table;
@bottom-center {
content: 'make output/reading_structure';
font-family: 'Ubuntu Mono', monospace;
white-space: pre;
color: #000;
padding-bottom: 3em;
}
}
/* ---
ELEMENTS TO CHANGE HIDDEN WORDS AND ACCENT COLOR
--- */
span.word_label, .stopword .word {
display: block;
opacity: 0;
width: 100%;
font-size: 1rem;
}
.stopword > .wordtype:hover, {
opacity: 1;
}
.stopword > .wordtype {
color: #b83e54;
}
/* ---
BASIC ELEMENTS
--- */
body {
background-color: transparent !important;
font-size: 20px;
}
.container {
margin: 0 auto;
padding: 3rem 2.5rem;
max-width: 100% !important;
height: 100px !important;
background-color: transparent !important;
border: none !important;
}
span.wrapper {
display: inline-block;
font-family: 'PT Serif', serif;
font-size: 1.5rem;
text-align:center;
position: relative;
margin-bottom: 1rem;
color: #000;
}
.action-container {
display: none;
}
/* ---
ELEMENTS IN .WRAPPER
--- */
.word, .tag {
display: block;
position: relative;
margin: 0 auto;
clear:both;
}
.word {
margin-top: 0.2rem;
}
span.invisible {
}
span.tag {
color: #fff;
font-family: 'Ubuntu Mono', monospace;
font-size: 0.8rem;
}

@ -1,19 +1,43 @@
@page {
/* dimensions for the whole page */
size: A3 portrait;
margin: 2rem 2rem 3em 2rem;
background-color: #003cb3;
size: 297mm 420mm;
margin: 7rem 2rem 7rem 2rem;
background-color: #d9d9d6; /* To emulate #dfdfdf on print at PZI Canon MFP */
position: absolute;
display: table;
@bottom-center {
content: 'make output/reading_structure';
font-family: 'Ubuntu Mono', monospace;
white-space: pre;
color: #fff;
padding-bottom: 2rem;
color: #000;
padding-bottom: 3em;
}
}
/* ---
ELEMENTS TO CHANGE HIDDEN WORDS AND ACCENT COLOR
--- */
span.word_label, .stopword .word {
display: block;
opacity: 0;
width: 100%;
font-size: 1rem;
}
.stopword > .wordtype:hover, {
opacity: 1;
}
.stopword > .wordtype {
color: #b83e54;
}
/* ---
BASIC ELEMENTS
@ -21,17 +45,18 @@
--- */
body {
background-color: none !important;
background-color: transparent !important;
font-size: 20px;
}
.container {
margin: 0 auto;
padding: 2rem 2.5rem;
padding: 3rem 2.5rem;
max-width: 100% !important;
min-height: 90% !important;
background-color: #003cb3 !important;
height: 100px !important;
background-color: transparent !important;
border: none !important;
}
span.wrapper {
@ -41,7 +66,7 @@ span.wrapper {
text-align:center;
position: relative;
margin-bottom: 1rem;
color: #fff;
color: #000;
}
.action-container {
@ -71,29 +96,6 @@ span.invisible {
span.tag {
color: #fff;
opacity: 0.5;
font-family: 'Ubuntu Mono', monospace;
font-size: 0.8rem;
}
/* Show original word when hovering label */
span.word_label, .stopword .word {
display: block;
opacity: 0;
width: 100%;
font-size: 1rem;
}
.stopword > .wordtype:hover, {
opacity: 1;
/*color: red;*/
}
.stopword > .wordtype {
opacity: 1;
}
/* Spacing fix for punctuation */
.punctuation {
margin-left: -4px;
}

@ -3,9 +3,10 @@ import nltk
import json
import os
from sys import stdin, stdout
from nltk import ne_chunk, pos_tag, word_tokenize
from nltk import pos_tag, word_tokenize
from nltk.sentiment.vader import SentimentIntensityAnalyzer
from nltk.corpus import stopwords
import spacy
from jinja2 import Template
# == INPUT AND TOKENIZE ==
@ -13,20 +14,20 @@ from jinja2 import Template
input = stdin.read()
words = nltk.word_tokenize(input)
words_and_tags = {index : {'word':word} for index , word in enumerate(words)}
print(words_and_tags)
#print(words_and_tags)
# == FILTER FUNCTIONS ==
# == TAGGING FUNCTIONS ==
# === 1. POS_tagger & Named Entity Recognizer ===
# This function cuts a string into words. Then runs a POS tagger for each word. Returns a list with tags
def POS_tagger(list):
taggedwordlist = nltk.pos_tag(list)
for word, pos in nltk.pos_tag(list):
taggedwordlist = nltk.pos_tag(list)
#print('{0} is a {1}'.format(word,pos)) # Comment out to print the analysis step
print(taggedwordlist)
#print(taggedwordlist)
taglist = [ pos for word,pos in taggedwordlist ]
POS_tags = []
@ -35,7 +36,7 @@ def POS_tagger(list):
POS_tag = 'noun'
elif tag in {'VB','VBD','VBG','VBN','VBP','VBZ'}:
POS_tag = 'verb'
elif tag in {'RB','RBR','RBS','WRB'}:
elif tag in {'RB','RBR','RBS','WRB', 'RP'}:
POS_tag = 'adverb'
elif tag in {'PRP','PRP$'}:
POS_tag = 'pronoun'
@ -68,14 +69,16 @@ def POS_tagger(list):
elif tag == 'CD':
POS_tag = 'cardinal number'
elif tag == 'TO':
POS_tag = 'infinitival to'
POS_tag = 'to'
elif tag == '.':
POS_tag = 'line ending'
elif tag == ',':
POS_tag = 'comma'
else:
POS_tag = tag
POS_tags.append(POS_tag)
#print(POS_tag)
return POS_tags;
@ -113,12 +116,67 @@ def stopword_tagger(word):
return stopword_tag
# === 4. Named Entity tagger ===
def ner_tagger(list):
ner_en = spacy.load('en_core_web_sm') # use English model for SpaCy
#ner_en = spacy.load('xx_ent_wiki_sm') # use multilingual model (performance was less than the English model in my use case)
text = " ".join(list) # Convert NLTK tokens back to string, so SpaCy can change it to its own format
ner_spacy_doc = ner_en(text)
ner_tags = []
for word in ner_spacy_doc:
#print(word.ent_type_)
if word.ent_type_ == "PERSON":
ner_tag = 'geographical entity'
elif word.ent_type_ == 'NORP':
ner_tag = 'group'
elif word.ent_type_ == 'FACILITY':
ner_tag = 'facility'
elif word.ent_type_ == 'ORG':
ner_tag = 'organisation'
elif word.ent_type_ in {'GPE','LOC'}:
ner_tag = 'location'
elif word.ent_type_ == 'PRODUCT':
ner_tag = 'product'
elif word.ent_type_ == 'EVENT':
ner_tag = 'event'
elif word.ent_type_ == 'WORK_OF_ART':
ner_tag = 'artwork'
elif word.ent_type_ == 'LAW':
ner_tag = 'law'
elif word.ent_type_ == 'LANGUAGE':
ner_tag = 'language'
elif word.ent_type_ == 'DATE':
ner_tag = 'date'
elif word.ent_type_ == 'TIME':
ner_tag = 'time'
elif word.ent_type_ == 'PERCENT':
ner_tag = 'percentage'
elif word.ent_type_ == 'MONEY':
ner_tag = 'monetary value'
elif word.ent_type_ == 'QUANTITY':
ner_tag = 'measurement'
elif word.ent_type_ == 'ORDINAL':
ner_tag = 'ordinal'
elif word.ent_type_ == 'CARDINAL':
ner_tag = 'numeral'
else:
ner_tag = 'no entity'
ner_tags.append(ner_tag)
print(ner_tags)
return ner_tags
# Run POS tagger
# This tagger outputs a list for all items in the dict at once
# These tagger outputs a list for all items in the dict at once
# To avoid double work, it is better to keep this outside the for loop
POS_tags = POS_tagger(words)
sentiment_tags = sentiment_tagger(words)
ner_tags = ner_tagger(words)
i = 0
# Adding tags to words in dictionary, which will be exported as a json file
@ -129,24 +187,28 @@ for item, value in words_and_tags.items():
# POS
pos_tag = POS_tags[i]
words_and_tags[item]['POS'] = pos_tag
#i = i+1
# Add sentiment tag
#sentiment_tag = sentiment_tagger(word)
#words_and_tags[item]['sentiment'] = sentiment_tag
sentiment_tag = sentiment_tags[i]
words_and_tags[item]['sentiment'] = sentiment_tag
# Named Entity Recognition
ner_tag = ner_tags[i]
words_and_tags[item]['named entity'] = ner_tag
# Move to the next word in the tokenized words dictionary
i = i+1
# Add stopword tag
stopword_tag = stopword_tagger(word)
words_and_tags[item]['wordtype'] = stopword_tag
# Add entity tag
# Not functional yet
# Save data into a json file
print(words_and_tags)
#print(words_and_tags)
#with open("data.json", 'w') as f:
with open(os.path.dirname(os.path.dirname(os.path.dirname( __file__ ))) + "output/reading_structure/data.json", 'w') as f:
json.dump(words_and_tags, f, ensure_ascii=False)
@ -159,7 +221,7 @@ index_render = template.render(words_and_tags=words_and_tags)
#print(text_render)
# And render an html file!
print(index_render)
#print(index_render)
index_open = open("output/reading_structure/index.html", "w")
index_open.write(index_render)
index_open.close()

@ -28,8 +28,8 @@ $(document).ready(function(){
var stopword_label = $('.stopword > .wordtype');
// State 2 Selectors for the sentiment tagger, showing neutral words and their labels
var posneg_word = $('.negative > .word, .positive > .word');
var posneg_label = $('.negative > .sentiment, .positive > .sentiment');
var known_entity_word = $('.known_entity > .word, .pronoun > .word');
var known_entity_label = $('.known_entity > .ner, .pronoun > .pos');
// State 3 Selectors for the noun taggger
var noun_word = $('.noun > .word');
@ -60,13 +60,17 @@ $(document).ready(function(){
stopword_word.removeClass('word_label');
stopword_label.addClass('invisible');
posneg_word.addClass('word_label');
posneg_label.removeClass('invisible');
$("#poster").prop("href", "poster-neutral.pdf")
known_entity_word.addClass('word_label');
known_entity_label.removeClass('invisible');
}
if (state == 2) {
posneg_word.removeClass('word_label');
posneg_label.addClass('invisible');
known_entity_word.removeClass('word_label');
known_entity_label.addClass('invisible');
$("#poster").prop("href", "poster-neutral.pdf")
noun_word.addClass('word_label');
noun_label.removeClass('invisible');
@ -76,6 +80,8 @@ $(document).ready(function(){
noun_word.removeClass('word_label');
noun_label.addClass('invisible');
$("#poster").prop("href", "poster-neutral.pdf")
ad_word.addClass('word_label');
ad_label.removeClass('invisible');
}
@ -84,6 +90,8 @@ $(document).ready(function(){
ad_word.removeClass('word_label');
ad_label.addClass('invisible');
$("#poster").prop("href", "poster-neutral.pdf")
dppt_word.addClass('word_label');
dppt_label.removeClass('invisible');
}
@ -92,6 +100,8 @@ $(document).ready(function(){
dppt_word.removeClass('word_label');
dppt_label.addClass('invisible');
$("#poster").prop("href", "poster-neutral.pdf")
neutral_word.addClass('word_label');
neutral_label.removeClass('invisible');
}
@ -100,6 +110,8 @@ $(document).ready(function(){
neutral_word.removeClass('word_label');
neutral_label.addClass('invisible');
$("#poster").prop("href", "poster-neutral.pdf")
stopword_word.addClass('word_label');
stopword_label.removeClass('invisible');

@ -5,7 +5,7 @@
--- */
body {
background-color: #dfdfdf;
background-color: #d9d9d6;
}
.container {
@ -123,11 +123,7 @@ span.word_label {
color: #8491a5;
}
.negative .sentiment {
color: #c9805b;
}
.positive .sentiment {
.known_entity .ner, .pronoun .pos {
color: #44a889;
}

@ -13,7 +13,8 @@
<div class="container"><p>
{% for item, value in words_and_tags.items() %}
<span id="{{item}}" class="wrapper {{ words_and_tags[item]['wordtype'] }} {{ words_and_tags[item]['sentiment'] }} {{ words_and_tags[item]['POS'] }}">
<span id="{{item}}" class="wrapper {{ words_and_tags[item]['wordtype'] }} {{ words_and_tags[item]['sentiment'] }} {{ words_and_tags[item]['POS'] }} {% if words_and_tags[item]['named entity'] == 'no entity' %} no_entity {% else %} known_entity {% endif %}">
<span class ="tag ner invisible"> {{ words_and_tags[item]['named entity'] }}</span>
<span class ="tag wordtype invisible"> {{ words_and_tags[item]['wordtype'] }} </span>
<span class ="tag sentiment invisible"> {{ words_and_tags[item]['sentiment'] }}</span>
<span class ="tag pos invisible"> {{ words_and_tags[item]['POS'] }}</span>
@ -26,7 +27,7 @@
<div class="action-container">
<p><a href="data.json" download>Export data as json</a> </p>
<p><a href="poster.pdf" download>Print this as a poster</a> </p>
<p><a id="poster" href="poster.pdf" download>Print this as a poster</a></p>
</div>
</body>

Loading…
Cancel
Save