Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,13 +3,13 @@ from annotated_text import annotated_text
|
|
| 3 |
|
| 4 |
import warnings
|
| 5 |
import pandas as pd
|
| 6 |
-
|
| 7 |
warnings.filterwarnings('ignore')
|
| 8 |
import re, flair, random, time
|
| 9 |
from bnlp import BasicTokenizer
|
| 10 |
from flair.data import Corpus, Sentence
|
| 11 |
from flair.datasets import ColumnCorpus
|
| 12 |
-
|
| 13 |
from flair.models import SequenceTagger
|
| 14 |
from flair.trainers import ModelTrainer
|
| 15 |
|
|
@@ -55,35 +55,40 @@ if choice == 'ফাইল আপলোড':
|
|
| 55 |
if uploaded_files is not None:
|
| 56 |
search_word_def = uploaded_files.name.split('.')[0].split(' ')[-1]
|
| 57 |
dataframe = pd.read_excel(uploaded_files)
|
|
|
|
| 58 |
# model = load_model('best-model-002.pt')
|
| 59 |
-
|
| 60 |
for index, row in dataframe.iterrows():
|
| 61 |
-
|
| 62 |
-
# st.write(row['Unnamed: 2'])
|
| 63 |
if pd.notnull(row['Unnamed: 2']):
|
| 64 |
data = BasicTokenizer().tokenize(row['Unnamed: 2'])
|
| 65 |
sentence = Sentence(data)
|
| 66 |
model.predict(sentence)
|
| 67 |
|
| 68 |
-
|
| 69 |
search_w = []
|
| 70 |
my_list = []
|
| 71 |
for token in sentence:
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
if token.text == search_word_def:
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
search_w.append("/".join(tuple(w)))
|
| 82 |
word = []
|
| 83 |
word.append(token.text)
|
| 84 |
word.append(token.tag)
|
| 85 |
my_list.append("/".join(tuple(word)))
|
| 86 |
st.write(" ".join(my_list))
|
|
|
|
| 87 |
st.write(" ".join(search_w))
|
| 88 |
|
| 89 |
|
|
|
|
| 3 |
|
| 4 |
import warnings
|
| 5 |
import pandas as pd
|
| 6 |
+
|
| 7 |
warnings.filterwarnings('ignore')
|
| 8 |
import re, flair, random, time
|
| 9 |
from bnlp import BasicTokenizer
|
| 10 |
from flair.data import Corpus, Sentence
|
| 11 |
from flair.datasets import ColumnCorpus
|
| 12 |
+
|
| 13 |
from flair.models import SequenceTagger
|
| 14 |
from flair.trainers import ModelTrainer
|
| 15 |
|
|
|
|
| 55 |
if uploaded_files is not None:
|
| 56 |
search_word_def = uploaded_files.name.split('.')[0].split(' ')[-1]
|
| 57 |
dataframe = pd.read_excel(uploaded_files)
|
| 58 |
+
search_word = = st.text_input('Any other word you want to search for', '')
|
| 59 |
# model = load_model('best-model-002.pt')
|
| 60 |
+
|
| 61 |
for index, row in dataframe.iterrows():
|
| 62 |
+
|
|
|
|
| 63 |
if pd.notnull(row['Unnamed: 2']):
|
| 64 |
data = BasicTokenizer().tokenize(row['Unnamed: 2'])
|
| 65 |
sentence = Sentence(data)
|
| 66 |
model.predict(sentence)
|
| 67 |
|
| 68 |
+
search_w_d = []
|
| 69 |
search_w = []
|
| 70 |
my_list = []
|
| 71 |
for token in sentence:
|
| 72 |
+
if search_word is not None:
|
| 73 |
+
if token.text == search_word:
|
| 74 |
+
w = []
|
| 75 |
+
w.append(token.text)
|
| 76 |
+
w.append(token.tag)
|
| 77 |
+
search_w.append("/".join(tuple(w)))
|
| 78 |
+
|
| 79 |
if token.text == search_word_def:
|
| 80 |
+
w_d = []
|
| 81 |
+
|
| 82 |
+
w_d.append(token.text)
|
| 83 |
+
w_d.append(token.tag)
|
| 84 |
+
|
| 85 |
+
search_w_d.append("/".join(tuple(w_d)))
|
|
|
|
| 86 |
word = []
|
| 87 |
word.append(token.text)
|
| 88 |
word.append(token.tag)
|
| 89 |
my_list.append("/".join(tuple(word)))
|
| 90 |
st.write(" ".join(my_list))
|
| 91 |
+
st.write(" ".join(search_w_d))
|
| 92 |
st.write(" ".join(search_w))
|
| 93 |
|
| 94 |
|