Skip to content

Coder-dev2006/language-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 Language Detector (Python)

A simple yet enhanced Python tool that automatically detects the language of any text using the langdetect library. You can input a single text or scan an entire file β€” the program will identify each language detected!

✨ Features

βœ… Detects over 55+ languages βœ… Supports single text or file input βœ… Can export results to JSON or CSV βœ… Command-line interface with flexible arguments βœ… Lightweight, fast, and beginner-friendly βœ… Built entirely with pure Python

βš™οΈ Installation

Install the required dependency:

pip install langdetect

Clone this repository (if you haven’t yet):

git clone https://github.com/Coder-dev2006/language-detection.git cd language-detection

πŸš€ Usage 🧾 Option 1: Single text detection

Run from terminal:

python main.py -t "Bonjour tout le monde"

Output:

Detected: fr / French β€” top: fr(0.9999)

πŸ“‚ Option 2: Detect languages in a text file

Create a file named texts.txt:

Hello world ΠŸΡ€ΠΈΠ²Π΅Ρ‚ ΠΌΠΈΡ€ Salom dunyo Hola mundo

Then run:

python main.py -f texts.txt --csv results.csv

Output example:

Detected 4 lines, exported to results.csv βœ…

πŸ› οΈ Command-line arguments Argument Description Example -t, --text Analyze a single text string -t "Hello world" -f, --file Analyze a file with multiple lines -f texts.txt --json Save detection results in JSON format --json result.json --csv Save detection results in CSV format --csv result.csv --top Show top N detected languages --top 3 -v Verbose mode (debug info) -v πŸ“‚ Project Structure language-detection/ β”‚ β”œβ”€β”€ main.py β”œβ”€β”€ README.md β”œβ”€β”€ requirements.txt # optional └── texts.txt # sample input

⚑ How It Works

Imports the detect() function from the langdetect library.

Takes either user input or file input.

Detects the dominant language(s).

Displays results or saves them in JSON/CSV.

🌍 Common Language Codes Code Language Code Language en English fr French uz Uzbek ru Russian de German es Spanish ar Arabic ja Japanese zh Chinese it Italian 🧩 Future Improvements

βœ… Add translation feature (via googletrans)

βœ… Add GUI (Tkinter) interface for easy use

βœ… Support batch file processing

βœ… Improve accuracy metrics and confidence score output

🀝 Contributing

Want to add new features?

Fork this repository

Create a new branch

git checkout -b feature/my-feature

Commit your changes

git commit -m "Add: new detection improvement"

Push and create a Pull Request πŸš€

πŸ‘¨β€πŸ’» Author

Developed with ❀️ by Coder-dev2006

Simple yet powerful example of natural language detection in Python.

πŸ“„ License

This project is licensed under the MIT License β€” free for personal and educational use!!!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages