Skip to content

Main content

Morpheme Boundary Byte Offset

Count UTF-8 bytes preceding an explicit morpheme boundary, requiring each morpheme to contain complete Unicode scalar values; the terminal boundary is allowed.

Loading tool…

Description

Count UTF-8 bytes preceding a supplied morpheme boundary.

Language-processing records distinguish tokens, code points, UTF-16 positions and UTF-8 byte offsets. Tag grammars and local transition checks do not validate a full annotation sequence. Log-loss units determine perplexity conversion, while identifier suffixes may be textual labels rather than ordinary decimal numbers.

Count UTF-8 bytes preceding a supplied morpheme boundary.

When to use this tool

Use Morpheme Boundary Byte Offset when you already have morphemes, boundaryIndex and need to count UTF-8 bytes preceding a supplied morpheme boundary.

How to use the tool and how it works

  1. Enter morphemes, boundaryIndex. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read utf8ByteOffset, precedingMorphemeCount. Use the output convention below.

Reject unpaired surrogates in every morpheme; require a safe boundary index 0..morphemes.length. Concatenate preceding morphemes without separators, UTF-8 encode the prefix and return byte length and preceding count.1

UTF-8 encodes a Unicode scalar value in one to four bytes; supplementary characters use surrogate pairs in UTF-16. A byte boundary therefore differs from a JavaScript string-length boundary.2

Input fieldMeaning and unitsAccepted input
morphemesAll entries must have paired Unicode surrogates, including entries after the requested boundary.Required. Array of text; maximum UTF-16 length 8192; maximum items 256.
boundaryIndexBoundary IndexRequired. Safe integer; minimum 0.
Output fieldInterpretationReturned shape
utf8ByteOffsetByte count of concatenated morphemes strictly before boundaryIndex, without separators.Required. Safe integer.
precedingMorphemeCountPreceding Morpheme CountRequired. Safe integer.
json
{
  "input": {
    "morphemes": [
      "un",
      "café",
      "s"
    ],
    "boundaryIndex": 2
  },
  "output": {
    "utf8ByteOffset": 7,
    "precedingMorphemeCount": 2
  }
}

Limitations and assumptions

  • This is a byte offset, not code-point, grapheme or UTF-16 offset. No segmentation, normalization, original-byte spelling, BOM or separator length is inferred.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.

Alternative or Complementary methods

Validate the complete corpus format, tokenizer, annotation sequence and scoring convention. Use a full parser or model evaluation when needed, preserving the exact offset unit, vocabulary and log base rather than inferring them from a local transformation.

References

  1. Calculation and input contract: computational-linguistics/morpheme-boundary-byte-offset — tool.io

  2. Unicode 17.0: UTF-8 and UTF-16 encoding forms — Unicode Consortium

Similar or alternative tools