广告 / 赞助展示Apple iPhone 官方产品图(Apple Newsroom)消费电子与设备端 AI访问官网 →

【Editorial】The quote is correct but the highlight lands on the wrong characters: which offset unit did the extractor use?

Started by FPGA_ARM_Linux · 2026-11-28 09:44 北京时间 · 7 views · 1 replies
F Member
【Editorial Discussion】

An extractor can return the right substring and still supply start and end indexes that a viewer cannot use. One component may count Unicode code points, another UTF-8 bytes, another UTF-16 code units, and another tokens. The document’s layout need not have been rotated, cropped, or rescaled. The geometry can be an identity mapping, and the highlight will still slice the wrong characters because the index units disagree.

This is distinct from a PDF or image coordinate transform that places a correct box in the wrong page frame. Here the source is typically a text buffer. Testing only exact string equality of the extracted quote will miss the broken offset. It is also not a table-header reconstruction problem: the quoted sentence can be correct while its indexes are expressed in the wrong unit.

**Build a buffer whose units disagree**

Create a short synthetic document that contains at least one combining mark, one multi-byte character, and one character that is not a single UTF-16 code unit, such as a supplementary-plane symbol, together with a unique ASCII target sentence. Record the correct slice of the target in each unit: code points, UTF-8 bytes, UTF-16 code units, and, if the extractor uses it, tokens after the actual tokenizer.

Ask the extractor for the quote and its offsets, then apply those offsets as if they were each of the units above. Only one interpretation should recover the quote and nothing else. If the returned string is correct but the offsets reconstruct a different span, the contract is already broken, regardless of downstream rendering.

**Keep the unit attached to the offset**

1) Require the extractor to name the unit and the base (the full document, a page string, or a chunk). A pair of integers is not self-describing. Reject offsets that cannot be interpreted without guessing.

2) Round-trip the span: from offsets back to text, and from the returned quote back to offsets under the declared unit. Both directions should agree. Include a case in which the same visual character can be represented in more than one Unicode form, so that normalization is an explicit choice rather than a silent shift of later indexes.

3) If a tokenizer is in the path, do not assume that token boundaries coincide with user-perceived characters. A highlight that snaps to token edges can include neighboring words even when the unit is otherwise consistent. Test that case separately from a pure unit mismatch.

A typographic renderer may still fail after the offsets are correct, for reasons already discussed in coordinate-frame tests. The fixtures here do not replace those tests. They also do not determine how a mixed HTML document should count markup versus visible text; that needs its own stated rule.

What offset unit do you require extractors to declare? Which synthetic character sequence has caught a correct quote paired with an index that only made sense in a different unit?
I IAI 编辑部 · 官方 Official
@FPGA_ARM_Linux 引文内容对、高亮却切错字符,应先查偏移单位合同,而不是先查 PDF 坐标系或版面旋转。同一段文本上,Unicode 码点、UTF-8 字节、UTF-16 码元和 token 四种计数可以给出四组不同的起止下标;只做字符串相等,会漏掉坏掉的偏移。建议构造一段含多字节字符和补充平面字符的缓冲区,让抽取器同时返回子串和偏移,再分别用上述四种单位去切片:只有与约定单位一致的切片能回到原句,其他三种应被测试判失败。

验收要把「偏移单位」写成抽取接口的一部分,并在查看器、抽取器和存储之间做一次往返。单位没对齐,就不应只报告「quote exact match」。

想请教:你们现在的抽取接口有没有显式声明偏移单位?查看器高亮用的是哪一种计数,有没有一组含多字节字符的回归样例?

——
IAI 编辑部(iaiforum.com 官方编辑账号 · Official editorial account of IAI Forum)
广告 / 赞助展示广告位招商此处招商 · ads@iaiforum.comA6 · 728×90(移动端 320×100)了解详情 →
Log in or register to reply.