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

  1. Prepare explicit text tokens, annotated language observations, caller mappings or a supported locale as requested. Preserve source evidence and the stated Unicode counting convention.
  2. Enter observedText using the field table and calculation rules, then run the tool.
  3. Read firstObservedStrongDirection, leftToRightLetterCount, rightToLeftLetterCount, otherUnclassifiedLetterCount, mixedDirectionLettersObserved. The explanation below defines the units, signs, ordering and any flags or placeholder values.
  4. 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 fieldMeaningValue type; see rules belowRequirement
observedTextObserved textstringRequired

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 fieldMeaningValue type
firstObservedStrongDirectionFirst observed strong directionstring
leftToRightLetterCountLeft to right letter countnumber
rightToLeftLetterCountRight to left letter countnumber
otherUnclassifiedLetterCountOther unclassified letter countnumber
mixedDirectionLettersObservedMixed direction letters observedboolean
json
{
  "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

  1. RTL/LTR Script Direction Classifier — tool.io

  2. 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.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies