Spanish

The first text model created is based on tweets collected from December 2015 until February 2020. From this collection we randomly selected approximately 5,000,000, excluding retweets and tweets having less than two words, to create the text model. The text model is created using the following paramters.

from b4msa.textmodel import TextModel
tm = TextModel(usr_option="delete",
               num_option="delete",
               url_option="delete",
               emo_option="none",
               token_min_filter=0.001,
               token_max_filter=0.999)

The aforementioned model is a bag of word model, where the number of tokens is 15,227 (i.e., \(m_b: \text{text} \rightarrow \mathbb R^{15227}\)).

This model (without using the text model trained with the training set) can be used as follow:

>>> from EvoMSA.base import EvoMSA
>>> evo = EvoMSA(TR=False, B4MSA=True, lang='es')

The next table shows the different models we have produced for the Spanish language.

Source

Model

Multilingual Twitter sentiment classification: The role of human annotators [Human-Annotated]

Human annotated model

Overview of TASS 2017 [TASS2017]

tass2016_Es.evomsa tass2017_Es.evomsa

Overview of TASS 2018: Opinions, health and emotions [TASS2018]

tass2018_s1_l1_Es.evomsa tass2018_s1_l2_Es.evomsa tass2018_s2_Es.evomsa

SemEval-2018 Task 1: Affect in tweets [Task-1]

semeval2018_anger_Es.evomsa semeval2018_fear_Es.evomsa semeval2018_joy_Es.evomsa semeval2018_sadness_Es.evomsa semeval2018_valence_Es.evomsa

Overview of MEX-A3T at IberEval 2018 [MEX-A3T]

mexa3t2018_aggress_Es.evomsa

Overview of the HAHA Task [HAHA]

haha2018_Es.evomsa

Overview of the Task on Automatic Misogyny Identification at IberEval 2018 [AMI]

misoginia_Es.evomsa

Estado de ánimo de los tuiteros en México

INEGI-MX_Es.evomsa

The following code shows the usage of two of the models with suffix .evomsa. The models used are haha2018_Es.evomsa, mexa3t2018_aggress_Es.evomsa, as well as \(m_b\) text-model, and without the text model obtained with the training set.

>>> from EvoMSA.utils import download
>>> from EvoMSA.base import EvoMSA
>>> from microtc.utils import tweet_iterator
>>> import os
>>> tweets = os.path.join(os.path.dirname(base.__file__), 'tests', 'tweets.json')
>>> D = list(tweet_iterator(tweets))
>>> X = [x['text'] for x in D]
>>> y = [x['klass'] for x in D]
>>> haha = download('haha2018_Es.evomsa')
>>> mexa3t = download('mexa3t2018_aggress_Es.evomsa')
>>> evo = EvoMSA(TR=False, B4MSA=True, lang='es',
                 models=[[haha, "sklearn.svm.LinearSVC"],
                         [mexa3t, "sklearn.svm.LinearSVC"]])
>>> evo.fit(X, y)

where sklearn.svm.LinearSVC can be any classifier following the structure of sklearn.

Predict a sentence in Spanish

>>> evo.predict(['EvoMSA esta funcionando'])