drepr.models.drepr#

Classes

DRepr(resources, preprocessing, attrs, ...)

EngineFormat(model, edges_optional, ...)

class EngineFormat(model: 'dict[str, Any]', edges_optional: 'list[bool]', resource_idmap: 'dict[str, int]', attribute_idmap: 'dict[str, int]', sm_node_idmap: 'dict[str, int]')[source]#

Bases: object

Parameters:
model: dict[str, Any]#
edges_optional: list[bool]#
resource_idmap: dict[str, int]#
attribute_idmap: dict[str, int]#
sm_node_idmap: dict[str, int]#
class DRepr(resources: 'list[Resource]', preprocessing: 'list[Preprocessing]', attrs: 'list[Attr]', aligns: 'list[Alignment]', sm: 'SemanticModel')[source]#

Bases: object

Parameters:
resources: list[drepr.models.resource.Resource]#
preprocessing: list[drepr.models.preprocessing.Preprocessing]#
attrs: list[drepr.models.attr.Attr]#
aligns: list[Union[drepr.models.align.RangeAlignment, drepr.models.align.ValueAlignment, drepr.models.align.IdenticalAlign, drepr.models.align.AutoAlignment]]#
sm: SemanticModel#
static parse(raw: dict) DRepr[source]#
Parameters:

raw (dict) –

Return type:

DRepr

static parse_from_file(fpath: Union[Path, str]) DRepr[source]#
Parameters:

fpath (Union[Path, str]) –

Return type:

DRepr

static empty() DRepr[source]#
Return type:

DRepr

static deserialize(raw: dict) DRepr[source]#
Parameters:

raw (dict) –

Return type:

DRepr

serialize() dict[source]#
Return type:

dict

assert_valid()[source]#

Perform a check to see if this D-REPR is valid. Raise AssertionError if this is not valid

to_lang_format(simplify: bool = True, use_json_path: bool = False) dict[source]#
Parameters:
  • simplify (bool) –

  • use_json_path (bool) –

Return type:

dict

to_lang_yml(simplify: bool = True, use_json_path: bool = False) str[source]#
Parameters:
  • simplify (bool) –

  • use_json_path (bool) –

Return type:

str

remove_resource(resource_id: str)[source]#
Parameters:

resource_id (str) –

get_resource_by_id(resource_id: str) Optional[Resource][source]#
Parameters:

resource_id (str) –

Return type:

Optional[Resource]

add_resource(resource: Resource)[source]#
Parameters:

resource (Resource) –

has_attr(attr_id: str) bool[source]#
Parameters:

attr_id (str) –

Return type:

bool

add_attr(attr: Attr)[source]#
Parameters:

attr (Attr) –

get_attr_index_by_id(attr_id: str) int[source]#
Parameters:

attr_id (str) –

Return type:

int

get_attr_by_id(attr_id: str) Attr[source]#
Parameters:

attr_id (str) –

Return type:

Attr

remove_attribute(attr_id: str, idx: Optional[int] = None)[source]#
Parameters:
update_attribute(attr_id: str, new_attr: Attr)[source]#
Parameters:
  • attr_id (str) –

  • new_attr (Attr) –