sentence

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package sentence decides what prose a reference binds to (docs/SPEC.md §18).

A reference in running text binds to its enclosing sentence. `.`, `!`, or `?` ends a sentence only when whitespace follows and then an uppercase letter, a digit, a quote or backtick, or an opening bracket — or the text ends. So "v1.2 and", "Fig. 3" and "e.g. this" do not split, and a short fixed list of abbreviations (Abbreviations) and a run of three or more dots never end one either. Inside a list item or a table cell it binds to the whole item or cell. The markdown extractor hands Bind a whole paragraph, joined, so a sentence wrapped across lines is one sentence.

Two references in one sentence share one ack because they share one sentence hash. This is the unit a reviewer approves, so the rule has to be boring and stable: an ack must survive a paragraph moving, re-wrapping, or re-spacing, and must be invalidated when the sentence is rewritten. Runs of whitespace in the result are collapsed to one space for that reason.

Index

Constants

View Source
const Terminators = ".!?"

Terminators end a sentence when followed by whitespace or end of text.

Variables

View Source
var Abbreviations = map[string]bool{
	"e.g.": true, "i.e.": true, "etc.": true, "vs.": true, "cf.": true, "viz.": true,
	"fig.": true, "no.": true, "dr.": true, "mr.": true, "mrs.": true, "ms.": true,
	"st.": true, "u.s.": true, "u.k.": true,
}

Abbreviations never end a sentence. The list is short, English, and fixed on purpose: it covers what technical prose uses, and a term not on it splits as before, so the list can only remove false splits. Compared lowercased.

Functions

func Bind

func Bind(line string, col int) string

Bind returns the sentence, list item, or table cell of line that contains byte offset col. If col is out of range the whole line is returned so a caller with an imprecise column still gets a sensible binding.

func Split

func Split(text string) []string

Split returns every sentence in text, in order, trimmed and non-empty. Line breaks always split. Used by tests and by tools that count sentences.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL