Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,145 +1,30 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
-
from
|
3 |
-
from
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
"
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
unsafe_allow_html=True,
|
31 |
-
)
|
32 |
-
|
33 |
-
st.write("#")
|
34 |
-
|
35 |
-
col = st.columns(2)
|
36 |
-
|
37 |
-
# Include an image/logo for branding
|
38 |
-
col[0].image("images/cauldron.jpg", width=100)
|
39 |
-
|
40 |
-
st.markdown(
|
41 |
-
"""
|
42 |
-
<h3 style="text-align:left;">A POS Tagging Tool for the Hamshetsnag Language</h3>
|
43 |
-
""", unsafe_allow_html=True,
|
44 |
-
)
|
45 |
-
|
46 |
-
st.markdown(
|
47 |
-
"""
|
48 |
-
**Features:**
|
49 |
-
|
50 |
-
- Tags parts of speech in Hamshetsnag text.
|
51 |
-
- Utilizes a fine-tuned model specifically for this language.
|
52 |
-
- Configurable parameters for customizing tagging behavior.
|
53 |
-
|
54 |
-
Refer to the [paper](http://kelesonur.github.io/folder/hms_abstract.pdf) for more details.
|
55 |
-
|
56 |
-
### Citation:
|
57 |
-
```bibtex
|
58 |
-
@inproceedings{keles2024hamshetsnag,
|
59 |
-
title={Transfer Learning to the Rescue! Cross-Lingual Transfer for POS Tagging in an Endangered Language: Hamshetsnag},
|
60 |
-
author={Onur Keleş and Baran Günay},
|
61 |
-
booktitle={Turkey Computational Social Science Conference},
|
62 |
-
year={2024},
|
63 |
-
address={Koç University: Istanbul, Turkey}
|
64 |
-
}
|
65 |
-
```
|
66 |
-
"""
|
67 |
-
)
|
68 |
-
|
69 |
-
st.markdown(
|
70 |
-
"""
|
71 |
-
<p style="text-align:right;"><em>Please use this tool responsibly and double-check all outputs.</em></p>
|
72 |
-
""",
|
73 |
-
unsafe_allow_html=True,
|
74 |
-
)
|
75 |
-
|
76 |
-
def pos_tagging_page():
|
77 |
-
"""Displays the POS tagging page content."""
|
78 |
-
st.markdown("# Part-of-Speech Tagging for Hamshetsnag")
|
79 |
-
st.sidebar.header("POS Tagging")
|
80 |
-
|
81 |
-
st.write(
|
82 |
-
'''Detect parts of speech in Hamshetsnag text using the fine-tuned model.'''
|
83 |
-
)
|
84 |
-
|
85 |
-
# Sidebar for configurations
|
86 |
-
st.sidebar.subheader("Configurable Parameters")
|
87 |
-
|
88 |
-
# Detailed Output Checkbox
|
89 |
-
detailed_output = st.sidebar.checkbox(
|
90 |
-
"Detailed Output",
|
91 |
-
value=False,
|
92 |
-
help="If checked, output shows detailed tag information (probability scores, etc.).",
|
93 |
-
)
|
94 |
-
|
95 |
-
# Input field for text
|
96 |
-
input_text = st.text_area(label='Enter a text: ', height=100, value="Put example text here.")
|
97 |
-
|
98 |
-
# Provide example sentences with translations
|
99 |
-
example_sentences = [
|
100 |
-
"tuute acertsetser topoldetser. aaav ta? (TR: Kâğıdı büzüştürdün attın. Oldu mu?)",
|
101 |
-
"Baran u Baden teran. (TR: Baran ve Bade koştu.)",
|
102 |
-
"Onurun ennush nu İremin terchushe intzi shad kızdırmısh aaav. (TR: Onur'un düşüşü ve İrem'in koşuşu beni kızdırdı.)"
|
103 |
-
]
|
104 |
-
|
105 |
-
st.write("## Example Sentences:")
|
106 |
-
for example in example_sentences:
|
107 |
-
if st.button(f"Use: {example.split('(TR:')[0].strip()}"):
|
108 |
-
input_text = example.split('(TR:')[0].strip() # Update the input text directly with the Hamshetsnag part
|
109 |
-
break # Only use the first clicked example
|
110 |
-
|
111 |
-
if st.button("Tag POS"):
|
112 |
-
with st.spinner('Processing...'):
|
113 |
-
# Tag the input text and format output as per settings
|
114 |
-
output = tag_pos(input_text, detailed_output)
|
115 |
-
st.success(output)
|
116 |
-
|
117 |
-
def main():
|
118 |
-
st.set_page_config(
|
119 |
-
page_title="Hamshetsnag POS Tagger",
|
120 |
-
page_icon="📚",
|
121 |
-
layout='wide'
|
122 |
-
)
|
123 |
-
|
124 |
-
# Dictionary mapping pages
|
125 |
-
PAGES = {
|
126 |
-
"Home": home_page,
|
127 |
-
"POS Tagging": pos_tagging_page,
|
128 |
-
}
|
129 |
-
|
130 |
-
st.sidebar.title("Navigation")
|
131 |
-
selection = st.sidebar.radio("Pages", list(PAGES.keys()))
|
132 |
-
|
133 |
-
# Load and display the selected page
|
134 |
-
PAGES[selection]()
|
135 |
-
|
136 |
-
st.sidebar.header("Info")
|
137 |
-
st.sidebar.write(
|
138 |
-
"Models available on [HF Hub](https://huggingface.co/onurkeles/hamshetsnag-pos-tagger)"
|
139 |
-
)
|
140 |
-
st.sidebar.write(
|
141 |
-
"Model source code available on [GitHub](http://github.com/kelesonur)"
|
142 |
-
)
|
143 |
-
|
144 |
-
if __name__ == "__main__":
|
145 |
-
main()
|
|
|
1 |
+
import awesome_streamlit as ast
|
2 |
import streamlit as st
|
3 |
+
from home import write as write_home
|
4 |
+
from pos_tagger import write as write_pos_tagger
|
5 |
+
|
6 |
+
st.set_page_config(
|
7 |
+
page_title="Hamshetsnag POS Tagger",
|
8 |
+
page_icon="📚",
|
9 |
+
layout='wide'
|
10 |
+
)
|
11 |
+
|
12 |
+
PAGES = {
|
13 |
+
"Home": write_home,
|
14 |
+
"POS Tagging": write_pos_tagger,
|
15 |
+
}
|
16 |
+
|
17 |
+
st.sidebar.title("Navigation")
|
18 |
+
selection = st.sidebar.radio("Pages", list(PAGES.keys()))
|
19 |
+
|
20 |
+
page = PAGES[selection]
|
21 |
+
# with st.spinner(f"Loading {selection} ..."):
|
22 |
+
ast.shared.components.write_page(page)
|
23 |
+
|
24 |
+
st.sidebar.header("Info")
|
25 |
+
st.sidebar.write(
|
26 |
+
"Models available on [HF Hub](https://huggingface.co/onurkeles/hamshetsnag-pos-tagger)"
|
27 |
+
)
|
28 |
+
st.sidebar.write(
|
29 |
+
"Model source code will be soon available on [GitHub](http://github.com/kelesonur)"
|
30 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|