diff --git a/src/mod_searchable.py b/src/mod_searchable.py index 52070d2..509f4be 100644 --- a/src/mod_searchable.py +++ b/src/mod_searchable.py @@ -10,6 +10,10 @@ tfidf_vectorizer_path = "data/tfidf_vectorizer.pckl" relevance_score_path = "data/tweet_relevance.json" tweets_path = "data/tweets_all_combined.csv" +reply_html_svg = '' +retweet_html_svg = '' +like_html_svg = '' + print("Loading data from storage") tweets = pd.read_csv(tweets_path) @@ -48,7 +52,7 @@ def search_query(query: str, limit: int = 5) -> pd.DataFrame: def searchable_ui(): return ui.div( ui.h2("Tweet Suchmaschine"), - ui.input_text("search_input", "Suche:", placeholder="Gebe Suchterm ein"), + ui.input_text("search_input", "Suche:", placeholder="Gebe Suchterm ein", value="Leipzig"), ui.HTML("
"), ui.output_ui(id="searchable_tweet_ui"), ) @@ -77,17 +81,24 @@ def searchable_server(input: Inputs, output: Outputs, session: Session): tweet_ui.append( ui.div( ui.row( - ui.column(9, ui.markdown(f"**{row['user_name']}** *@{row['handle']}*"), style=style), + ui.column(9, ui.markdown( + f"**{row['user_name']}** *@{row['handle']}*"), style=style), ui.column(3, ui.p(f"{row['created_at']}"), style=style), ), ui.row( - ui.column(12, ui.HTML(str(row["tweet_text"]).replace("\\n", "
")), style=style + "font-size: 20px; padding:1em;"), + ui.column(12, ui.HTML(str(row["tweet_text"]).replace( + "\\n", "
")), style=style + "font-size: 20px; padding:1em;"), ), ui.row( - ui.column(3, ui.p(f"👍 {row['like_count']}"), style=style), - ui.column(3, ui.p(f"⟲ {row['retweet_count']}"), style=style), - ui.column(3, ui.p(f"↪ {row['reply_count']}"), style=style), - ui.column(3, ui.p(f"💬 {row['quote_count']}"), style=style), + ui.column(3, ui.HTML(reply_html_svg), ui.p( + f"{row['reply_count']}"), style=style), + ui.column(3, ui.HTML(retweet_html_svg), ui.p( + f"{row['retweet_count']}"), style=style), + ui.column(3, ui.HTML(like_html_svg), ui.p( + f"{row['like_count']}"), style=style), + # quote_count: . Indicates approximately how many times this Tweet has been quoted by Twitter users. Example: + # TODO: use a nice svg for quote_count + ui.column(3, ui.p(f"Quote Count: {row['quote_count']}"), style=style), ), style="border: 1px solid #954; margin-bottom: 1em;")) return tweet_ui