Spaces:
Sleeping
Sleeping
update upload function
Browse files
app.py
CHANGED
@@ -29,17 +29,20 @@ def prediction(news):
|
|
29 |
|
30 |
def file_prediction(file):
|
31 |
if file.name.endswith('.csv'):
|
32 |
-
df = pd.read_csv(file)
|
33 |
-
news_list = df.iloc[:, 0].tolist()
|
34 |
else:
|
35 |
-
file.seek(0)
|
36 |
-
|
|
|
37 |
|
38 |
results = []
|
39 |
for news in news_list:
|
40 |
-
|
|
|
41 |
|
42 |
-
return results
|
|
|
43 |
|
44 |
|
45 |
gradio_ui = gr.Interface(
|
|
|
29 |
|
30 |
def file_prediction(file):
|
31 |
if file.name.endswith('.csv'):
|
32 |
+
df = pd.read_csv(file)
|
33 |
+
news_list = df.iloc[:, 0].tolist()
|
34 |
else:
|
35 |
+
file.seek(0)
|
36 |
+
file_content = file.read().decode('utf-8')
|
37 |
+
news_list = file_content.splitlines()
|
38 |
|
39 |
results = []
|
40 |
for news in news_list:
|
41 |
+
if news.strip():
|
42 |
+
results.append(prediction(news))
|
43 |
|
44 |
+
return pd.DataFrame(results, index=news_list)
|
45 |
+
|
46 |
|
47 |
|
48 |
gradio_ui = gr.Interface(
|