Mercurial > code > home > repos > homeauto
diff service/mqtt_to_rdf/stmt_chunk.py @ 1661:00a5624d1d14
cleanups and optimizations
author | drewp@bigasterisk.com |
---|---|
date | Sun, 19 Sep 2021 16:51:51 -0700 |
parents | 31f7dab6a60b |
children | 1a7c1261302c |
line wrap: on
line diff
--- a/service/mqtt_to_rdf/stmt_chunk.py Sun Sep 19 15:39:37 2021 -0700 +++ b/service/mqtt_to_rdf/stmt_chunk.py Sun Sep 19 16:51:51 2021 -0700 @@ -8,8 +8,7 @@ from rdflib.term import BNode, Literal, Node, URIRef, Variable from candidate_binding import CandidateBinding -from inference_types import BindingUnknown, Inconsistent, Triple -from rdf_debug import graphDump +from inference_types import BindingUnknown, Inconsistent log = logging.getLogger('infer') @@ -20,13 +19,16 @@ @dataclass class Chunk: # rename this - """a statement, maybe with variables in it, except *the object can be an rdf list*. - This is done to optimize list comparisons (a lot) at the very minor expense of not - handling certain exotic cases, such as a branching list. + """A statement, maybe with variables in it, except *the subject or object + can be rdf lists*. This is done to optimize list comparisons (a lot) at the + very minor expense of not handling certain exotic cases, such as a branching + list. - Also the subject could be a list, e.g. for (?x ?y) math:sum ?z . + Example: (?x ?y) math:sum ?z . <-- this becomes one Chunk. - Also a function call in a rule is always contained in exactly one chunk. + A function call in a rule is always contained in exactly one chunk. + + https://www.w3.org/TeamSubmission/n3/#:~:text=Implementations%20may%20treat%20list%20as%20a%20data%20type """ # all immutable primary: ChunkPrimaryTriple @@ -71,7 +73,8 @@ def myMatches(self, g: 'ChunkedGraph') -> List['Chunk']: """Chunks from g where self, which may have BindableTerm wildcards, could match that chunk in g.""" out: List['Chunk'] = [] - log.debug(f'{INDENT*6} {self}.myMatches({g}') + if log.isEnabledFor(logging.DEBUG): + log.debug(f'{INDENT*6} {self}.myMatches({g}') for ch in g.allChunks(): if self.matches(ch): out.append(ch)