Spaces:
Sleeping
Sleeping
Update pos_tagger.py
Browse files- pos_tagger.py +22 -21
pos_tagger.py
CHANGED
@@ -13,10 +13,10 @@ def tag_pos(text, detailed_output):
|
|
13 |
|
14 |
if detailed_output:
|
15 |
# Generate detailed information with tag values and probabilities
|
16 |
-
output =
|
17 |
for label in sentence.get_labels('pos'):
|
18 |
-
output
|
19 |
-
|
20 |
else:
|
21 |
# Return a simple tagged string
|
22 |
return sentence.to_tagged_string()
|
@@ -25,9 +25,7 @@ def write():
|
|
25 |
st.markdown("# Part-of-Speech Tagging for Hamshetsnag")
|
26 |
st.sidebar.header("POS Tagging")
|
27 |
|
28 |
-
st.write(
|
29 |
-
'''Detect parts of speech in Hamshetsnag text using the fine-tuned model.'''
|
30 |
-
)
|
31 |
|
32 |
# Sidebar for configurations
|
33 |
st.sidebar.subheader("Configurable Parameters")
|
@@ -39,24 +37,27 @@ def write():
|
|
39 |
help="If checked, output shows detailed tag information (probability scores, etc.).",
|
40 |
)
|
41 |
|
42 |
-
#
|
43 |
-
input_text = st.text_area(label='Enter a text:', height=100, value="Put example text here.")
|
44 |
-
|
45 |
-
# Provide example sentences with translations
|
46 |
example_sentences = [
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
]
|
51 |
|
52 |
st.write("## Example Sentences:")
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
with st.spinner('Processing...'):
|
60 |
-
# Tag the input text and format output as per settings
|
61 |
output = tag_pos(input_text, detailed_output)
|
62 |
st.success(output)
|
|
|
|
13 |
|
14 |
if detailed_output:
|
15 |
# Generate detailed information with tag values and probabilities
|
16 |
+
output = []
|
17 |
for label in sentence.get_labels('pos'):
|
18 |
+
output.append(f"{label.text}: {label.value} ({label.score:.2f})")
|
19 |
+
return " ".join(output)
|
20 |
else:
|
21 |
# Return a simple tagged string
|
22 |
return sentence.to_tagged_string()
|
|
|
25 |
st.markdown("# Part-of-Speech Tagging for Hamshetsnag")
|
26 |
st.sidebar.header("POS Tagging")
|
27 |
|
28 |
+
st.write("Detect parts of speech in Hamshetsnag text using the fine-tuned model.")
|
|
|
|
|
29 |
|
30 |
# Sidebar for configurations
|
31 |
st.sidebar.subheader("Configurable Parameters")
|
|
|
37 |
help="If checked, output shows detailed tag information (probability scores, etc.).",
|
38 |
)
|
39 |
|
40 |
+
# Example Sentences and Translations
|
|
|
|
|
|
|
41 |
example_sentences = [
|
42 |
+
("tuute acertsetser topoldetser.", "Kâğıdı büzüştürdün attın. Oldu mu?"),
|
43 |
+
("Baran u Baden teran.", "Baran ve Bade koştu."),
|
44 |
+
("Onurun ennush nu İremin terchushe intzi shad kızdırmısh aaav.", "Onur'un düşüşü ve İrem'in koşuşu beni kızdırdı."),
|
45 |
+
]
|
46 |
|
47 |
st.write("## Example Sentences:")
|
48 |
+
|
49 |
+
for hamshetsnag, turkish in example_sentences:
|
50 |
+
if st.button(f"Use: {hamshetsnag}", key=hamshetsnag):
|
51 |
+
st.session_state['input_text'] = hamshetsnag # Update input text in session state
|
52 |
+
break # Stop checking further examples once one is used
|
53 |
+
|
54 |
+
st.write(f"(TR: {turkish})") # Show the translation as a comment, but not clickable
|
55 |
+
|
56 |
+
# Input text area, pre-populated with current input text if available
|
57 |
+
input_text = st.text_area("Enter a text:", height=100, value=st.session_state.get('input_text', 'Put example text here.'))
|
58 |
+
|
59 |
+
if st.button("Tag POS", key="tag_pos"):
|
60 |
with st.spinner('Processing...'):
|
|
|
61 |
output = tag_pos(input_text, detailed_output)
|
62 |
st.success(output)
|
63 |
+
|