Readers
Converting simple structured data from XML or JSON into authorityspoke objects.
These functions will usually be called by functions from the io.loaders module after they import some data from a file.
- class authorityspoke.io.readers.HoldingsIndexed(holdings: List[Holding], mentioned: Mentioned, holding_anchors: List[List[TextQuoteSelector]])
Lists
Holdingobjects with corresponding text selectors.-
holding_anchors:
List[List[TextQuoteSelector]] Alias for field number 2
-
holding_anchors:
- authorityspoke.io.readers.collect_anchors_from_index(object_index, field_name)
Get text anchors out of an index of terms or enactments.
- authorityspoke.io.readers.read_holdings_with_anchors(record, client=None)
Load a list of Holdings from JSON, with text links.
- Parameters:
record (
Dict[str,Union[List[Dict[str,Union[Dict[str,Union[Dict[str,Sequence[Dict[str,Union[Dict[str,Union[str,bool]],Sequence[Any],str,bool]]]],Sequence[RawEnactment],str,bool]],str,bool]]],List[Union[str,Dict[str,str]]]]]) – a list of dicts representing holdings, in the JSON input formatclient (
Optional[Client]) – Legislice client for downloading missing fields from record
- Return type:
- Returns:
a namedtuple listing
Holdingobjects with a list matchingHoldings to selectors and an index matchingFactors to selectors.
- authorityspoke.io.readers.expand_factor(record, factor_index)
Expand fields of Factor from index of mentioned factors.
- authorityspoke.io.readers.expand_names(record, factor_index)
Expand a list of names into a list of factors.
- authorityspoke.io.readers.expand_enactments(record, enactment_index)
Expand a list of enactments into a list of dicts.
- Parameters:
record (
List[Union[str,RawEnactment]]) – a list of enactments, either as strings or dictsenactment_index (
Mentioned) – a dict of names to enactments
- Return type:
- Returns:
a list of dicts representing enactments
- authorityspoke.io.readers.walk_tree_and_expand(obj, mentioned, ignore=())
Traverse tree of dicts and lists, and modify each node.
- authorityspoke.io.readers.expand_holding(record, factor_index, enactment_index)
Expand one holding from index of expanded terms and enactments.
- authorityspoke.io.readers.expand_holdings(record, factor_index, enactment_index)
Expand holdings from index of expanded terms and enactments.
- authorityspoke.io.readers.extract_anchors_from_holding_record(record, client=None)
Load a list of Holdings from JSON, with text links.
- Parameters:
record (
List[Dict[str,Union[Dict[str,Union[Dict[str,Sequence[Dict[str,Union[Dict[str,Union[str,bool]],Sequence[Any],str,bool]]]],Sequence[RawEnactment],str,bool]],str,bool]]]) – a list of dicts representing holdings, in the JSON input formatclient (
Optional[Client]) – Legislice client for downloading missing fields from record
- Return type:
Tuple[List[Holding],List[EnactmentWithAnchors],List[TermWithAnchors],List[Dict[str,str]]]- Returns:
a tuple of four objects containing holdings, terms, enactments, and anchors.
- authorityspoke.io.readers.read_holdings(record, client=None)
Load a list of
Holdingss from JSON.- Parameters:
record (
List[Dict[str,Union[Dict[str,Union[Dict[str,Sequence[Dict[str,Union[Dict[str,Union[str,bool]],Sequence[Any],str,bool]]]],Sequence[RawEnactment],str,bool]],str,bool]]]) – a list of dicts representing holdings, in the JSON input format- Parame regime:
A collection of
Jurisdictions and theCodes that have been enacted in each. Used for constructingEnactments referenced byHoldings.- Return type:
- Returns:
a list of
Holdingobjects
- authorityspoke.io.readers.read_decision(decision)
Create and return a
Decisionfrom a dict API response.Relies on the JSON format from the Caselaw Access Project API.
- Parameters:
decision_dict – A dict created from a Caselaw Access Project API response.
- Return type: