Skip to content

yaml_ld.load_document.load_document

load_document(
    url,
    base=None,
    profile=None,
    requestProfile=None,
    options: BaseOptions = DEFAULT_BASE_OPTIONS,
) -> RemoteDocument

Load an *-LD document.

The document can be retrieved from local filesystem or from the Web.

yaml_ld.load_document.BaseOptions

Bases: BaseModel

Base options shared by all YAML-LD API methods.

base class-attribute instance-attribute

base: URI | None = None

The base IRI to use.

document_loader class-attribute instance-attribute

document_loader: Any = None

The document loader.

Examples

get_local_file.py
from pprint import pprint

import yaml_ld

pprint(yaml_ld.load_document('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 get_local_file.py
{'contentType': 'application/ld+yaml',
 'contextUrl': None,
 'document': {'$id': 'https://dbpedia.org/page/Pythagorean_theorem',
              '@context': ['https://json-ld.org/contexts/dollar-convenience.jsonld',
                           {'prov': 'http://www.w3.org/ns/prov#'},
                           {'+': 'https://math.namespace/add',
                            '=': 'https://math.namespace/equal',
                            'variable': 'https://variables.namespace/',
                            '²': 'https://math.namespace/squared'}],
              'prov:Entity': {'=': [{'+': [{'²': 'variable:a'},
                                           {'²': 'variable:b'}]},
                                    {'²': 'variable:c'}]}},
 'documentUrl': 'pythagorean-theorem.yamlld'}