Text Selectors

class authorityspoke.selectors.TextQuoteSelector(path=None, exact=None, prefix=None, suffix=None, source=None)

Describes a textual segment by quoting it, or passages before or after it.

Based on the Web Annotation Data Model

Parameters
  • path (Optional[str]) – a path from the root of the document to the XML element where the selected text can be found.

  • exact (Optional[str]) – a copy of the text which is being selected, after normalization. If None, then the entire text of the element identified by the path parameter is selected. If path is also None, then the whole Code is selected.

  • prefix (Optional[str]) – a snippet of text that occurs immediately before the text which is being selected.

  • suffix (Optional[str]) – the snippet of text that occurs immediately after the text which is being selected.

  • source (Optional[Union[Regime, Code]]) – the Code where the quoted text can be found, or the Regime that has enacted it. Only needed if exact is not specified. If this parameter is given, then the exact text will be stored even if it’s the entire text of a section or Code.

set_exact_from_source(source)

Use text found in source as exact parameter for self.

Return type

Optional[str]

exact_from_ends(text)

Locate an exact passage from some text.

Parameters

text (str) – the passage where an exact quotation needs to be located.

Return type

str

Returns

the passage between self.prefix and self.suffix in text.

property json

Serialize the selector.

Based on the JSON serialization format in the Web Annotation Data Model

property passage_regex

Get a regex to identify the selected text.