Qifan Zhang
commited on
Commit
·
4347f00
1
Parent(s):
8920952
update
Browse files
app.py
CHANGED
@@ -23,31 +23,31 @@ def process(task_name: str,
|
|
23 |
text: str,
|
24 |
file=None,
|
25 |
):
|
26 |
-
try:
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
except Exception as e:
|
50 |
-
|
51 |
|
52 |
|
53 |
# input
|
|
|
23 |
text: str,
|
24 |
file=None,
|
25 |
):
|
26 |
+
# try:
|
27 |
+
# load file
|
28 |
+
if file:
|
29 |
+
df = read_data(file.name)
|
30 |
+
elif text:
|
31 |
+
string_io = StringIO(text)
|
32 |
+
df = pd.read_csv(string_io)
|
33 |
+
assert len(df) >= 1, 'No input data'
|
34 |
+
else:
|
35 |
+
raise Exception('No input data')
|
36 |
+
|
37 |
+
# process
|
38 |
+
if task_name == 'Originality':
|
39 |
+
df = pipeline.p0_originality(df, model_name)
|
40 |
+
elif task_name == 'Flexibility':
|
41 |
+
df = pipeline.p1_flexibility(df, model_name)
|
42 |
+
else:
|
43 |
+
raise Exception('Task not supported')
|
44 |
+
|
45 |
+
# save
|
46 |
+
path = 'output.csv'
|
47 |
+
df.to_csv(path, index=False, encoding='utf-8-sig')
|
48 |
+
return None, df.iloc[:10], path
|
49 |
+
# except Exception as e:
|
50 |
+
# return {'Error': e}, None, None
|
51 |
|
52 |
|
53 |
# input
|