Spaces:
No application file
No application file
import streamlit as st | |
from sentence_transformers import SentenceTransformer | |
from langdetect import detect, DetectorFactory | |
st.set_page_config(page_title="Simple Text Analysis", layout="wide") | |
def load_model(): | |
return SentenceTransformer('distiluse-base-multilingual-cased-v1') | |
DetectorFactory.seed = 0 | |
model = load_model() | |
st.title("Simple Text Analysis") | |
user_input = st.text_area("Enter your text here:") | |
if st.button("Analyze"): | |
if user_input: | |
try: | |
lang = detect(user_input) | |
st.write(f"Detected language: {lang}") | |
embedding = model.encode(user_input) | |
st.write(f"Text embedding shape: {embedding.shape}") | |
st.write("First few values of the embedding:") | |
st.write(embedding[:5]) | |
except Exception as e: | |
st.error(f"An error occurred: {str(e)}") | |
else: | |
st.warning("Please enter some text to analyze.") | |
st.sidebar.title("About") | |
st.sidebar.info("This is a simple text analysis app.") |