atanu0491 commited on
Commit
8ca33fd
·
verified ·
1 Parent(s): 5b621e7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -12
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
- for line in lines:
116
- data = BasicTokenizer().tokenize(line)
117
- sentence = Sentence(data)
118
- model.predict(sentence)
119
- my_list = []
120
-
121
- for token in sentence:
122
- word = []
123
- word.append(token.text)
124
- word.append(token.tag)
125
- my_list.append(tuple(word))
126
- annotated_text(my_list)
 
 
 
 
 
 
 
 
 
 
 
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