Skip to content

Main content

Parse Node Span Width Tool

Calculate parse node span width from explicit caller-supplied inputs.

Loading tool…

Description

Return token-span width with explicit end inclusion.

Language-processing records depend on tokenization, indexing, null sentinels and text representation. A UTF-8 byte offset, UTF-16 index, dependency link or literal feature label can be handled precisely without inferring linguistic correctness or semantic equivalence.

Return token-span width with explicit end inclusion.

When to use this tool

Use Parse Node Span Width when checking a supplied linguistic annotation, span, alignment or text-offset convention.

How to use the tool and how it works

  1. Enter startToken, endToken, inclusiveEnd. 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 width. Use the output convention below.

Return token-span width with explicit end inclusion. Require whole 0 <= startToken <= endToken; width = end-start+(inclusiveEnd ? 1 : 0).1

Input fieldMeaning and unitsAccepted input
startTokenStart TokenRequired. Safe integer; minimum 0.
endTokenEnd TokenRequired. Safe integer.
inclusiveEndInclusive EndRequired. Boolean.
Output fieldInterpretationReturned shape
widthWidthRequired. Safe integer.
json
{
  "input": {
    "startToken": 2,
    "endToken": 5,
    "inclusiveEnd": false
  },
  "output": {
    "width": 3
  }
}

Limitations and assumptions

  • A coincident inclusive span has width one; token count and sentence bounds are not checked.
  • 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

Use the appropriate tokenizer, Unicode and annotation-format conventions and validate the complete text or tree for full linguistic processing.

References

  1. Calculation and input contract: computational-linguistics/parse-node-span-width — tool.io

Similar or alternative tools