Loaders

Load a list of Example data from JSON represented records in the Prodigy format.

json_to_examples(data)

Show source code in recon/loaders.py
44
45
46
47
48
49
50
51
52
53
def json_to_examples(data: List[Dict[str, Any]]) -> List[Example]:
    """Convert List of Dicts to List of typed Examples

    Args:
        data (List[Dict[str, Any]]): Input List of Dicts to convert

    Returns:
        List[Example]: List of typed Examples
    """
    return [Example(**example) for example in data]

Convert List of Dicts to List of typed Examples

Parameters

Name Type Description Default
data List[Dict[str, Any]] Input List of Dicts to convert required

Returns

Type Description
List[recon.types.Example] List[Example]: List of typed Examples

read_json(path)

Show source code in recon/loaders.py
30
31
32
33
34
35
36
37
38
39
40
41
def read_json(path: Path) -> List[Example]:
    """Read annotations in JSON file format

    Args:
        path (Path): Path to data

    Returns:
        List[Example]: List of examples
    """
    data = srsly.read_jsonl(path)
    examples = json_to_examples(data)
    return examples

Read annotations in JSON file format

Parameters

Name Type Description Default
path Path Path to data required

Returns

Type Description
List[recon.types.Example] List[Example]: List of examples

read_jsonl(path)

Show source code in recon/loaders.py
16
17
18
19
20
21
22
23
24
25
26
27
def read_jsonl(path: Path) -> List[Example]:
    """Read annotations in JSONL file format

    Args:
        path (Path): Path to data

    Returns:
        List[Example]: List of examples
    """
    data = srsly.read_jsonl(path)
    examples = json_to_examples(data)
    return examples

Read annotations in JSONL file format

Parameters

Name Type Description Default
path Path Path to data required

Returns

Type Description
List[recon.types.Example] List[Example]: List of examples