Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rules appear not to be properly constructed #14

Open
doriantaylor opened this issue Oct 9, 2015 · 0 comments
Open

Rules appear not to be properly constructed #14

doriantaylor opened this issue Oct 9, 2015 · 0 comments

Comments

@doriantaylor
Copy link

Currently trying to get the OWL rules to be processed correctly. dct.n3 is just http://purl.org/dc/terms/ to use as input fodder.

pdb `which FuXi` -d  --input-format=n3   --rules  http://www.agfa.com/w3c/euler/rdfs-rules.n3 --rules http://www.agfa.com/w3c/euler/owl-rules.n3  /tmp/dct.n3

Running the FuXi script (bare and in the debugger) gives me a bunch of these:

/…/FuXi/Rete/CommandLine.py:443: SyntaxWarning: Integrity constraints (rules with empty heads) are not supported: Forall ?X ?A ( And(  ) :- And( owl:equivalentClass(?A owl:Nothing) ?A(?X) ) )

…and then crashes with a KeyError here: https://github.com/RDFLib/FuXi/blob/master/lib/Rete/Network.py#L360

I added the following condition in my test code:

        try:
            flhs = self.ruleStore.formulae[lhs]
            frhs = self.ruleStore.formulae[rhs]
        except KeyError as e:
            import warnings
            warnings.warn("Could not find rule %s in rule store" % rule,
                SyntaxWarning, 2)
            raise e

This spits out the offending rule as something like:

(Pdb) p rule
Forall _:N58f3fe0d6efa485eb833f4518991fa8b ?X _:N0cdcf914557f4059bf7c5d114e004be3 ?M ( Exists _:N58f3fe0d6efa485eb833f4518991fa8b _:N58e667762cb3452bb0330582592477e4 _:N43a8f967776a40208352e3912c6e1b02 _:N0cdcf914557f4059bf7c5d114e004be3 ( And( notItem(rdf:nil N58e667762cb3452bb0330582592477e4) rdf:first(rdf:nil N58e667762cb3452bb0330582592477e4) rdf:rest(rdf:nil N58f3fe0d6efa485eb833f4518991fa8b) rdf:first(N58f3fe0d6efa485eb833f4518991fa8b N43a8f967776a40208352e3912c6e1b02) rdf:rest(N58f3fe0d6efa485eb833f4518991fa8b N0cdcf914557f4059bf7c5d114e004be3) rdf:first(N0cdcf914557f4059bf7c5d114e004be3 1) rdf:rest(N0cdcf914557f4059bf7c5d114e004be3 rdf:nil) ) ) :- )

That smiley-face looking construct at the tail of the rule is, from my reading, a syntax error in RIF. Likewise is And( ) in the SyntaxWarning above. If we inspect the rule's body:

(Pdb) p rule.formula.body
And(  )
(Pdb) p rule.formula.body.__dict__
{'nsMgr': <rdflib.namespace.NamespaceManager object at 0x98fcdcc>, 'nsDict': {}, 'naf': False, 'formulae': []}

My tentative conclusion is that something in the process is generating these illegal empty And( ) constructs. I have a hunch that it has something to do with the fact that certain terms evaluate to False, as I found in issue #13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant