RTL/LTR Script Direction Classifier
Audit letters in an explicitly bounded selected-script subset for common RTL/LTR direction and first classified letter; other scripts remain unclassified. Not Unicode bidi-class/UAX#9 layout, spoof detection or inferred language.
Description
Script-level direction counts provide a limited text inventory.
Script-level direction counts provide a limited text inventory. Actual Unicode bidirectional layout also depends on marks, numbers and formatting controls.1, 2
Enter text. Count RTL Hebrew/Arabic/Syriac/Thaana/Nko/Adlam and LTR Latin/Greek/Cyrillic/Han/Hiragana/Katakana/Hangul/Devanagari/Thai letters; retain other letters as unclassified. Return first classified direction or none and mixed flag.
When to use RTL/LTR Script Direction Classifier
Use RTL/LTR Script Direction Classifier when you need to evaluate the supplied records under the calculation and evidence rules below. This is not Unicode bidi-class resolution, layout, language identification or spoof detection.
Prepare explicit text tokens, annotated language observations, caller mappings or a supported locale as requested. Preserve source evidence and the stated Unicode counting convention.
How to use RTL/LTR Script Direction Classifier and understand its results
- Prepare explicit text tokens, annotated language observations, caller mappings or a supported locale as requested. Preserve source evidence and the stated Unicode counting convention.
- Enter observedText using the field table and calculation rules, then run the tool.
- Read firstObservedStrongDirection, leftToRightLetterCount, rightToLeftLetterCount, otherUnclassifiedLetterCount, mixedDirectionLettersObserved. The explanation below defines the units, signs, ordering and any flags or placeholder values.
- If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
| Input field | Meaning | Value type; see rules below | Requirement |
|---|---|---|---|
| observedText | Observed text | string | Required |
Enter text. Count RTL Hebrew/Arabic/Syriac/Thaana/Nko/Adlam and LTR Latin/Greek/Cyrillic/Han/Hiragana/Katakana/Hangul/Devanagari/Thai letters; retain other letters as unclassified. Return first classified direction or none and mixed flag.
count letters in selected RTL/LTR scripts; first classified letter supplies initial direction Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.
| Output field | Meaning | Value type |
|---|---|---|
| firstObservedStrongDirection | First observed strong direction | string |
| leftToRightLetterCount | Left to right letter count | number |
| rightToLeftLetterCount | Right to left letter count | number |
| otherUnclassifiedLetterCount | Other unclassified letter count | number |
| mixedDirectionLettersObserved | Mixed direction letters observed | boolean |
{
"input": {
"observedText": "Hello אב"
},
"output": {
"firstObservedStrongDirection": "ltr",
"leftToRightLetterCount": 5,
"rightToLeftLetterCount": 2,
"otherUnclassifiedLetterCount": 0,
"mixedDirectionLettersObserved": true
}
} Limitations and assumptions
This is not Unicode bidi-class resolution, layout, language identification or spoof detection.
Numeric inputs, where present, must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Extremely large text inputs are rejected. Missing required fields, extra fields, wrong value types and violations of the calculation rules are input errors. A successfully returned false flag is an evaluated outcome; its meaning is explained above.
Alternative or Complementary methods
Use Stopword-Based Language Guess Score: Stopword overlap supplies lexical evidence for caller-defined profiles. Shared words can produce ties and zero matches can mean no evidence. For a complementary task, use Hangul Jamo Composition Count: A modern Hangul syllable contains leading and vowel jamo plus an optional trailing jamo. Unicode composition gives an exact decomposition.
Further background: Unicode Bidirectional Algorithm.
References
-
RTL/LTR Script Direction Classifier — tool.io
-
Unicode Bidirectional Algorithm — Unicode Consortium
Similar or alternative tools
- Stopword-Based Language Guess Score
Stopword overlap supplies lexical evidence for caller-defined profiles. Shared words can produce ties and zero matches can mean no evidence.
- Hangul Jamo Composition Count
A modern Hangul syllable contains leading and vowel jamo plus an optional trailing jamo. Unicode composition gives an exact decomposition.