Update app.py
Browse files
app.py
CHANGED
|
@@ -11,14 +11,14 @@ inf_model = SetFitModel.from_pretrained("MYox/NSS_multi-label_8_sent_v3_1")
|
|
| 11 |
features = (['Teaching & learning', 'Support', 'Communication', 'Organisation & timetable',
|
| 12 |
'Assessment & feedback', 'Career & placement', 'Health, well-being & social life', 'Facilities & technology'])
|
| 13 |
|
| 14 |
-
def
|
| 15 |
t = inf_model(d)
|
| 16 |
return [f for i, f in enumerate(features) if t[0][i]]
|
| 17 |
|
| 18 |
-
def
|
| 19 |
sent_topics = []
|
| 20 |
for s in sent_tokenize(comment):
|
| 21 |
-
sent_topics.append(
|
| 22 |
|
| 23 |
output = []
|
| 24 |
for x in sent_topics:
|
|
@@ -29,7 +29,7 @@ def get_comment_topics_old(comment):
|
|
| 29 |
|
| 30 |
app = gr.Interface(
|
| 31 |
title='NSS Topic Generator',
|
| 32 |
-
fn=
|
| 33 |
inputs=gr.Textbox(lines=4, placeholder='Type comment here or choose example, below', label='Comment'),
|
| 34 |
outputs=gr.Textbox(lines=4, label='Generated Topics'),
|
| 35 |
allow_flagging='never',
|
|
|
|
| 11 |
features = (['Teaching & learning', 'Support', 'Communication', 'Organisation & timetable',
|
| 12 |
'Assessment & feedback', 'Career & placement', 'Health, well-being & social life', 'Facilities & technology'])
|
| 13 |
|
| 14 |
+
def get_doc_topics(d):
|
| 15 |
t = inf_model(d)
|
| 16 |
return [f for i, f in enumerate(features) if t[0][i]]
|
| 17 |
|
| 18 |
+
def get_comment_topics(comment):
|
| 19 |
sent_topics = []
|
| 20 |
for s in sent_tokenize(comment):
|
| 21 |
+
sent_topics.append(get_doc_topics([s]))
|
| 22 |
|
| 23 |
output = []
|
| 24 |
for x in sent_topics:
|
|
|
|
| 29 |
|
| 30 |
app = gr.Interface(
|
| 31 |
title='NSS Topic Generator',
|
| 32 |
+
fn=get_comment_topics,
|
| 33 |
inputs=gr.Textbox(lines=4, placeholder='Type comment here or choose example, below', label='Comment'),
|
| 34 |
outputs=gr.Textbox(lines=4, label='Generated Topics'),
|
| 35 |
allow_flagging='never',
|