Fixed bugs.
Browse files
app.py
CHANGED
@@ -157,54 +157,18 @@ def predict(tweet):
|
|
157 |
|
158 |
return prediction
|
159 |
|
|
|
|
|
160 |
|
161 |
-
|
162 |
-
|
163 |
-
# # fuzzy_text, matches = fuzzy_lookup(tweet)
|
164 |
-
# # processed_text = preprocess(fuzzy_text)
|
165 |
-
# # output = query(processed_text)
|
166 |
-
|
167 |
-
|
168 |
-
# # if 'error' in output:
|
169 |
-
# # return output['error'], 'Error occured. Try again later.', {}
|
170 |
-
# # elif len(matches) == 0:
|
171 |
-
# # return 'No Profanity Found.', '', {}
|
172 |
-
# # else:
|
173 |
-
# # output = [tuple(i.values()) for i in output[0]]
|
174 |
-
# # output = dict((x, y) for x, y in output)
|
175 |
-
# # predicted_label = list(output.keys())[0]
|
176 |
-
|
177 |
-
# # if predicted_label == 'Abusive':
|
178 |
-
# # # Censor
|
179 |
-
# # for base_word, _ in matches.items():
|
180 |
-
# # mask = '*' * len(base_word)
|
181 |
-
# # compiled = re.compile(re.escape(base_word), re.IGNORECASE)
|
182 |
-
# # tweet = compiled.sub(mask, tweet)
|
183 |
-
# # # tweet = tweet.replace(base_word, re.sub("[a-zA-Z0-9@]", "*", base_word))
|
184 |
-
# # return output, tweet, json.dumps(matches)
|
185 |
-
# # else:
|
186 |
-
# # return output, tweet, json.dumps(matches)
|
187 |
-
|
188 |
-
# # # output, tweet, matches = predict('ul0L Sama ng ugali mo pre Tangina uL0l!!!')
|
189 |
-
# # # print(output, '\n', tweet, '\n', matches)
|
190 |
-
|
191 |
-
# # hf_writer = gr.HuggingFaceDatasetSaver('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', 'tagalog-profanity-feedbacks')
|
192 |
-
|
193 |
-
|
194 |
-
# demo = gr.Interface(
|
195 |
-
# fn=predict,
|
196 |
-
|
197 |
-
# inputs=[gr.components.Textbox(lines=5, placeholder='Enter your input here', label='INPUT')],
|
198 |
-
|
199 |
-
# outputs=[gr.components.Label(num_top_classes=2, label="PREDICTION")],
|
200 |
|
201 |
-
|
202 |
-
# 'Napakainit ngayong araw pakshet namaaan!!',
|
203 |
-
# 'Napakabagal naman ng wifi tangina #PLDC #HelloDITO',
|
204 |
-
# 'Bobo ka ba? napakadali lang nyan eh... ๐คก',
|
205 |
-
# 'Uy gago laptrip yung nangyare samen kanina HAHAHA๐๐'],
|
206 |
-
# )
|
207 |
|
208 |
-
|
|
|
|
|
|
|
|
|
|
|
209 |
|
210 |
-
|
|
|
157 |
|
158 |
return prediction
|
159 |
|
160 |
+
demo = gr.Interface(
|
161 |
+
fn=predict,
|
162 |
|
163 |
+
inputs=[gr.components.Textbox(lines=5, placeholder='Enter your input here', label='INPUT')],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
|
165 |
+
outputs=[gr.components.Label(num_top_classes=2, label="PREDICTION")],
|
|
|
|
|
|
|
|
|
|
|
166 |
|
167 |
+
examples=['Tangina mo naman sobrang yabang mo gago!!๐ ๐ค @davidrafael',
|
168 |
+
'Napakainit ngayong araw pakshet namaaan!!',
|
169 |
+
'Napakabagal naman ng wifi tangina #PLDC #HelloDITO',
|
170 |
+
'Bobo ka ba? napakadali lang nyan eh... ๐คก',
|
171 |
+
'Uy gago laptrip yung nangyare samen kanina HAHAHA๐๐'],
|
172 |
+
)
|
173 |
|
174 |
+
demo.launch()
|