Spaces:
Runtime error
Runtime error
hf-dongpyo
commited on
Commit
·
d2827b6
1
Parent(s):
012dca9
Update app.py
Browse files
app.py
CHANGED
@@ -66,6 +66,16 @@ def text2text_acceptable_sentence(text):
|
|
66 |
|
67 |
return response
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
# question
|
70 |
# context = grad.Textbox(lines = 10, label = 'English', placeholder = 'Context')
|
71 |
# ans = grad.Textbox(lines = 1, label = 'Answer')
|
@@ -80,12 +90,17 @@ def text2text_acceptable_sentence(text):
|
|
80 |
# out = grad.Textbox(lines = 1, label = 'German Translation')
|
81 |
|
82 |
# sentiment
|
83 |
-
para = grad.Textbox(lines = 1, label = 'English Text', placeholder = 'Text in English')
|
84 |
-
out = grad.Textbox(lines = 1, label = 'Sentiment')
|
|
|
|
|
|
|
|
|
85 |
|
86 |
-
#
|
87 |
-
|
88 |
-
|
|
|
89 |
|
90 |
grad.Interface(
|
91 |
# text2text,
|
@@ -93,7 +108,9 @@ grad.Interface(
|
|
93 |
# text2text_summary,
|
94 |
# text2text_translate,
|
95 |
# text2text_sentiment,
|
96 |
-
text2text_acceptable_sentence,
|
97 |
-
|
|
|
|
|
98 |
outputs = out
|
99 |
).launch()
|
|
|
66 |
|
67 |
return response
|
68 |
|
69 |
+
def text2text_paraphrase(sentence1, sentence2):
|
70 |
+
inp1 = "mrpc sentence1: " + sentence1
|
71 |
+
inp2 = "sentence2: " + sentence2
|
72 |
+
combined_inp = inp1 + " " + inp2
|
73 |
+
enc = text2text_tkn(combined_inp, return_tensors = 'pt')
|
74 |
+
tokens = mdl.generate(**enc)
|
75 |
+
response = text2text_tkn.batch_decode(tokens)
|
76 |
+
|
77 |
+
return response
|
78 |
+
|
79 |
# question
|
80 |
# context = grad.Textbox(lines = 10, label = 'English', placeholder = 'Context')
|
81 |
# ans = grad.Textbox(lines = 1, label = 'Answer')
|
|
|
90 |
# out = grad.Textbox(lines = 1, label = 'German Translation')
|
91 |
|
92 |
# sentiment
|
93 |
+
# para = grad.Textbox(lines = 1, label = 'English Text', placeholder = 'Text in English')
|
94 |
+
# out = grad.Textbox(lines = 1, label = 'Sentiment')
|
95 |
+
|
96 |
+
# # grammatical acceptance
|
97 |
+
# para = grad.Textbox(lines = 1, label = 'English Text', placeholder = 'Text in English')
|
98 |
+
# out = grad.Textbox(lines = 1, label = 'Whether the sentence is acceptable or not')
|
99 |
|
100 |
+
# paraphrase
|
101 |
+
sent1 = grad.Textbox(lines = 1, label = 'Sentence1', placeholder = 'Text in English')
|
102 |
+
sent2 = grad.Textbox(lines = 1, label = 'Sentence2', placeholder = 'Text in English')
|
103 |
+
out = grad.Textbox(lines = 1, label = 'Paraphrase')
|
104 |
|
105 |
grad.Interface(
|
106 |
# text2text,
|
|
|
108 |
# text2text_summary,
|
109 |
# text2text_translate,
|
110 |
# text2text_sentiment,
|
111 |
+
# text2text_acceptable_sentence,
|
112 |
+
text2text_paraphrase,
|
113 |
+
# inputs = para,
|
114 |
+
inputs = [sent1, sent2],
|
115 |
outputs = out
|
116 |
).launch()
|