Language Heuristic Detector avatar

Language Heuristic Detector

Pricing

$0.01 / actor start

Go to Apify Store
Language Heuristic Detector

Language Heuristic Detector

Pricing

$0.01 / actor start

Rating

0.0

(0)

Developer

Eichan Jolly

Eichan Jolly

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

12 days ago

Last modified

Categories

Features

Limited permissions

Share

One job: make a small, deterministic heuristic guess about the language of one supplied text block, and show why that guess was made. No website fetching, machine learning, LLM or external API.

Who it is for

Developers, content organizers and RAG data-preparation pipelines that want a lightweight first-pass routing label for text that may need more careful language identification later.

How it works

  1. Count letters in Unicode writing systems: Hiragana, Katakana, Han, Hangul, Cyrillic, Arabic, Devanagari and Latin.
  2. If a non-Latin script is sufficiently prominent, make a script-based candidate guess: Japanese (ja, kana), Korean (ko, Hangul), Chinese (zh, Han-only), Russian (ru, Cyrillic), Arabic (ar, Arabic script) or Hindi (hi, Devanagari).
  3. Otherwise compare common-word patterns for English (en), Spanish (es), French (fr), German (de), Portuguese (pt) and Italian (it) with small hand-coded word lists. Weight more distinctive terms twice, select the highest score, and report a runner-up.
  4. Emit a qualitative heuristic confidence label (high, medium, low, insufficient) representing the strength of these few signals, not a calibrated probability. und means insufficient evidence, not an error.

Example input

{"text":"The library is open today, and the books are ready."}

Example output (one dataset item)

{
"heuristic_language_code": "en",
"heuristic_confidence_label": "high",
"signals": [
"Latin letters: 40",
"en common-word hits: 5 (weighted score 9)",
"de runner-up weighted score: 0"
],
"dominant_script_signal": "Latin",
"characters_analyzed": 51,
"method": "deterministic_script_and_common_word_heuristic"
}

The actual values are generated by code; see tests/smoke_dataset.json for the exact item from the runnable example.

Input and output

  • Input: text (required, nonempty string, max 50,000 characters).
  • Output: exactly one item with these stable fields: heuristic_language_code, heuristic_confidence_label, signals (list of plain-language evidence), dominant_script_signal, characters_analyzed, and method.

Honest limitations

  • This is not an ML detector and never reports a statistical accuracy or probability. The label high means clear support in a tiny fixed rule set, not 90%, 95%, or any other confidence percentage.
  • Scripts are shared: Cyrillic does not uniquely mean Russian, Arabic script does not uniquely mean Arabic, Devanagari does not uniquely mean Hindi, and Han-only text can be Japanese, Chinese or another language. Such guesses are explicitly capped in heuristic strength.
  • Spanish, French, Italian and Portuguese share many common words; short texts, titles, names, code, emojis, mixed languages, transliterations and dialects are often ambiguous. The detector may return und or misclassify them.
  • No sentence-level multilingual segmentation. Latin word lists cover only six languages; many other languages are not represented.
  • All operations are deterministic and offline; results should be independently checked before consequential use.

Local execution and verification

Python 3.12+; only the standard library, no dependencies to install:

ACTOR_INPUT_JSON='{"text":"The library is open today, and the books are ready."}' python src/main.py
python -m unittest discover -s tests -v
python tests/run_smoke.py

The test runner actually executes python src/main.py, saves the terminal output and JSON dataset item into tests/, and checks them. Local output is under storage/datasets/default/; on the Apify platform it uses Apify's internal REST storage API with the injected runtime token, not an API key provided by a user.

Store category and pricing suggestion

  • Intended category: AI (deterministic text pre-processing).
  • Suggested price: $0.005 per completed run (one text, one output item). Suggestion only — no platform billing configured, no publishing performed.
  • See store_metadata.json.

Deployment status

Script-mode execution and offline tests are included. Docker construction and real Apify platform execution have not been performed.