Loaders
¶
Functions to load JSON or XML files for conversion into authorityspoke objects.
Will usually hand off data to the io.readers module to create authorityspoke objects.
Create a new
Code
from an XML filepath.Defers parsing of the XML until later, which makes “read” in the function name misleading.
- Parameters
filename (
Optional
[str
]) – Name of the XML file representing theCode
. Ignored if filepath is given.directory (
Optional
[Path
]) – Directory where the XML file can be found. Ignored if filepath is given.filepath (
Optional
[Path
]) – Complete path to the XML file representing theCode
, including filename.
- Return type
- Returns
new
Code
object that can be used to parse the XML to find text ofEnactment
s.
Load a list of
Holding
s from JSON.- Parameters
filename (
Optional
[str
]) – the name of the JSON file to look in forRule
data in the format that listsmentioned_factors
followed 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.mentioned (
Optional
[List
[Factor
]]) – A list ofFactor
s that the method needs to expect to find in theOpinion
’s holdings, but that won’t be provided within the JSON, if any.report_mentioned (
bool
) –
- Parame regime
- Return type
Union
[List
[Holding
],Tuple
[List
[Holding
],Dict
[Factor
,List
[TextQuoteSelector
]]]]- Returns
a list of
Rule
s from a JSON file in theexample_data/holdings
subdirectory, from a JSON file.
Create and return one or more
Opinion
objects from JSON.Relies on the JSON format from the Caselaw Access Project API.
- Parameters
directory (
Optional
[Path
]) – The directory where the input JSON file is located.filepath (
Optional
[Path
]) – Complete path to the JSON file representing theOpinion
, including filename.lead_only (
bool
) – If True, returns a singleOpinion
object, otherwise returns an iterator that yields everyOpinion
in the case.as_generator (
bool
) – if True, returns a generator that yields all opinions meeting the query.
- Return type