aboutsummaryrefslogtreecommitdiffstats
path: root/bsie/base/extractor.py
diff options
context:
space:
mode:
Diffstat (limited to 'bsie/base/extractor.py')
-rw-r--r--bsie/base/extractor.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/bsie/base/extractor.py b/bsie/base/extractor.py
index 678dcec..c44021b 100644
--- a/bsie/base/extractor.py
+++ b/bsie/base/extractor.py
@@ -9,8 +9,6 @@ import abc
import typing
# bsie imports
-from bsie.utils import node
-from bsie.utils.bsfs import schema as _schema, typename
from bsie.utils import bsfs, node, ns
# exports
@@ -58,10 +56,10 @@ class Extractor(abc.ABC):
CONTENT_READER: typing.Optional[str] = None
# extractor schema.
- schema: _schema.Schema
+ _schema: bsfs.schema.Schema
- def __init__(self, schema: _schema.Schema):
- self.schema = schema
+ def __init__(self, schema: bsfs.schema.Schema):
+ self._schema = schema
def __str__(self) -> str:
return bsfs.typename(self)
@@ -77,7 +75,14 @@ class Extractor(abc.ABC):
def __hash__(self) -> int:
return hash((type(self), self.CONTENT_READER, self.schema))
- def predicates(self) -> typing.Iterator[_schema.Predicate]:
+ @property
+ def schema(self) -> bsfs.schema.Schema:
+ """Return the extractor's schema."""
+ return self._schema
+
+ @property
+ def principals(self) -> typing.Iterator[bsfs.schema.Predicate]:
+ """Return the principal predicates, i.e., relations from/to the extraction subject."""
ent = self.schema.node(ns.bsfs.Entity)
return (
pred
@@ -91,8 +96,8 @@ class Extractor(abc.ABC):
self,
subject: node.Node,
content: typing.Any,
- predicates: typing.Iterable[_schema.Predicate],
- ) -> typing.Iterator[typing.Tuple[node.Node, _schema.Predicate, typing.Any]]:
+ principals: typing.Iterable[bsfs.schema.Predicate],
+ ) -> typing.Iterator[typing.Tuple[node.Node, bsfs.schema.Predicate, typing.Any]]:
"""Return (node, predicate, value) triples."""
## EOF ##