# Deploying External Knowledge for RTE with Figurative Language


Here are implementation codes of experiments of the bachelor thesis, "Deploying External Knowledge for Recognizing Textual Entailment with Figurative Language".


***
## Repo structure

- `atomic`

    - contain [templates]() for ATOMIC-2020 that are modified from the [original templates](https://github.com/sysuhcm/NLI-KB/blob/master/kb_process/atomic_process.py).
    - HasP_Attr_React.zip : KB sentences converted from KB triples with four relations (HasProperty, xAttr, xReact, oReact) via the templates


- `datasets` - contain [figurative datasets](#-figuratvie-datasets)

- `metaphor_module.py` & `metaphor.py` - functions and execution for metaphor datasets

- `simile_module.py` & `simile.py` - functions and execution for simile datasets

- `impli.py` - execution file for IMPLI metaphor (gold pairs) datasets



## Installation

Following packages need to be installed:
- re
- torch
- nltk
- requests
- ast
- transformers (for AutoTokenizer, AutoModelForSequenceClassification)
- sentence_transformers (for SentenceTransformer)



## Figurative Datasets

- `simile-entail.txt` and `metaphor-entail.txt` are originally from [Figurative-NLI](https://github.com/tuhinjubcse/Figurative-NLI/tree/main/data)
    * `new-simile-entail.txt` include four examples that are re-annotated.

    | Examples | Gold Label | New Label |
    | :---: | :---: | :---: |
    |p: The old van in the field is like **a stiff sweatshirt**.<br>h: The old van in the field is almost *comfortable*.| E | NE |
    |p: The old van in the field is like **a stiff sweatshirt**.<br>h:  The old van in the field is almost *uncomfortable*. | NE | E |
    |p: When you confront him about it, he is like **the perfectly ignorant boyfriend**.<br>h: When you confront him about it, he is absolutely *astounded*.| E | NE |
    |p: When you confront him about it, he is like **the perfectly ignorant boyfriend**.<br>h: When you confront him about it, he is absolutely *unconcerned*.| NE | E |


- `manual_e.txt` and `manual_ne.txt` are originally from [IMPLI](https://github.com/UKPLab/acl2022-impli)



## Preprocessing

- Download [ATOMIC-2020](https://allenai.org/data/atomic-2020) and use templates to convert triples to natural language sentences.
- Download [VerbNet 3.3](http://verbs.colorado.edu/verb-index/vn/verbnet-3.3.tar.gz).



## Authors
Hyunji Kim

Computational Linguistics, Heidelberg University


## References
```{r}
    @inproceedings{chakrabarty-etal-2021-figurative,
        title = "Figurative Language in Recognizing Textual Entailment",
        author = "Chakrabarty, Tuhin  and Ghosh, Debanjan  and Poliak, Adam  and Muresan, Smaranda",
        booktitle = "Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021",
        month = aug,
        year = "2021",
        address = "Online",
        publisher = "Association for Computational Linguistics",
        url = "https://aclanthology.org/2021.findings-acl.297",
        pages = "3354--3361"}

    @inproceedings{stowe-2022,
        title = "IMPLI: Investigating NLI Models' Performance on Figurative Language",
        author = "Stowe, Kevin and Utama, Prasetya Ajie, and Gurevytch, Iryna",
        booktitle = "Proceedings of the 2022 Conference for the Association of Computational Linguistics",
        month = "06",
        year = "2022",
        publisher = "Association for Computational Linguistics",
        url = "tbd"}
```

