Agente-editorial-novela / editor_literario_tono.py
Horacio Perez
Upload 11 files
5852f36 verified
raw
history blame contribute delete
503 Bytes
from textblob import TextBlob
def analizar_tono(texto):
if not texto.strip():
return "El texto está vacío."
blob = TextBlob(texto)
polaridad = blob.sentiment.polarity
subjetividad = blob.sentiment.subjectivity
tono = "Neutral"
if polaridad > 0.2:
tono = "Positivo"
elif polaridad < -0.2:
tono = "Negativo"
resultado = {
"tono": tono,
"polaridad": polaridad,
"subjetividad": subjetividad,
}
return resultado