TECHNOLOGY

ICU normalization and text spans: preserve annotation coordinates after edits

In this article
THE QUICK TAKE

Equivalent normalized text can have different coordinates; edit lengths help map revisions but do not store the original replacement text.

Text equality and position equality differ

A normalizer can change the sequence of code points while producing the representation intended by a dataset policy. Existing entity spans, answer spans or citation boundaries still refer to the original sequence. Copying their numeric offsets into the transformed text can silently target different content.

Treat normalized text as a derivative revision with its own annotation coordinate system. Preserve the original where the workflow requires comparison. A valid normalization result does not by itself establish valid answer extraction or named-entity labels on that result.

Declare the indexing unit at every boundary

An offset can count bytes, code units or code points depending on the interface. ICU offers normalization functionality through its documented APIs, including UTF-8 processing paths. A consumer in another language may index its strings differently.

Name the unit in the annotation schema and inspect conversions between components. A proposed fixture should include text whose encoded lengths differ, alongside a known labeled span. Merely checking that offsets remain inside the new string’s length misses many alignment errors.

Edits records lengths rather than replacement text

ICU’s Edits class records unchanged segments and replacement lengths. It supports fine and coarse iteration, with coarse handling merging adjacent changes. This is useful for relating source and destination ranges under the operations that produce the edit record.

It is not a backup of deleted content. Keep source text separately if exact reconstruction is required. Also inspect whether the chosen transformation API actually populates the edit object; allocating an Edits instance beside an unrelated string replacement does not create a mapping automatically.

Changed regions may need a review policy

An annotation that crosses a changed region can require more than shifting its start position by an overall length delta. Replacement can contract or expand content inside the span. Several original positions may no longer correspond to distinct destination positions.

Define whether such labels are remapped, regenerated or flagged for review. Keep the rule with the transformed dataset. Fine-grained edit tracking improves evidence, but does not determine the semantic validity of a label whose underlying text has changed.

Validate extracted spans, not just bounds

After transformation, compare the text selected by remapped annotations with the expected labeled content. Review boundary cases around combined characters, adjacent changes and annotations that include both changed and unchanged segments.

Preserve transformation settings, coordinate conventions and mapping revision with the output. This permits an alignment audit without asserting that normalization universally preserves every annotation or that an overall character-count adjustment is sufficient.

Primary references

ICU normalization guide.

ICU Normalizer2 API.

ICU Edits API.

Related explanations: Text provenance; Sequence representations.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles