This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pandas as pd | |
import fitz | |
from collections import Counter | |
import spacy | |
nlp = spacy.load('en_core_web_trf') | |
magazin_fol = "myfol/magazines/" | |
out_full_fp = "myfol/word_count_full.csv" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
data_fol = "/myLocal/dataFol/" | |
# wc = wordcount. Make words lower case to make interpretation easier. Remove words that might still have <2 characters. | |
wc_df = pd.read_csv(data_fol + "word_count_full.csv", sep=";", decimal=",", encoding="utf8") | |
wc_df["word"] = wc_df["word"].str.lower() | |
wc_df = wc_df[wc_df["word"].str.len() > 2] | |
# convert str date column to pandas datetime format and extract months & years... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
word | date | word_cnt_page | |
---|---|---|---|
before | 2017-06-21 | 2 | |
before | 2017-07-05 | 2 | |
before | 2017-10-11 | 1 | |
before | 2018-01-31 | 2 | |
before | 2018-02-14 | 2 | |
before | 2018-07-18 | 1 | |
before | 2018-09-26 | 1 | |
before | 2018-10-24 | 2 | |
before | 2018-11-07 | 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# 1.0 Imports | |
import dash | |
from dash import dcc | |
from dash import html | |
from dash.dependencies import Output | |
from dash.dependencies import Input |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 3.1 PAGE 1 | |
# store ALL of the following html in a variable page1_content. This is called when switching pages | |
# wrap everything in an out Div | |
page1_content = html.Div( | |
children=[ | |
#header, this is a child of the outer div. All header information is then | |
# wrapped in its own Div | |
html.Div( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 4.1 switch between pages. Each callback is connected to the function below | |
@app.callback(Output("page-content", "children"), # returns the page content of the clicked page | |
[Input("url", "pathname")]) # get the pathname from the url click as input | |
def render_page_content(pathname): # function input the the Input() parameter from the callback decorator | |
if pathname == "/": | |
return page1_content | |
elif pathname == "/page2_url": | |
return page2_content | |
# If the user tries to reach a different page, return an error message | |
return html.Div( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 5 run the darn thing | |
if __name__ == "__main__": | |
# this will run the app on your local machine: basically dash will run | |
# its own dev server on localhost: visit 127.0.0.1:8050 in your browser to | |
# see your app | |
app.run_server(port=8050, debug=True) | |
#HOWEVER, if you are deploying it later, set your host to "0.0.0.0", | |
# because dash will not be responsible for managing the server itself |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# 1.0 Imports | |
import dash | |
from dash import dcc | |
from dash import html | |
from dash.dependencies import Output | |
from dash.dependencies import Input |