Skip to content

mapping

Mapping filter strategy.

MappingStrategy

Strategy for a mapping.

The mapping strategy simply adds more prefixes and triples to the prefixes and triples fields in the session such that they are available for other strategies, like function strategies that convert between data models.

Nothing is returned to avoid deleting existing mappings.

Registers strategies:

  • ("mappingType", "triples")
Source code in oteapi/strategies/mapping/mapping.py
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
@dataclass
class MappingStrategy:
    """Strategy for a mapping.

    The mapping strategy simply adds more prefixes and triples to the
    `prefixes` and `triples` fields in the session such that they are
    available for other strategies, like function strategies that convert
    between data models.

    Nothing is returned to avoid deleting existing mappings.

    **Registers strategies**:

    - `("mappingType", "triples")`

    """

    mapping_config: MappingConfig

    def initialize(self) -> MappingStrategyConfig:
        """Initialize strategy."""

        return MappingStrategyConfig(
            prefixes=self.mapping_config.prefixes, triples=self.mapping_config.triples
        )

    def get(self) -> AttrDict:
        """Execute strategy and return a dictionary."""
        return AttrDict()

mapping_config: MappingConfig instance-attribute

get()

Execute strategy and return a dictionary.

Source code in oteapi/strategies/mapping/mapping.py
52
53
54
def get(self) -> AttrDict:
    """Execute strategy and return a dictionary."""
    return AttrDict()

initialize()

Initialize strategy.

Source code in oteapi/strategies/mapping/mapping.py
45
46
47
48
49
50
def initialize(self) -> MappingStrategyConfig:
    """Initialize strategy."""

    return MappingStrategyConfig(
        prefixes=self.mapping_config.prefixes, triples=self.mapping_config.triples
    )

MappingStrategyConfig

Bases: AttrDict

AttrDict model for mappings.

Source code in oteapi/strategies/mapping/mapping.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class MappingStrategyConfig(AttrDict):
    """AttrDict model for mappings."""

    prefixes: Dict[str, str] = Field(
        ...,
        description=(
            "Dictionary of shortnames that expands to an IRI "
            "given as local value/IRI-expansion-pairs."
        ),
    )
    triples: List[RDFTriple] = Field(
        ...,
        description="List of semantic triples given as (subject, predicate, object).",
    )

prefixes: Dict[str, str] = Field(..., description='Dictionary of shortnames that expands to an IRI given as local value/IRI-expansion-pairs.') class-attribute instance-attribute

triples: List[RDFTriple] = Field(..., description='List of semantic triples given as (subject, predicate, object).') class-attribute instance-attribute