File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 } ' )
Original file line number Diff line number Diff line change
1
+ langdetect == 1.0.9
You can’t perform that action at this time.
0 commit comments