File size: 785 Bytes
789d284
 
 
621b222
789d284
fa8bb67
789d284
c6b6b4d
789d284
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67b2f0d
1
2
3
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
31
import streamlit as st
from transformers import pipeline

# Initialize the POS tagger with from_pt=True for PyTorch model
pos_tagger = pipeline(
    model="projecte-aina/roberta-base-ca-cased-pos",
    aggregation_strategy="simple",
 
)

# Function to get color for each POS tag
def get_color(pos_tag):
    colors = {
        "PRON": "blue",
        "VERB": "green",
        "ADP": "red",
        "PROPN": "orange",
        # Add more POS tags and colors as needed
    }
    return colors.get(pos_tag, "grey")  # Default color

# Streamlit app
st.title("Part-of-Speech Highlighter")

# Text input
text = st.text_area("Enter your text here:", "I am an artist and I live in Dublin")

# Process text and highlight POS
if text:
    pos_result = pos_tagger(text)
    st.markdown(pos_result)