Skip to content

yaml_ld.expand.expand

expand(
    document: JsonLdInput,
    options: ExpandOptions = DEFAULT_EXPAND_OPTIONS,
) -> list[JsonLdRecord]

Expand a *-LD document.

Converts all compact IRIs, keywords, and terms into their absolute IRI representations.

Example

expand.py
import yaml

import yaml_ld

print(yaml.dump(yaml_ld.expand('pythagorean-theorem.yamlld')))
pythagorean-theorem.yamlld
"@context":
  - https://json-ld.org/contexts/dollar-convenience.jsonld
  - prov: http://www.w3.org/ns/prov#
  - variable: https://variables.namespace/
    =: https://math.namespace/equal
    +: https://math.namespace/add
    ²: https://math.namespace/squared

$id: https://dbpedia.org/page/Pythagorean_theorem
prov:Entity:
  =:
    - +:
      - ²: variable:a
      - ²: variable:b
    - ²: variable:c
python expand.py
- '@id': https://dbpedia.org/page/Pythagorean_theorem
  http://www.w3.org/ns/prov#Entity:
  - https://math.namespace/equal:
    - https://math.namespace/add:
      - https://math.namespace/squared:
        - '@value': variable:a
      - https://math.namespace/squared:
        - '@value': variable:b
    - https://math.namespace/squared:
      - '@value': variable:c