Loaders
Will usually hand off data to the io.readers module to create authorityspoke objects.
- authorityspoke.io.loaders.load_holdings(filename=None, directory=None, filepath=None)
Load list of records from YAML or JSON to create
Holdings with text selectors.- Parameters:
filename (
Optional[str]) – the name of the JSON file to look in forHoldingdata in the format that listsmentioned_factorsfollowed by a list of holdings.directory (
Optional[Path]) – the path of the directory containing the JSON file.filepath (
Optional[Path]) – Complete path to the XML file representing theCode, including filename.
- Return type:
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]]]- Returns:
a list of
Holdings from a JSON file in theexample_data/holdingssubdirectory, from a JSON file.
- authorityspoke.io.loaders.read_holdings_from_file(filename=None, directory=None, filepath=None, client=None)
Read holdings from a file.
- Parameters:
- Return type:
- authorityspoke.io.loaders.read_anchored_holdings_from_file(filename=None, directory=None, filepath=None, client=None)
Read holdings from file, with Opinion text anchors for holdings and factors.
This function can accept a file containing
authorityspoke.holdings.Holdingsummaries in the YAML format that may contain abbreviations and expandable named entities.In the example below, a
FakeClientis used to add fields toEnactments in the Holding objects, to avoid using the network or making API calls. The realLegisClientclass would also have worked (with an appropriate API key). :rtype:AnchoredHoldings>>> from authorityspoke.io.fake_enactments import FakeClient >>> fake_client = FakeClient.from_file("usc.json") >>> filepath = filepaths.make_filepath(filename="holding_mazza_alaluf.yaml") >>> with open(filepath, "r") as f: ... yaml.safe_load(f) [{'inputs': [{'type': 'fact', 'content': "{Mazza-Alaluf} used Mazza-Alaluf's business {Turismo Costa Brava} to commit the New York offense of engaging in the business of receiving money for transmission or transmitting the same, without a license therefor"}], 'outputs': [{'type': 'fact', 'content': 'Mazza-Alaluf operated Turismo Costa Brava without an appropriate money transmitting license in a State where such operation was punishable as a misdemeanor or a felony under State law', 'anchors': {'quotes': [{'exact': "we conclude that sufficient evidence supports Mazza-Alaluf's convictions under 18 U.S.C. § 1960(b)(1)(A) for conspiring to operate and operating a money transmitting business without appropriate state licenses."}]}, 'name': 'operated without license'}], 'enactments': [{'name': 'state money transmitting license provision', 'enactment': {'node': '/us/usc/t18/s1960/b/1'}, 'anchors': {'quotes': ['state money transmitting licenses, see |18 U.S.C. § 1960(b)(1)(A)|']}, 'selection': {'quotes': [{'exact': 'is operated without an appropriate money transmitting license in a State where such operation is punishable as a misdemeanor or a felony under State law, whether or not the defendant knew that the operation was required to be licensed or that the operation was so punishable'}]}}], 'universal': True}, {'inputs': ['operated without license', {'type': 'fact', 'content': 'Mazza-Alaluf operated Turismo Costa Brava as a business', 'anchors': {'quotes': 'Mazza-Alaluf does not contest that he owned and managed Turismo'}}, {'type': 'fact', 'content': 'Turismo Costa Brava was a money transmitting business', 'anchors': {'quotes': 'record evidence that Turismo conducted substantial money transmitting business in the three states'}}], 'despite': [{'type': 'fact', 'content': 'Turismo Costa Brava was a domestic financial institution', 'truth': False, 'anchors': {'quotes': 'without respect to whether or not Turismo was a "domestic financial institution"'}}], 'outputs': [{'type': 'fact', 'content': 'Mazza-Alaluf committed the offense of conducting a money transmitting business without a license required by state law', 'anchors': {'quotes': 'a crime to operate a money transmitting business without appropriate state licenses,'}}], 'enactments': ['state money transmitting license provision'], 'enactments_despite': [{'enactment': {'node': '/us/usc/t31/s5312/b/1'}, 'anchors': {'quotes': ['§ 5312(b)(1) (defining "domestic financial institution")']}}], 'anchors': {'quotes': [{'prefix': 'Accordingly, we conclude that the', 'suffix': 'In any event'}]}, 'universal': True, 'mandatory': True}] >>> result = read_anchored_holdings_from_file(filepath=filepath, client=fake_client) >>> selection = result.get_term_anchors("the fact it was false that <Turismo Costa Brava> was a domestic financial institution") >>> selection.quotes[0].exact 'without respect to whether or not Turismo was a "domestic financial institution"' >>> print(result.holdings[0].holding.outputs[0]) the fact that <Mazza-Alaluf> operated <Turismo Costa Brava> without an appropriate money transmitting license in a State where such operation was punishable as a misdemeanor or a felony under State law
- authorityspoke.io.loaders.load_decision(filename=None, directory=None, filepath=None)
Load file containing a judicial decision with one or more opinions.
Relies on the JSON format from the Caselaw Access Project API.
- Parameters:
- Return type:
- authorityspoke.io.loaders.load_decision_as_reading(filename=None, directory=None, filepath=None)
Load file containing a judicial decision with one or more opinions.
Relies on the JSON format from the Caselaw Access Project API.