Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,38 +11,29 @@ from flair.datasets import ColumnCorpus
|
|
| 11 |
from flair.models import SequenceTagger
|
| 12 |
from flair.trainers import ModelTrainer
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
@st.cache_resource()
|
| 17 |
def load_model(model_name):
|
| 18 |
model = SequenceTagger.load(model_name)
|
| 19 |
return (model)
|
| 20 |
|
| 21 |
-
activity = ['
|
| 22 |
-
choice = st.selectbox('
|
| 23 |
#st.write('You selected:', option)
|
| 24 |
|
| 25 |
-
if choice == '
|
| 26 |
-
input_data = st.text_area("
|
| 27 |
if st.button('Process'):
|
| 28 |
-
|
| 29 |
data = BasicTokenizer().tokenize(input_data)
|
| 30 |
|
| 31 |
-
|
| 32 |
-
# for i in data:
|
| 33 |
-
# fl.write(i)
|
| 34 |
-
# fl.write('\n')
|
| 35 |
-
# fl.close()
|
| 36 |
-
|
| 37 |
-
# columns = {0: 'text'}
|
| 38 |
-
# corpus: Corpus = ColumnCorpus('bengali_pos/', columns, train_file='train.txt', test_file='test.txt', dev_file='valid.txt')
|
| 39 |
-
# '''
|
| 40 |
sentence = Sentence(data)
|
| 41 |
model = load_model('best-model-002.pt')
|
| 42 |
model.predict(sentence)
|
| 43 |
my_list = []
|
| 44 |
-
|
| 45 |
-
# st.write(sentence.to_tagged_string())
|
| 46 |
for token in sentence:
|
| 47 |
word = []
|
| 48 |
word.append(token.text)
|
|
@@ -52,23 +43,5 @@ if choice == 'Text Input':
|
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
-
|
| 56 |
-
#result_mean = model.evaluate(corpus.test, gold_label_type='pos',mini_batch_size=32, out_path=f"pred_pos.txt")
|
| 57 |
-
|
| 58 |
-
# st.write("Input Data: \n")
|
| 59 |
-
# st.write(input_data)
|
| 60 |
-
|
| 61 |
-
# file1 = open('pred_pos.txt', 'r')
|
| 62 |
-
# Lines = file1.readlines()
|
| 63 |
-
|
| 64 |
-
# my_list = []
|
| 65 |
-
# for line in Lines:
|
| 66 |
-
# word = []
|
| 67 |
-
# for j in line.split(' O '):
|
| 68 |
-
# word.append(j)
|
| 69 |
-
# my_list.append(tuple(word))
|
| 70 |
-
|
| 71 |
-
# st.write("Output Data: \n")
|
| 72 |
-
# annotated_text(my_list)
|
| 73 |
-
# file1.close()
|
| 74 |
|
|
|
|
| 11 |
from flair.models import SequenceTagger
|
| 12 |
from flair.trainers import ModelTrainer
|
| 13 |
|
| 14 |
+
|
| 15 |
|
| 16 |
@st.cache_resource()
|
| 17 |
def load_model(model_name):
|
| 18 |
model = SequenceTagger.load(model_name)
|
| 19 |
return (model)
|
| 20 |
|
| 21 |
+
activity = ['ফাইল আপলোড', 'টেক্সট ইনপুট']
|
| 22 |
+
choice = st.selectbox('আপনি কিভাবে এটি প্রক্রিয়া করতে চান?',activity)
|
| 23 |
#st.write('You selected:', option)
|
| 24 |
|
| 25 |
+
if choice == 'টেক্সট ইনপুট':
|
| 26 |
+
input_data = st.text_area("আপনার বাংলা বাক্য লিখুন", value="", height=10)
|
| 27 |
if st.button('Process'):
|
| 28 |
+
|
| 29 |
data = BasicTokenizer().tokenize(input_data)
|
| 30 |
|
| 31 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
sentence = Sentence(data)
|
| 33 |
model = load_model('best-model-002.pt')
|
| 34 |
model.predict(sentence)
|
| 35 |
my_list = []
|
| 36 |
+
|
|
|
|
| 37 |
for token in sentence:
|
| 38 |
word = []
|
| 39 |
word.append(token.text)
|
|
|
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|