Stable Occurrence Numbering

Assign stable one-based occurrence numbers independently for each exact supplied string.

Description

Assign stable one-based occurrence numbers independently for each exact supplied string.

Occurrence numbering labels the first, second and later appearance of each value. The number is local to that value rather than a global rank.

When to use this tool

Assign stable one-based occurrence numbers independently for each exact supplied string.

  • Prepare the supplied values fields for this operation.
  • Compare the complete example with the representation used by your own input before carrying the result into another step.

How to use the tool and how it works

  1. Enter values. Use the exact text syntax, units and index conventions explained below.
  2. Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
  3. Read result.occurrenceNumbers. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.

Maintain a running count for every value and return the incremented count at each source position, starting each value at one.1

Input fieldMeaning and representationAccepted input
valuesvalues.At most 128 strings, each at most 128 UTF-16 code units
Output fieldInterpretation
resultObject containing the named outputs below.
result.occurrenceNumbersThe occurrence numbers list in the ordering and representation described above.
json
{
  "input": {
    "values": [
      "a",
      "b",
      "a"
    ]
  },
  "output": {
    "result": {
      "occurrenceNumbers": [
        1,
        1,
        2
      ]
    }
  }
}

Limitations and assumptions

  • The output remains aligned with the original list. Equality is exact; the tool does not sort values, group neighboring runs or provide statistical ranks.
  • Every declared top-level field is required and unexpected fields are rejected. Numeric inputs must be finite; ordinary text fields are bounded to 8,192 UTF-16 code units, with tighter operation-specific limits where stated.
  • Ordinary string lists have at most 128 entries of at most 128 code units each; numeric lists and matrices have separate bounded size checks. Nonfinite results and excessively large serialized outputs are rejected.
  • Indexes are zero-based and spans have an exclusive end unless explicitly stated otherwise. A valid false, null or empty-list result is distinct from malformed input.

Alternative or Complementary methods

Use explicit source-index maps when rearranging data or planning missing-value fills. Keep row-major coordinates, cyclic indexes and one-based occurrence numbers distinct, and inspect null donor positions before copying values.

References

  1. Tool behavior and example: Stable Occurrence Numbering — tool.io

Similar or alternative tools

  • Occurrence Index Buckets

    Bucket occurrence indexes by exact string value in first-occurrence order without losing duplicates.

  • Adjacent Change Indexes

    Return indexes whose value differs from the previous supplied string, not CSS change hints or a value transform.

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