Gitlab service upgraded. Please report any problems to dl_gitadmin@cs.lth.se

Commit 439a1d8e authored by Anders Nilsson's avatar Anders Nilsson

Can find some simple functional properties belonging to a class

parent 5016cb0f
......@@ -17,7 +17,10 @@ aspect DumpClasses {
pStream.print(getId());
pStream.print(" : "+getSuperClass().getId());
pStream.print(" ::= ");
Properties props = getFunctionalProperties();
for (int i=0; i<props.getNumProperty(); i++) {
pStream.print(props.getProperty(i).getId()+" ");
}
pStream.println(";");
}
}
\ No newline at end of file
......@@ -38,7 +38,11 @@ aspect MiscUtilities {
return false;
}
String ComplexElement.getId() {
syn lazy String Element.getId() {
return new String("Element has no ID");
}
eq ComplexElement.getId() {
if (hasRdfId()) {
for (int i=0; i<getNumAttribute(); i++) {
if (getAttribute(i) instanceof RdfId) {
......@@ -58,11 +62,11 @@ aspect MiscUtilities {
}
ComplexElement ComplexElement.getTopElement() {
ComplexElement e = this;
ASTNode e = this;
while (e != null && !(e instanceof RdfDeclaration)) {
e = (ComplexElement) e.getParent().getParent();
e = e.getParent();
}
return e;
return (ComplexElement) e;
}
}
......@@ -88,4 +92,15 @@ aspect RewriteClasses {
new List().add(oc));
}
}
rewrite RdfsDomain {
when (getNumAttribute()>0 && getAttribute(0) instanceof RdfResource)
to RdfsDomain {
Value value = getAttribute(0).getValue();
OwlClass oc = new OwlClass(new List().add(new RdfAbout(value)),
new List());
return new RdfsDomain(new List(),
new List().add(oc));
}
}
}
\ No newline at end of file
/* -*-Java-*- */
aspect Types {
syn lazy Class Class.getSuperClass();
syn lazy OClass OClass.getSuperClass();
eq OwlClassDecl.getSuperClass() {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i) instanceof RdfsSubClassOf) {
RdfsSubClassOf e = (RdfsSubClassOf) getElement(i);
if (e.getElement(0) instanceof Class) {
return ((Class) e.getElement(0)).decl();
if (e.getElement(0) instanceof OClass) {
return ((OClass) e.getElement(0)).decl();
}
}
}
......@@ -18,7 +18,7 @@ aspect Types {
return null;
}
syn lazy OwlClassDecl Class.decl();
syn lazy OwlClassDecl OClass.decl();
eq OwlClassDecl.decl() = this;
eq OwlClassUse.decl() {
ComplexElement top = getTopElement();
......@@ -44,7 +44,7 @@ aspect Types {
for (int i=0; i<l.getNumChild(); i++) {
OwlFunctionalProperty op = (OwlFunctionalProperty) l.getChild(i);
if (op.domainIncludes(this)) {
p.addElement(op);
p.addProperty(op);
}
}
return p;
......@@ -62,12 +62,29 @@ aspect Properties {
l.add(this);
}
boolean OwlFunctionalProperty.domainIncludes(Class clazz) {
boolean ASTNode.domainIncludes(OClass clazz) {
return false;
}
boolean OwlFunctionalProperty.domainIncludes(OClass clazz) {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i) instanceof RdfsDomain) {
// ((RdfsDomain) getElement(i)).
return ((RdfsDomain) getElement(i)).domainIncludes(clazz);
}
}
return false;
}
boolean RdfsDomain.domainIncludes(OClass clazz) {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i).domainIncludes(clazz)) {
return true;
}
}
return false;
}
boolean OClass.domainIncludes(OClass clazz) {
return getId().equals(clazz.getId());
}
}
\ No newline at end of file
......@@ -52,8 +52,8 @@ Value ::= <STRING_LITERAL>;
// Types generated by rewrite rules
abstract Class : ComplexElement;
OwlClassDecl : Class ::= <Id:String> ;
OwlClassUse : Class ::= <Id:String> ;
abstract OClass : ComplexElement;
OwlClassDecl : OClass ::= <Id:String> ;
OwlClassUse : OClass ::= <Id:String> ;
Properties ::= Element*;
\ No newline at end of file
Properties ::= Property:Element*;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment