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.

authorityspoke.io.readers.read_fact(record)

Construct a Fact after loading a dict from JSON.

Parameters

record (Dict[str, Union[Dict[str, Union[str, bool]], Sequence[Any], str, bool]]) – parameter values to pass to FactSchema.

Return type

Fact

Returns

a Fact, with optional mentioned factors

authorityspoke.io.readers.read_factor(record, client=None, **kwargs)

Turn fields from JSON into a Factor object.

Parameters
Return type

Factor

authorityspoke.io.readers.read_factors(record, client=None, **kwargs)

Turn fields from JSON into a Factor object.

Parameters

record (List[Dict[str, Union[Dict[str, Union[str, bool]], Sequence[Any], str, bool]]]) – parameter values to pass to schema

Parame regime

to look up any Enactment references

Return type

Factor

authorityspoke.io.readers.read_procedure(record, client=None, many=False)

Turn fields from JSON into a Procedure object.

Parameters
  • record (Dict) – parameter values to pass to schema

  • many – whether to use the “many” form of the Marshmallow schema (whether there are multiple Procedures)

Parame regime

to look up any Enactment references

Return type

Procedure

authorityspoke.io.readers.read_holding(record, client=None)

Create new Holding object from simple datatypes from JSON input.

Will yield multiple items if exclusive: True is present in record.

Parameters
Return type

Holding

Returns

New Holding, and an updated dictionary with mentioned Factors as keys and their TextQuoteSelectors as values.

class authorityspoke.io.readers.HoldingsIndexed(holdings: List[authorityspoke.holdings.Holding], mentioned: authorityspoke.io.name_index.Mentioned, holding_anchors: List[List[anchorpoint.textselectors.TextQuoteSelector]])

Lists Holding objects with corresponding text selectors.

holdings: List[authorityspoke.holdings.Holding]

Alias for field number 0

mentioned: authorityspoke.io.name_index.Mentioned

Alias for field number 1

holding_anchors: List[List[anchorpoint.textselectors.TextQuoteSelector]]

Alias for field number 2

authorityspoke.io.readers.read_holdings_with_index(record, client=None, many=True, enactment_index=None)

Load a list of Holdingss from JSON, with “mentioned” index.

Return type

HoldingsIndexed

authorityspoke.io.readers.read_holdings_with_anchors(record, client=None, many=True)

Load a list of Holdings from JSON, with text links.

Parameters
Return type

AnchoredHoldings

Returns

a namedtuple listing Holding objects with a list matching Holdings to selectors and an index matching Factors to selectors.

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[Dict[str, Union[str, List[Union[str, Dict[str, str]]]]]], str, bool]], str, bool]]]) – a list of dicts representing holdings, in the JSON input format

Parame regime

A collection of Jurisdictions and the Codes that have been enacted in each. Used for constructing Enactments referenced by Holdings.

Return type

List[Holding]

Returns

a list of Holding objects

authorityspoke.io.readers.read_decision(decision_dict)

Create and return one or more Opinion objects from a dict API response.

Relies on the JSON format from the Caselaw Access Project API.

This function is a more convenient way to call read_opinions with an entire case from the CAP API as a single parameter.

Parameters

decision_dict (Dict[str, Union[str, int, Sequence[Dict[str, str]]]]) – A dict created from a Caselaw Access Project API response.

Return type

Decision

authorityspoke.io.readers.read_rules_with_index(record, client=None, many=True)

Make Rule and “mentioned” index from dict of fields and Regime.

Return type

Tuple[List[Rule], Mentioned]

authorityspoke.io.readers.read_rule(record, client=None)

Make Rule from a dict of fields and a Regime.

Parameters
  • record (Dict) –

  • client (Optional[Client]) – Legislice client for downloading missing fields from record

Return type

Rule

Returns

iterator yielding Rules with the items from mentioned_entities as terms

authorityspoke.io.readers.read_rules(record, client=None)

Make Rules from a list of fields and a Regime.

Parameters
  • record (List[Dict]) –

  • client (Optional[Client]) – Legislice client for downloading missing fields from record

Return type

List[Rule]

Returns

iterator yielding Rules with the items from mentioned_entities as terms