Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -49,6 +49,7 @@ if choice == 'টেক্সট ইনপুট':
|
|
| 49 |
|
| 50 |
|
| 51 |
|
|
|
|
| 52 |
# if choice == 'ফাইল আপলোড':
|
| 53 |
# uploaded_files = st.file_uploader("Choose a CSV file")
|
| 54 |
|
|
@@ -57,95 +58,117 @@ if choice == 'টেক্সট ইনপুট':
|
|
| 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 |
-
#
|
| 62 |
-
|
| 63 |
-
#
|
| 64 |
-
#
|
| 65 |
-
#
|
| 66 |
-
#
|
| 67 |
-
|
| 68 |
-
#
|
| 69 |
-
#
|
| 70 |
-
#
|
| 71 |
-
#
|
| 72 |
-
#
|
| 73 |
-
#
|
| 74 |
-
#
|
| 75 |
-
#
|
| 76 |
-
#
|
| 77 |
-
#
|
| 78 |
-
|
| 79 |
-
#
|
| 80 |
-
#
|
| 81 |
-
|
| 82 |
-
#
|
| 83 |
-
#
|
| 84 |
-
|
| 85 |
-
#
|
| 86 |
-
#
|
| 87 |
-
#
|
| 88 |
-
#
|
| 89 |
-
#
|
| 90 |
-
#
|
| 91 |
-
#
|
| 92 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
if choice == 'ফাইল আপলোড':
|
| 94 |
uploaded_files = st.file_uploader("Choose a CSV file")
|
| 95 |
|
| 96 |
if uploaded_files is not None:
|
| 97 |
search_word_def = uploaded_files.name.split('.')[0].split(' ')[-1]
|
| 98 |
dataframe = pd.read_excel(uploaded_files)
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
+
|
| 53 |
# if choice == 'ফাইল আপলোড':
|
| 54 |
# uploaded_files = st.file_uploader("Choose a CSV file")
|
| 55 |
|
|
|
|
| 58 |
# dataframe = pd.read_excel(uploaded_files)
|
| 59 |
# search_word = st.text_input('Any other word you want to search for', '')
|
| 60 |
# # model = load_model('best-model-002.pt')
|
| 61 |
+
# if st.button('search'):
|
| 62 |
+
# if search_word is not None:
|
| 63 |
+
# for index, row in dataframe.iterrows():
|
| 64 |
+
# if pd.notnull(row['Unnamed: 2']):
|
| 65 |
+
# data = BasicTokenizer().tokenize(row['Unnamed: 2'])
|
| 66 |
+
# sentence = Sentence(data)
|
| 67 |
+
# model.predict(sentence)
|
| 68 |
+
|
| 69 |
+
# search_w_d = []
|
| 70 |
+
# search_w = []
|
| 71 |
+
# my_list = []
|
| 72 |
+
# for token in sentence:
|
| 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 |
+
# if token.text == search_word_def:
|
| 79 |
+
# w_d = []
|
| 80 |
+
# w_d.append(token.text)
|
| 81 |
+
# w_d.append(token.tag)
|
| 82 |
+
# search_w_d.append("/".join(tuple(w_d)))
|
| 83 |
+
# word = []
|
| 84 |
+
# word.append(token.text)
|
| 85 |
+
# word.append(token.tag)
|
| 86 |
+
# my_list.append("/".join(tuple(word)))
|
| 87 |
+
# st.write(" ".join(my_list))
|
| 88 |
+
# st.write(" ".join(search_w_d))
|
| 89 |
+
# st.write(" ".join(search_w))
|
| 90 |
+
# else:
|
| 91 |
+
# for index, row in dataframe.iterrows():
|
| 92 |
+
# if pd.notnull(row['Unnamed: 2']):
|
| 93 |
+
# data = BasicTokenizer().tokenize(row['Unnamed: 2'])
|
| 94 |
+
# sentence = Sentence(data)
|
| 95 |
+
# model.predict(sentence)
|
| 96 |
+
|
| 97 |
+
# search_w_d = []
|
| 98 |
+
|
| 99 |
+
# my_list = []
|
| 100 |
+
# for token in sentence:
|
| 101 |
+
# if token.text == search_word_def:
|
| 102 |
+
# w_d = []
|
| 103 |
+
# w_d.append(token.text)
|
| 104 |
+
# w_d.append(token.tag)
|
| 105 |
+
# search_w_d.append("/".join(tuple(w_d)))
|
| 106 |
+
# word = []
|
| 107 |
+
# word.append(token.text)
|
| 108 |
+
# word.append(token.tag)
|
| 109 |
+
# my_list.append("/".join(tuple(word)))
|
| 110 |
+
# st.write(" ".join(my_list))
|
| 111 |
+
# st.write(" ".join(search_w_d))
|
| 112 |
if choice == 'ফাইল আপলোড':
|
| 113 |
uploaded_files = st.file_uploader("Choose a CSV file")
|
| 114 |
|
| 115 |
if uploaded_files is not None:
|
| 116 |
search_word_def = uploaded_files.name.split('.')[0].split(' ')[-1]
|
| 117 |
dataframe = pd.read_excel(uploaded_files)
|
| 118 |
+
choice_new = st.selectbox('আপনি কিভাবে এটি প্রক্রিয়া করতে চান?',['Select', 'Yes', 'No'])
|
| 119 |
+
if choice_new == 'Yes':
|
| 120 |
+
search_word = st.text_input('Any other word you want to search for', '')
|
| 121 |
+
# model = load_model('best-model-002.pt')
|
| 122 |
+
if st.button('search'):
|
| 123 |
+
if search_word is not None:
|
| 124 |
+
for index, row in dataframe.iterrows():
|
| 125 |
+
if pd.notnull(row['Unnamed: 2']):
|
| 126 |
+
data = BasicTokenizer().tokenize(row['Unnamed: 2'])
|
| 127 |
+
sentence = Sentence(data)
|
| 128 |
+
model.predict(sentence)
|
| 129 |
+
|
| 130 |
+
search_w_d = []
|
| 131 |
+
search_w = []
|
| 132 |
+
my_list = []
|
| 133 |
+
for token in sentence:
|
| 134 |
+
if token.text == search_word:
|
| 135 |
+
w = []
|
| 136 |
+
w.append(token.text)
|
| 137 |
+
w.append(token.tag)
|
| 138 |
+
search_w.append("/".join(tuple(w)))
|
| 139 |
+
if token.text == search_word_def:
|
| 140 |
+
w_d = []
|
| 141 |
+
w_d.append(token.text)
|
| 142 |
+
w_d.append(token.tag)
|
| 143 |
+
search_w_d.append("/".join(tuple(w_d)))
|
| 144 |
+
word = []
|
| 145 |
+
word.append(token.text)
|
| 146 |
+
word.append(token.tag)
|
| 147 |
+
my_list.append("/".join(tuple(word)))
|
| 148 |
+
st.write(" ".join(my_list))
|
| 149 |
+
st.write(" ".join(search_w_d))
|
| 150 |
+
st.write(" ".join(search_w))
|
| 151 |
+
else:
|
| 152 |
+
st.error('Please enter words', icon="🚨")
|
| 153 |
+
if choice_new == 'No':
|
| 154 |
+
for index, row in dataframe.iterrows():
|
| 155 |
+
if pd.notnull(row['Unnamed: 2']):
|
| 156 |
+
data = BasicTokenizer().tokenize(row['Unnamed: 2'])
|
| 157 |
+
sentence = Sentence(data)
|
| 158 |
+
model.predict(sentence)
|
| 159 |
+
|
| 160 |
+
search_w_d = []
|
| 161 |
+
|
| 162 |
+
my_list = []
|
| 163 |
+
for token in sentence:
|
| 164 |
+
if token.text == search_word_def:
|
| 165 |
+
w_d = []
|
| 166 |
+
w_d.append(token.text)
|
| 167 |
+
w_d.append(token.tag)
|
| 168 |
+
search_w_d.append("/".join(tuple(w_d)))
|
| 169 |
+
word = []
|
| 170 |
+
word.append(token.text)
|
| 171 |
+
word.append(token.tag)
|
| 172 |
+
my_list.append("/".join(tuple(word)))
|
| 173 |
+
st.write(" ".join(my_list))
|
| 174 |
+
st.write(" ".join(search_w_d))
|