DRM semantic entities
Optional module
Install: included in
pip install cvcdocdb(no extra dependencies).Import:
from cvcdocdb.drm_entities import IndividuPadro, LlocPadro, ...—import cvcdocdbdoes not import this module.from cvcdocdb import IndividuPadrostill works but emits aDeprecationWarning; it will be removed in the next major version.
The cvcdocdb.drm_entities module contains the domain-specific node types
of the Document Representation Model (people, places, cultural documents,
layouts…) built on top of cvcdocdb.base. These classes add
validation, default labels, and automatic materialisation of properties into
graph structures.
Atribut (the Valor node that materialises be_value_properties) is
part of the core and lives in cvcdocdb.base; it is re-exported here.
Example
from cvcdocdb import NetworkXGraph
from cvcdocdb.drm_entities import IndividuPadro
graph = NetworkXGraph()
person = IndividuPadro(pk=123, nom="Joan", cognom1="Miró", cognom2="Ferrer")
graph.insertNode(person) # nom/cognom1/cognom2 become Valor nodes
graph.close()
The entities work the same on every backend (NetworkXGraph, Neo4jGraph,
MemgraphGraph).
API
Semantic entity definitions for the DRM graph model (optional module).
This module is optional: import cvcdocdb doesn’t import it. Import
the entities from here, e.g. from cvcdocdb.drm_entities import
IndividuPadro. (from cvcdocdb import IndividuPadro still works but is
deprecated and will be removed in the next major version.)
This module defines domain-specific node types such as Individu, Lloc
and DocumentCultural. These classes build on cvcdocdb.base to provide
validation, default labels, and automatic relationship materialisation.
Conceptually, the module is organised around two families of entities:
The concrete classes model people, places, cultural documents, layouts and other semantic concepts used throughout the tutorials and examples.
- cvcdocdb.drm_entities.assert_on_properties(args, properties, entity, accepted_types=(<class 'str'>, <class 'int'>, <class 'dict'>, <class 'bool'>))[source]
Precondition on node insertion: asserts if a specified property isn’t an instance.
- Parameters:
- Returns:
bool, message: str). On success, message is “OKAY”. On failure, message describes the missing property.
- Return type:
A tuple (success
- class cvcdocdb.drm_entities.Individu(ignore_assertion=False, **kwargs)[source]
Bases:
NodeA person entity with a primary key.
Base class for all person entities. Automatically appends “Individu” to alternative labels. Subclasses can define
be_value_propertiesto automatically materialise string attributes asAtributnodes.- Parameters:
- class cvcdocdb.drm_entities.IndividuPadro(ignore_assertion=False, **kwargs)[source]
Bases:
IndividuA person entity with a name attribute.
Extends Individu with mandatory
nomproperty. Thenomandcognomattributes are automatically materialised asValornodes connected by typed edges.- Parameters:
pk – Primary key.
nom – Person’s first name (creates a Valor node).
cognom1 – First surname (creates a Valor node).
cognom2 – Second surname (creates a Valor node).
alternative_labels – Additional labels (appends “Individu”).
ignore_assertion (bool) – If True, skip mandatory property checks.
**kwargs (Any) – Additional node attributes.
- class cvcdocdb.drm_entities.IndividuFoto(ignore_assertion=False, **kwargs)[source]
Bases:
IndividuA person entity linked to a photograph.
Extends Individu with no additional value properties.
- Parameters:
- class cvcdocdb.drm_entities.Lloc(main_label='', ignore_assertion=False, **kwargs)[source]
Bases:
NodeA place entity with a primary key.
Base class for all place entities. Automatically appends “Lloc” to alternative labels.
- Parameters:
- class cvcdocdb.drm_entities.LlocPadro(main_label='', ignore_assertion=False, **kwargs)[source]
Bases:
LlocA location entity with a custom label.
Extends Lloc with default label “LlocPadro”.
- Parameters:
- class cvcdocdb.drm_entities.LlocFoto(main_label='', ignore_assertion=False, **kwargs)[source]
Bases:
LlocA location entity linked to a photograph.
Extends Lloc with default label “LlocFoto”.
- Parameters:
- class cvcdocdb.drm_entities.DocumentCultural(**kwargs)[source]
Bases:
NodeAn abstract base class for cultural documents.
This class should not be instantiated directly. Subclasses override
document_classto set the appropriate label. Automatically appends “DocumentCultural” to alternative labels.- Parameters:
kwargs (Any)
- document_class
The Cypher label for this document type. Defaults to “abstract_class”.
- class cvcdocdb.drm_entities.Fons(ignore_assertion=False, **kwargs)[source]
Bases:
DocumentCulturalA document collection (fonds) entity.
Extends DocumentCultural with label “Fons”. This is the root entity under which all other documents are hierarchically organised.
- Parameters:
- mandatory_properties = ('pk',)
- class cvcdocdb.drm_entities.ActaTemporal(ignore_assertion=False, **kwargs)[source]
Bases:
DocumentCulturalA temporary act/document entity.
Extends DocumentCultural with label “ActaTemporal”.
- Parameters:
- mandatory_properties = ('pk',)
- class cvcdocdb.drm_entities.EntitatAmbNom(ignore_assertion=False, **kwargs)[source]
Bases:
NodeA named entity with a
nomproperty.Extends Node with mandatory
pkandnomproperties.- Parameters:
- mandatory_properties = ('pk', 'nom')
- class cvcdocdb.drm_entities.IndividuAgregat(pk='', main_label='PersonaAgregat', ignore_assertion=False, **kwargs)[source]
Bases:
NodeAn aggregated person entity with configurable mandatory properties.
Extends Node with a configurable set of mandatory properties derived from a tuple or list of property names.
- Parameters:
- class cvcdocdb.drm_entities.Esdeventiment(ignore_assertion=False, **kwargs)[source]
Bases:
NodeAn event entity.
Extends Node with mandatory
pkproperty and label “Esdeveniment”.- Parameters:
- mandatory_properties = ('pk',)
- class cvcdocdb.drm_entities.Layout(**kwargs)[source]
Bases:
WeakNodeAn abstract base class for layout entities.
This class should not be instantiated directly. Subclasses override
main_labelto set the appropriate Cypher label. Automatically appends “layout” to alternative labels.- Parameters:
parent – The parent
Node.main_label – Primary Cypher label.
pk – Primary key.
alternative_labels – Additional labels (appends “layout”).
**kwargs (Any) – Additional node attributes passed to WeakNode.__init__.
- class cvcdocdb.drm_entities.RegioFisica(**kwargs)[source]
Bases:
LayoutA physical region entity with contours.
Extends Layout with mandatory
pkandcontoursproperties.- Parameters:
parent – The parent
Node.main_label – Primary Cypher label.
pk – Primary key.
contours – Region contour data.
alternative_labels – Additional labels (appends “layout”).
**kwargs (Any) – Additional node attributes passed to WeakNode.__init__.
- mandatory_properties = ('pk', 'contours')
- class cvcdocdb.drm_entities.OCRTranscript(**kwargs)[source]
Bases:
LayoutAn OCR transcript entity.
Extends Layout with a
main_labeland optionalpk. Automatically appends “semantic” to alternative labels.- Parameters:
parent – The parent
Node.main_label – Primary Cypher label.
pk – Primary key.
alternative_labels – Additional labels (appends “semantic”).
**kwargs (Any) – Additional node attributes passed to WeakNode.__init__.
- class cvcdocdb.drm_entities.Padro(ignore_assertion=False, **kwargs)[source]
Bases:
_DocumentCulturalBaseA padro document entity with a path property.
Extends _DocumentCulturalBase with mandatory
pkandrutaproperties.- Parameters:
- mandatory_properties = ('pk', 'ruta')
- class cvcdocdb.drm_entities.Fotografia(ignore_assertion=False, **kwargs)[source]
Bases:
_DocumentCulturalBaseA photograph entity.
Extends _DocumentCulturalBase with mandatory
pkproperty.- Parameters:
- mandatory_properties = ('pk',)