A Python script that uses Ollama AI to automatically detect and categorize the language of text entries. This tool reads words or phrases from an input file and identifies their language using the Qwen3:4b-instruct model.
- 🌍 Automatic language detection for multiple languages (English, French, German, Spanish, Japanese, Chinese, Italian, etc.)
- 🤖 Powered by Ollama with Qwen3:4b-instruct model
- 📝 Batch processing of text files
- ⚡ Fast and efficient processing
- 📊 Clear output format showing word → language mappings
- Python 3.14 or higher
- Ollama installed and running on your computer
- Qwen3:4b-instruct model pulled in Ollama
-
Clone or download this repository
-
Install dependencies using
uv:uv sync
-
Make sure Ollama is running and has the Qwen3:4b-instruct model:
ollama pull qwen3:4b-instruct
-
Add your text entries to
input.txt(one entry per line) -
Run the script:
uv run main.py
-
Check the results in
output.txt
Input (input.txt):
Mango
りんご
Fraise
Banane
Output (output.txt):
Mango -> English
りんご -> Japanese
Fraise -> French
Banane -> French
The script:
- Reads each line from
input.txt - Sends each entry to Ollama using the Qwen3:4b-instruct model
- Receives the detected language for each entry
- Writes the results in
word -> languageformat tooutput.txt - Displays progress and total processing time in the console
ollama>=0.6.1- Python client for Ollama AI
categorizer/
├── main.py # Main script for language categorization
├── input.txt # Input file with text entries
├── output.txt # Output file with categorization results
├── pyproject.toml # Project configuration and dependencies
├── README.md # This file
└── uv.lock # Locked dependencies
This project is open source and available for personal and educational use.