Spaces:
Runtime error
Runtime error
fixed more things in the website
Browse files
app.py
CHANGED
@@ -1,11 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
from textclassifier import TextClassifier as tc
|
|
|
3 |
from functions import functions as f
|
4 |
import time
|
5 |
|
6 |
USER_LIST = ['jimmieakesson', 'BuschEbba', 'annieloof', 'JohanPehrson', 'bolund', 'martastenevi', 'SwedishPM',
|
7 |
'dadgostarnooshi']
|
8 |
|
|
|
9 |
def get_summary_statistics(dataframe):
|
10 |
"""
|
11 |
This function returns a summary statistics of the dataframe. Returns a string with the summary statistics.
|
@@ -39,11 +41,16 @@ def summary_categorical(dataframe):
|
|
39 |
return "Summary of categorical variables:\n" + summary
|
40 |
|
41 |
|
|
|
|
|
|
|
|
|
|
|
42 |
def main(From,
|
43 |
To,
|
44 |
Username,
|
45 |
Nbr_Of_Tweets_To_Classify,
|
46 |
-
|
47 |
"""
|
48 |
Main function. Runs the program.
|
49 |
:return: None
|
@@ -57,17 +64,27 @@ def main(From,
|
|
57 |
|
58 |
text_classifier.run_main_pipeline()
|
59 |
dataframe = text_classifier.get_dataframe()
|
60 |
-
return dataframe, get_summary_statistics(dataframe), dataframe.sort_values(by=['nlikes'], ascending=False)
|
61 |
|
62 |
-
|
63 |
-
from datetime import date
|
64 |
|
65 |
|
|
|
|
|
66 |
|
67 |
demo = gr.Interface(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
fn=main,
|
69 |
-
inputs=['text', 'text', 'text', 'text'
|
70 |
-
outputs=["dataframe", "
|
71 |
)
|
72 |
demo.launch()
|
73 |
|
|
|
1 |
import gradio as gr
|
2 |
from textclassifier import TextClassifier as tc
|
3 |
+
import pandas as pd
|
4 |
from functions import functions as f
|
5 |
import time
|
6 |
|
7 |
USER_LIST = ['jimmieakesson', 'BuschEbba', 'annieloof', 'JohanPehrson', 'bolund', 'martastenevi', 'SwedishPM',
|
8 |
'dadgostarnooshi']
|
9 |
|
10 |
+
|
11 |
def get_summary_statistics(dataframe):
|
12 |
"""
|
13 |
This function returns a summary statistics of the dataframe. Returns a string with the summary statistics.
|
|
|
41 |
return "Summary of categorical variables:\n" + summary
|
42 |
|
43 |
|
44 |
+
def show_all_stats(dataframe):
|
45 |
+
dataframe = pd.read_csv("{}/data/twitterdata.csv".format(tc.ROOT_PATH))
|
46 |
+
return dataframe
|
47 |
+
|
48 |
+
|
49 |
def main(From,
|
50 |
To,
|
51 |
Username,
|
52 |
Nbr_Of_Tweets_To_Classify,
|
53 |
+
):
|
54 |
"""
|
55 |
Main function. Runs the program.
|
56 |
:return: None
|
|
|
64 |
|
65 |
text_classifier.run_main_pipeline()
|
66 |
dataframe = text_classifier.get_dataframe()
|
|
|
67 |
|
68 |
+
return dataframe, show_all_stats(dataframe)
|
|
|
69 |
|
70 |
|
71 |
+
if __name__ == "__main__":
|
72 |
+
from datetime import date
|
73 |
|
74 |
demo = gr.Interface(
|
75 |
+
article="From = The date from which you want to start the analysis.\n To = The date to which you want to end "
|
76 |
+
"the analysis.\n Username = The username of the user you want to analyze.\n Nbr_Of_Tweets_To_Classify "
|
77 |
+
"= The number of tweets you want to analyze.\n output 0: The summary statistics of the intervall you "
|
78 |
+
"selected.\n output 1: The summary statistics of the total database.\n",
|
79 |
+
thumbnail="https://www.google.com/search?q=softhouse&rlz=1C5CHFA_enSE936SE936&sxsrf"
|
80 |
+
"=ALiCzsadmCqCzwzt1COrGZxMGr8TfYzQdg:1658837053147&source=lnms&tbm=isch&sa=X&ved"
|
81 |
+
"=2ahUKEwiF36vKwZb5AhX6YPEDHbLJCRYQ_AUoAXoECAIQAw&biw=2560&bih=1274&dpr=1#imgrc=TA2JaVySjUQVsM",
|
82 |
+
analytics_enabled=True,
|
83 |
+
theme="default",
|
84 |
+
title="Twitter data analysis",
|
85 |
fn=main,
|
86 |
+
inputs=['text', 'text', 'text', 'text'],
|
87 |
+
outputs=["dataframe", "dataframe"]
|
88 |
)
|
89 |
demo.launch()
|
90 |
|