Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -112,18 +112,29 @@ if choice == 'ফাইল আপলোড (for PUBLIC use)':
|
|
| 112 |
if uploaded_file is not None:
|
| 113 |
lines = uploaded_file.read().decode('utf-8').splitlines()
|
| 114 |
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
|
| 129 |
|
|
|
|
| 112 |
if uploaded_file is not None:
|
| 113 |
lines = uploaded_file.read().decode('utf-8').splitlines()
|
| 114 |
|
| 115 |
+
# Define output file name
|
| 116 |
+
output_file_name = uploaded_file.name.split('.')[0] + '_tagged.txt'
|
| 117 |
+
|
| 118 |
+
with open(output_file_name, 'w', encoding='utf-8') as out_file:
|
| 119 |
+
for line in lines:
|
| 120 |
+
data = BasicTokenizer().tokenize(line)
|
| 121 |
+
sentence = Sentence(data)
|
| 122 |
+
model.predict(sentence)
|
| 123 |
+
|
| 124 |
+
my_list = []
|
| 125 |
+
|
| 126 |
+
for token in sentence:
|
| 127 |
+
word = (token.text, token.tag)
|
| 128 |
+
my_list.append(word)
|
| 129 |
+
|
| 130 |
+
# Write line to output file
|
| 131 |
+
tagged_line = ' '.join([f"{word}/{tag}" for word, tag in my_list])
|
| 132 |
+
out_file.write(tagged_line + '\n')
|
| 133 |
+
|
| 134 |
+
# Show annotated text
|
| 135 |
+
# annotated_text(*my_list)
|
| 136 |
+
|
| 137 |
+
btn = st.download_button(label="TXT ফাইল হিসাবে ডেটা ডাউনলোড করুন",data=out_file, file_name=output_file_name)
|
| 138 |
|
| 139 |
|
| 140 |
|