gerzin/irony-and-sarcasm-detector-italian

NLP project that analyses Italian tweets and finds out if they are ironic or not, and if they're ironic, if they are sarcastic or not.

4

stars

132

commits

Jupyter Notebook

primary language

Oct 14, 2022

updated

bert
bert-model
italian
keras
machine-learning
natural-language-processing
nlp
sentiment-analysis
tensorflow
transformers
twitter

README

IronySarcasmDetectorIT

NLP project that analyses Italian tweets and finds out if they are ironic or not, and if they're ironic, if they are sarcastic or not.

Challenge

The tasks solved in this project are the ones from the EVALITA 2018 challenge. The detailed description can be found here:

@inproceedings{cignarella2018overview,
  title={Overview of the {EVALITA} 2018 task on Irony Detection in {I}talian tweets ({IronITA})},
  author={Cignarella, Alessandra Teresa and Frenda, Simona and Basile, Valerio and Bosco, Cristina and Patti, Viviana and Rosso, Paolo and others},
  booktitle={Sixth Evaluation Campaign of Natural Language Processing and Speech Tools for Italian (EVALITA 2018)},
  volume={2263},
  pages={1--6},
  year={2018},
  organization={CEUR-WS}
}

Model

The framework used to develop the models is tensorflow.

Among all the models we developed, the one producing the best results has been the BERT-GRU model.

The BERT model we used was a pretrained one available on HuggingFace (https://huggingface.co/dbmdz/bert-base-italian-xxl-cased).

BERTGRUMODEL

Trained BERT-GRU model

Here you can download the trained BERT-GRU model (≈ 500MB). Another 400MB will be downloaded by the get_bert_tokenizer which will downloaded a pretrained tokenizer from HuggingFace.co

Here is an example of how to use it:

from models.bert_tokenizer import get_bert_tokenizer, tokenize
from preprocessing.pipeline import ItalianTweetsPreprocessingPipeline

pp = ItalianTweetsPreprocessingPipeline()

model = keras.models.load_model('path/to/trained/model/location')

tokenizer = get_bert_tokenizer()

tweets = pp.apply(pandas_frame_containing_tweets)
tokenized_tweets = tokenize(tweets, tokenizer)[:-1]

pred = model.predict(tokenized_tweet)

Challenge Results

  • Task A
NameF1 Avg
ItaliaNLP0.731
ItaliaNLP0.713
Our Model0.712
UNIBA0.710
UNIBA0.710
X2Check0.704
UNITOR0.700
UNITOR0.700
X2Check0.695
Aspie960.695
X2Check0.693
X2Check0.683
UOIRO0.651
UOIRO0.646
UOIRO0.629
UOIRO0.614
baseline-random0.505
venses-itgetarun0.470
venses-itgetarun0.420
baseline-mfc0.33
  • Task B
NameF1 Avg
Our Model0.536
UNITOR0.520
UNITOR0.518
ItaliaNLP0.516
ItaliaNLP0.503
Aspie960.465
baseline-random0.337
venses-itgetarun0.236
baseline-mfc0.223
venses-itgetarun0.199

Code structure

The main code is split across there three folders:

  • preprocessing - contains utilities for text preprocessing implementing the pipeline through which the tweets will pass.
  • models - contains the models implementations.
  • notebooks - contains the Jupyter notebooks we used to develop and test the code. The notebooks containing the models' implementations are meant to be run on Colab.

Contributors

gerzin

112 commits

dependabot[bot]

10 commits

MatteoMass

10 commits

gerzin/irony-and-sarcasm-detector-italian

NLP project that analyses Italian tweets and finds out if they are ironic or not, and if they're ironic, if they are sarcastic or not.

4

stars

132

commits

Jupyter Notebook

primary language

Oct 14, 2022

updated

bert
bert-model
italian
keras
machine-learning
natural-language-processing
nlp
sentiment-analysis
tensorflow
transformers
twitter

README

IronySarcasmDetectorIT

NLP project that analyses Italian tweets and finds out if they are ironic or not, and if they're ironic, if they are sarcastic or not.

Challenge

The tasks solved in this project are the ones from the EVALITA 2018 challenge. The detailed description can be found here:

@inproceedings{cignarella2018overview,
  title={Overview of the {EVALITA} 2018 task on Irony Detection in {I}talian tweets ({IronITA})},
  author={Cignarella, Alessandra Teresa and Frenda, Simona and Basile, Valerio and Bosco, Cristina and Patti, Viviana and Rosso, Paolo and others},
  booktitle={Sixth Evaluation Campaign of Natural Language Processing and Speech Tools for Italian (EVALITA 2018)},
  volume={2263},
  pages={1--6},
  year={2018},
  organization={CEUR-WS}
}

Model

The framework used to develop the models is tensorflow.

Among all the models we developed, the one producing the best results has been the BERT-GRU model.

The BERT model we used was a pretrained one available on HuggingFace (https://huggingface.co/dbmdz/bert-base-italian-xxl-cased).

BERTGRUMODEL

Trained BERT-GRU model

Here you can download the trained BERT-GRU model (≈ 500MB). Another 400MB will be downloaded by the get_bert_tokenizer which will downloaded a pretrained tokenizer from HuggingFace.co

Here is an example of how to use it:

from models.bert_tokenizer import get_bert_tokenizer, tokenize
from preprocessing.pipeline import ItalianTweetsPreprocessingPipeline

pp = ItalianTweetsPreprocessingPipeline()

model = keras.models.load_model('path/to/trained/model/location')

tokenizer = get_bert_tokenizer()

tweets = pp.apply(pandas_frame_containing_tweets)
tokenized_tweets = tokenize(tweets, tokenizer)[:-1]

pred = model.predict(tokenized_tweet)

Challenge Results

  • Task A
NameF1 Avg
ItaliaNLP0.731
ItaliaNLP0.713
Our Model0.712
UNIBA0.710
UNIBA0.710
X2Check0.704
UNITOR0.700
UNITOR0.700
X2Check0.695
Aspie960.695
X2Check0.693
X2Check0.683
UOIRO0.651
UOIRO0.646
UOIRO0.629
UOIRO0.614
baseline-random0.505
venses-itgetarun0.470
venses-itgetarun0.420
baseline-mfc0.33
  • Task B
NameF1 Avg
Our Model0.536
UNITOR0.520
UNITOR0.518
ItaliaNLP0.516
ItaliaNLP0.503
Aspie960.465
baseline-random0.337
venses-itgetarun0.236
baseline-mfc0.223
venses-itgetarun0.199

Code structure

The main code is split across there three folders:

  • preprocessing - contains utilities for text preprocessing implementing the pipeline through which the tweets will pass.
  • models - contains the models implementations.
  • notebooks - contains the Jupyter notebooks we used to develop and test the code. The notebooks containing the models' implementations are meant to be run on Colab.

Contributors

gerzin

112 commits

dependabot[bot]

10 commits

MatteoMass

10 commits

Languages

Jupyter Notebook

87.3%

Python

12.7%