Skip to content

๐ŸŒ Detect the language of any text via the CLI using franc, with ISO code mapping and colorized output.

License

Notifications You must be signed in to change notification settings

Misba0019/LangDetect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

15 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒ LangDetect

A simple command-line tool to detect the language of a given text using:

  • franc for language detection
  • langs for mapping ISO 639-3 codes to readable names
  • colors for colorized console output

Features

  • Detects the language of input text based on statistical analysis.
  • Provides the language name and ISO 639-3 code.
  • Handles cases where the language cannot be determined or is unsupported.
  • Encourages longer input for better accuracy.
  • Outputs colorized, readable messages in the terminal.

Usage

  1. Clone the repository:
    git clone https://github.com/Misba0019/LangDetect.git
    cd LangDetect
  2. Install dependencies:
    npm install
  3. Run the tool:
    node index.js "Your text here"
  • Example:
    node index.js "Hello, this tool can guess different languages."
  • Output:
    Detected language code: eng
    The language appears to be: English

Terminal Output Preview

Hereโ€™s what a sample run looks like: LangDetect output


Requirements

  • Node.js (version 18 or higher)

How It Works

  1. The tool takes a text input from the command line.
  2. It uses the franc library to detect the language code.
  3. The langs library maps the detected code to a language name.
  4. If the language cannot be determined (und) or is unsupported, the tool provides feedback to the user.

Limitations

  • Short or ambiguous text may return und (undefined)
  • Some rare languages may not be supported by the langs package.

Credits

Powered by the open-source libraries:


License

This project is licensed under the MIT License. See the LICENSE file for details.

About

๐ŸŒ Detect the language of any text via the CLI using franc, with ISO code mapping and colorized output.

Topics

Resources

License

Stars

Watchers

Forks