multiword
Browse files
app.py
CHANGED
|
@@ -1,5 +1,13 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
with st.spinner('Loading TaatikNet framework...'):
|
| 5 |
pipe = pipeline("text2text-generation", model='malper/taatiknet', device_map="auto")
|
|
@@ -9,5 +17,8 @@ st.success('Loaded!')
|
|
| 9 |
text = st.text_area('Enter text and press ctrl/command+enter:')
|
| 10 |
|
| 11 |
if text:
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
+
import unicodedata
|
| 4 |
+
|
| 5 |
+
def normalize(text):
|
| 6 |
+
return unicodedata.normalize('NFC', text
|
| 7 |
+
).replace('\u05ba', '\u05b9'
|
| 8 |
+
).replace('\u05be', '-'
|
| 9 |
+
).replace('״', '"'
|
| 10 |
+
).replace("׳", "'")
|
| 11 |
|
| 12 |
with st.spinner('Loading TaatikNet framework...'):
|
| 13 |
pipe = pipeline("text2text-generation", model='malper/taatiknet', device_map="auto")
|
|
|
|
| 17 |
text = st.text_area('Enter text and press ctrl/command+enter:')
|
| 18 |
|
| 19 |
if text:
|
| 20 |
+
|
| 21 |
+
words = [normalize(x) for x in text.split()]
|
| 22 |
+
outputs = pipe(words, max_length=40)
|
| 23 |
+
output_text = ' '.join([x['generated_text'] for x in outputs])
|
| 24 |
+
st.write(output_text)
|