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

SWRL rules dont appear. #651

Closed
vChavezB opened this issue Dec 9, 2023 · 8 comments · Fixed by #654
Closed

SWRL rules dont appear. #651

vChavezB opened this issue Dec 9, 2023 · 8 comments · Fixed by #654

Comments

@vChavezB
Copy link
Contributor

vChavezB commented Dec 9, 2023

I am trying to generate the SWRL rules I declare in my ontology but they dont apper after I generate the project.

The rules section appears empty with just a the title "4.6 Rules" and a blue rectangle

grafik

Do you have an example ontology that is known to be working and I can use to check if its just on my side?

Here is an excerpt of how I declare my SWRL rules (generated with protege)

@prefix swrl: <http://www.w3.org/2003/11/swrl#> .
[ <http://swrl.stanford.edu/ontologies/3.3/swrla.owl#isRuleEnabled> "true"^^xsd:boolean ;
   rdfs:label "My rule" ;
   rdf:type swrl:Imp ;
   swrl:body [ rdf:type swrl:AtomList ;
               rdf:first [ rdf:type swrl:ClassAtom ;
                           swrl:classPredicate :ApplicationDataObject ;
                           swrl:argument1 :ao
                         ] ;
               rdf:rest [ rdf:type swrl:AtomList ;
                          rdf:first [ rdf:type swrl:DatavaluedPropertyAtom ;
                                      swrl:propertyPredicate :isProcessData ;
                                      swrl:argument1 :ao ;
                                      swrl:argument2 "true"^^xsd:boolean
                                    ] ;
                          rdf:rest rdf:nil
                        ]
             ] ;
   swrl:head [ rdf:type swrl:AtomList ;
               rdf:first [ rdf:type swrl:ClassAtom ;
                           swrl:classPredicate :ProcessDataObject ;
                           swrl:argument1 :ao
                         ] ;
               rdf:rest rdf:nil
             ]
 ] .
@vChavezB
Copy link
Contributor Author

vChavezB commented Dec 9, 2023

I debugged the app and I am not sure if swr rules are parsed

the XLST output for swr rules looks as this. In this example I added two rules to an ontology.

	<div id="swrlrules">
			<h2>SWRL rules</h2>
			<div id="d4e4498" class="entity">
				<h3>Rule #1
					<span class="backlink">back to 
						<a href="#toc">ToC</a>
					</span>
				</h3>
				<p>
					<a href="#d4e4288" title="http://datos.bne.es/def/C1001">Work</a>
					<sup title="class" class="type-c">c</sup>(?) -&gt; 
					<a href="#d4e4316" title="http://datos.bne.es/def/C1002">Expression</a>
					<sup title="class" class="type-c">c</sup>(?)
				</p>
			</div>
			<div id="d4e4558" class="entity">
				<h3>Rule #2
					<span class="backlink">back to 
						<a href="#toc">ToC</a>
					</span>
				</h3>
				<p>
					<a href="#d4e4288" title="http://datos.bne.es/def/C1001">Work</a>
					<sup title="class" class="type-c">c</sup>(?) -&gt; 
					<a href="#d4e4316" title="http://datos.bne.es/def/C1002">Expression</a>
					<sup title="class" class="type-c">c</sup>(?)
				</p>
			</div>
		</div>

So my guess is that the SWRL html parser is not implemented in widoco due to the fact that I was debugging and the id for the html div is different. I changed the id to swrlrules but the program crashes.

@vChavezB
Copy link
Contributor Author

vChavezB commented Dec 9, 2023

Ok I made a PR #652 perhaps you can check if it looks fine. The rules are now displayed. However as you see the first element is "null".

grafik

vChavezB added a commit to vChavezB/Widoco that referenced this issue Dec 9, 2023
The output of the XLST transformation for SWRL rules does not provide an hlist div element. Instead each rule is provide as a class entity. Fixes dgarijo#651
vChavezB added a commit to vChavezB/Widoco that referenced this issue Dec 10, 2023
The output of the XLST transformation for SWRL rules does not provide an hlist div element. Instead each rule is provide as a class entity. Fixes dgarijo#651
@vChavezB
Copy link
Contributor Author

vChavezB commented Dec 10, 2023

ok an update now the rules look much better with annotation from rdfs:comment and rdfs:label

grafik

this requires changing the xslt of swrl-rules in specific , havent made a PR as I hope this gets merged first :) #653

    <xsl:template match="swrl:Imp | rdf:Description[rdf:type[@rdf:resource = 'http://www.w3.org/2003/11/swrl#Imp']]">
        <div id="{generate-id()}" class="entity">
            <h3>
                <xsl:value-of select="concat('Rule #', count(preceding-sibling::swrl:Imp | preceding-sibling::rdf:Description[rdf:type[@rdf:resource = 'http://www.w3.org/2003/11/swrl#Imp']]) + 1, ' ', rdfs:label)" />
                <xsl:call-template name="get.backlink.to.top" />
            </h3>
            <p>
                <!-- Add rdfs:comment -->
                <xsl:if test="rdfs:comment">
                    <strong>Comment: </strong>
                    <xsl:value-of select="rdfs:comment" /><br/><br/>
                </xsl:if>
                <!-- Continue with the existing content -->
                <xsl:apply-templates select="swrl:body" />
                <xsl:text> -> </xsl:text>
                <xsl:apply-templates select="swrl:head" />
            </p>
        </div>
    </xsl:template>

@dgarijo
Copy link
Owner

dgarijo commented Dec 11, 2023

Thanks a lot. So far, I think no swrl rules were considered, as I did not have a use case for them (I may have simplified them from the XSLT output). I will need to review the PR, since in the develop branch I was considering other types of rules I had been asked to include (but not SWRL). This is a great addition!

@dgarijo
Copy link
Owner

dgarijo commented Dec 11, 2023

Just pls make sure you send your PRs to the right branch @vChavezB (see https://github.com/dgarijo/Widoco#contribution-guidelines)

@vChavezB
Copy link
Contributor Author

I read the code again and the xlst sources. So if I understand correctly the "rules" extraction uses annotations from owl Individuals or which type of rules does it parse.

<xsl:template name="get.rules">

I did not found a sample ontology that uses this transformation. This would be helpful to know as it was not clear to me. I will update the PR and refine it.

@dgarijo
Copy link
Owner

dgarijo commented Dec 11, 2023

@vChavezB sorry, the rules stuff I added is for very specific owl annotations for a specific project I am doing.

The SWRL module you added recovers the original SWRL annotations, and I think they should be added, but separately.
Please just ignore the module I did for annotations of rules and use a new one with the id you gave, as you were doing. Thanks in advance!

@dgarijo
Copy link
Owner

dgarijo commented Dec 31, 2023

This issue should now be closed and will be up in the next release See #654 for more info.
Thanks @vChavezB for your work!!

@dgarijo dgarijo closed this as completed Dec 31, 2023
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

Successfully merging a pull request may close this issue.

2 participants