Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,10 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
import unicodedata
|
|
|
|
|
|
|
|
|
4 |
|
5 |
def normalize(text):
|
6 |
return unicodedata.normalize('NFC', text
|
@@ -18,7 +22,7 @@ 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=200, num_beams=5, num_return_sequences=5)
|
23 |
|
24 |
texts = [
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
import unicodedata
|
4 |
+
import re
|
5 |
+
|
6 |
+
def contains_text(text):
|
7 |
+
return re.search('[A-Za-z]', text) or re.search('[א-ת]', text)
|
8 |
|
9 |
def normalize(text):
|
10 |
return unicodedata.normalize('NFC', text
|
|
|
22 |
|
23 |
if text:
|
24 |
|
25 |
+
words = [normalize(x) for x in text.split() if contains_text(x)]
|
26 |
outputs = pipe(words, max_length=200, num_beams=5, num_return_sequences=5)
|
27 |
|
28 |
texts = [
|