https://github.com/camel-lab/codafication
Code, models, and data for "Exploiting Dialect Identification in Automatic Dialectal Text Normalization". ArabicNLP 2024, ACL.
Science Score: 23.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
✓Academic publication links
Links to: arxiv.org -
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.1%) to scientific vocabulary
Keywords
Repository
Code, models, and data for "Exploiting Dialect Identification in Automatic Dialectal Text Normalization". ArabicNLP 2024, ACL.
Basic Info
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
CODAfication
This repo contains code and pretrained models to reproduce the results in our paper Exploiting Dialect Identification in Automatic Dialectal Text Normalization.
Requirements:
The code was written for python>=3.9, pytorch 1.11.1, and transformers 4.22.2. You will need a few additional packages. Here's how you can set up the environment using conda (assuming you have conda and cuda installed):
```bash git clone https://github.com/CAMeL-Lab/codafication.git cd coda
conda create -n coda python=3.9 conda activate coda
pip install -r requirements.txt ```
Experiments and Reproducibility:
data: includes all the data we used throughout our paper to train and test various systems. This includes alignments, m2edits, the MADAR CODA Corpus, and all the utilities we used.
codafication: includes the scripts needed to train and evaluate our codafication models.
utils: includes various scripts used for evaluation and statistical significance.
Hugging Face Integration:
We make our CODAfication models publicly available on Hugging Face.
```python from transformers import AutoTokenizer, AutoModelForSeq2SeqLM from camel_tools.dialectid import DIDModel6 import torch
DID = DIDModel6.pretrained() DAPHRASEMAP = {'BEI': 'في بيروت منقول', 'CAI': 'في القاهرة بنقول', 'DOH': 'في الدوحة نقول', 'RAB': 'في الرباط كنقولو', 'TUN': 'في تونس نقولو'}
def predict_dialect(sent): """Predicts the dialect of a sentence using the CAMeL Tools MADAR 6 DID model"""
predictions = DID.predict([sent])
scores = predictions[0].scores
if predictions[0].top != "MSA":
# get the highest pred
pred = sorted(scores.items(),
key=lambda x: x[1], reverse=True)[0]
else:
# get the second highest pred
pred = sorted(scores.items(),
key=lambda x: x[1], reverse=True)[1]
dialect = pred[0]
score = pred[1]
return dialect, score
tokenizer = AutoTokenizer.frompretrained('CAMeL-Lab/arat5-coda-did') model = AutoModelForSeq2SeqLM.frompretrained('CAMeL-Lab/arat5-coda-did')
text = 'اتنين هامبورجر و اتنين قهوة، لو سمحت. عايزهم تيك اواي.'
preddialect, _ = predictdialect(text) text = DAPHRASEMAP[pred_dialect] + ' ' + text
inputs = tokenizer(text, returntensors='pt') genkwargs = {'numbeams': 5, 'maxlength': 200, 'numreturnsequences': 1, 'norepeatngramsize': 0, 'earlystopping': False }
codafiedtext = model.generate(*inputs, *genkwargs) codafiedtext = tokenizer.batchdecode(codafiedtext, skipspecialtokens=True, cleanuptokenizationspaces=False)[0]
print(codafied_text) "اثنين هامبورجر واثنين قهوة، لو سمحت. عايزهم تيك اوي." ```
License:
This repo is available under the MIT license. See the LICENSE for more info.
Citation
If you find the code or data in this repo helpful, please cite our paper:
BibTeX
@inproceedings{alhafni-etal-2024-exploiting,
title = "Exploiting Dialect Identification in Automatic Dialectal Text Normalization",
author = "Alhafni, Bashar and
Al-Towaity, Sarah and
Fawzy, Ziyad and
Nassar, Fatema and
Eryani, Fadhl and
Bouamor, Houda and
Habash, Nizar",
booktitle = "Proceedings of ArabicNLP 2024"
month = "aug",
year = "2024",
address = "Bangkok, Thailand",
abstract = "Dialectal Arabic is the primary spoken language used by native Arabic speakers in daily communication. The rise of social media platforms has notably expanded its use as a written language. However, Arabic dialects do not have standard orthographies. This, combined with the inherent noise in user-generated content on social media, presents a major challenge to NLP applications dealing with Dialectal Arabic. In this paper, we explore and report on the task of CODAfication, which aims to normalize Dialectal Arabic into the Conventional Orthography for Dialectal Arabic (CODA). We work with a unique parallel corpus of multiple Arabic dialects focusing on five major city dialects. We benchmark newly developed pretrained sequence-to-sequence models on the task of CODAfication. We further show that using dialect identification information improves the performance across all dialects. We make our code, data, and pretrained models publicly available.",
}
Owner
- Name: CAMeL Lab
- Login: CAMeL-Lab
- Kind: organization
- Location: Abu Dhabi, UAE
- Website: http://camel-lab.com
- Repositories: 22
- Profile: https://github.com/CAMeL-Lab
The Computational Approaches to Modeling Language (CAMeL) Lab at New York University Abu Dhabi
GitHub Events
Total
Last Year
Dependencies
- camel-tools *
- datasets ==2.5.1
- evaluate *
- jiwer *
- numpy ==1.26.4
- protobuf ==3.20.3
- sentencepiece ==0.1.99
- torch ==1.11.0
- transformers ==4.22.2
- docopt *
- rapidfuzz *