Skip to content

Commit a9aa557

Browse files
authored
Merge pull request Shahrayar123#284 from stephenombuya/master
Language Detector Project
2 parents 28791ec + 0eca4b0 commit a9aa557

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

Language Detector/Readme.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Language Detector
2+
3+
This is a simple Python project that uses the `langdetect` library to detect the language of a given text.
4+
5+
## Setup
6+
7+
1. Clone the repository.
8+
2. Install the dependencies:
9+
10+
```bash
11+
pip install -r requirements.txt
12+
3. Run the main script:
13+
14+
```bash
15+
python main.py

Language Detector/main.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Language Detector
2+
from langdetect import detect
3+
4+
# Detecting languages from input text
5+
language1 = detect('¿Qué te gusta hacer')
6+
language2 = detect('Nyasae no omuya')
7+
8+
# Mapping of language codes to human-readable names
9+
language_mapping = {
10+
'es': 'Spanish',
11+
'en': 'English',
12+
'sw': 'Swahili',
13+
'ek': 'Kisii'
14+
}
15+
16+
# Print the detected language in a more user-friendly format
17+
print(f'This is the {language_mapping.get(language1, language1)} language shortened by: {language1}')
18+
print(f'This is the {language_mapping.get(language2, language2)} language shortened by: {language2}')

Language Detector/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
langdetect==1.0.9

0 commit comments

Comments
 (0)