This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
I was following the Comparing Sentiment Analysis Algorithms article, but when trying to use the StandfordCoreNLP Sentiment tool I was getting the error "The external program "java" returned an error code: 2", just like in this post, being unable to run Java using the RunCommand.
The solution, posted here, worked fine, being able to solve the problem by wraping the java command in a cmd shell.
However, I am unable to get the CoreNLP running in other languages,as explained here. Any idea on how to modify the macro to achieve this? I have been toying with the configuration of some Formula tools but I am back to Java errors.
It looks like quite a bit of work needs to be done to get that tool to run with other languages based on the dependencies listed. One alternative would be to run your text through a translation API as part of your workflow to then be run through an English sentiment analysis process. That way you could run the tool as is.
That’s actually a solid alternative, but it moves the problem to how to translate texts in Alteryx. I am only able to find solutions that use the Cognitive Services Text Translation macro. This uses the same Microsoft paid services than the Cognitive Services Text Analytics macro, which already provides sentiment analysis in multiple languages at the same price.
So instead of paying for a translation, you can pay directly for a sentiment analysis in your language of choice.
The "Comparing Sentiment Analysis Algorithms" article that I mentioned explored different open source solutions, but all of them are in English only, or difficult to adapt to Alteryx.
Do you know an open source solution to translate texts in Alteryx? That would solve the problem.
I tried translating to English and then use the Stanford core. Also tried other packages such as TextBlob & Vader. At the end, I got the best results with a package called 'Spanish Sentiment Analysis', with everything in Spanish from scratch
Attached is a macro that gets a text field and returns the score 0..1
The second best option was translating the texts and moving to TextBlob. Here is some code for your python tool to use both TB and SpanishSA:
from ayx import Package
from ayx import Alteryx
from textblob import TextBlob
from textblob.sentiments import NaiveBayesAnalyzer
return TextBlob(text).translate(from_lang = 'es', to='en')
# Spanish Sentiment Analysis
# Necesita permisos y conex abierta.
# Necesita Microsoft Visual C++ Build Tools
from classifier import *
clf = SentimentClassifier()
# Procesar todas las líneas
texto = Alteryx.read("#1")
texto2 = texto
texto2['salida'] = texto['entrada'].apply(traducir)
texto2['tb_polaridad'] = texto2['salida'].apply(calcular_polaridad)
texto2['tb_subjetividad'] = texto2['salida'].apply(calcular_subjetividad)
# Es necesario cambiar el tipo de la salida
texto2['salida'] = texto['salida'].apply(str)
texto2['spa_score'] = texto['entrada'].apply(score_spa)
import pandas as pd
# Necesario para modificar el tipo de datos
b = pd.DataFrame(texto2)
The solution is not optimal, you need to tune it to your needs, by finding specific expressions or words in your use-case and adapting the wf