|
31 | 31 | import deap.base |
32 | 32 | import deap.tools |
33 | 33 | import numpy as np |
| 34 | +from rdflib import BNode |
34 | 35 | from rdflib import Literal |
35 | 36 | from rdflib import URIRef |
36 | 37 | from rdflib import Variable |
@@ -483,6 +484,10 @@ def mutate_fix_var_filter(item_counts): |
483 | 484 | i |
484 | 485 | ) |
485 | 486 | del item_counts[i] |
| 487 | + if isinstance(i, BNode): |
| 488 | + # make sure that BNodes stay variables |
| 489 | + logger.info('removed BNode from mutate_fix_var') |
| 490 | + del item_counts[i] |
486 | 491 |
|
487 | 492 |
|
488 | 493 | @exception_stack_catcher |
@@ -550,7 +555,7 @@ def mutate_simplify_pattern(gp): |
550 | 555 | logger.debug('simplifying pattern\n%s', gp.to_sparql_select_query()) |
551 | 556 |
|
552 | 557 | # remove parallel variable edges (single variables only) |
553 | | - # e.g., [ :x, ?v1 ?y . :x ?v2 ?y. ] |
| 558 | + # e.g., [ :x ?v1 ?y . :x ?v2 ?y. ] |
554 | 559 | identifier_counts = gp.identifier_counts() |
555 | 560 | edges = gp.edges |
556 | 561 | edge_vars = [edge for edge in edges if isinstance(edge, Variable)] |
@@ -578,7 +583,6 @@ def mutate_simplify_pattern(gp): |
578 | 583 |
|
579 | 584 | # remove unrestricting leaf edges (single occurring vars only) and leaves |
580 | 585 | # behind fixed nodes |
581 | | - # FIXME: BNodes aren't fixed nodes |
582 | 586 | # more explicit: such edges are |
583 | 587 | # - single occurrence edge vars with a single occ gen var node, |
584 | 588 | # so (x, ?vp, ?vn) or (?vn, ?vp, x) |
@@ -616,6 +620,7 @@ def mutate_simplify_pattern(gp): |
616 | 620 | # TODO: maybe remove disconnected components (relevance in reality?) |
617 | 621 |
|
618 | 622 | if len(gp) < 1: |
| 623 | + # for example: ?s ?v1 ?v2 . |
619 | 624 | logger.info( |
620 | 625 | 'simplification of the following pattern resulted in empty pattern,' |
621 | 626 | ' returning original pattern:\n%s', |
|
0 commit comments