Repository of OpenClassrooms' AI Engineer path, project #1.
Goal : use MS Azure's Cognitive Services to detect the language of some text.
Check the presentation for this project : Language Detector - Module Polyglotte presentation
- Install dependencies
$ pip install -r requirements.txt
- Create a Translator resource in Azure
Follow Azure's official documentation : Create a Translator resource
- Configure your environment
Rename .env.example
into .env
and set the parameters with the values provided by Azure.
Run python detector-cli.py --text TEXT
to detect the language of the text passed as an argument.
$ python detector-cli.py --text "We are the knights who say 'Ni!'"
> Detected language : en
Run python detector-cli.py
to detect the language of a random line of text in one of the most spoken languages (en, zh, hi, es, ar and fr) from the dataset (data/x_test.txt
).
$ python detector-cli.py
> Text : عملية التقويم أي إذا كان هناك درجات للنشاط يحاسب عليها التلميذ في تقصيره وتفاعلة أداء ذلك إلى التحاق بالنشاط و الإمكانيات المتاحة أي إذا كان هناك توفير الأدوات والأنشطة وتوفرت الأماكن كان النشاط كثير و أخيراً التوجيه نحو الإنجاز بمعنى إذا قام المدير بتكريم أداء ذلك إلى تفعيل النشاط.
>
> Expected language : ar
> Detected language : ar
> Result: SUCCESS
Run pytest
to check that the language of the most spoken languages is correctly detected.