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

should consider both prefix and baseiri when checking if a class is external #34

Open
FonyLi opened this issue Mar 30, 2017 · 1 comment

Comments

@FonyLi
Copy link

FonyLi commented Mar 30, 2017

Vowl marks all classes in SNOMED.owl as external. The reason is that vowl check it like this:

class ImportedChecker{
public void execute() { 
       //......
        vowlData.getEntityMap().values().forEach(abstractEntity -> {
		IRI entityIri = abstractEntity.getIri();
		if ( entityIri.toString().contains("http://owl2vowl.de#") )  {
			return;
		};

		if (ComparisonHelper.hasDifferentNameSpace(entityIri.toString(), loadedOntology, loadPath){
			addImportedAttribute(entityIri);
			}
		});
	}
}

Notice that ComparisonHelper.hasDifferentNameSpace(entityIri.toString(), loadedOntology, loadPath) only compares the class' name space with the base iri of ontology.

But from my understanding, besides base iri of ontology, the prefixes should be considered as well.

Say I have an ontology like this:

<?xml..>
<!DOCTYPE rdf:RDF [
    ...
    <!ENTITY somePrefix "http://bb.com/b.owl#" > //a prefix
    ...]
>
// a base
<rdf:RDF xmlns="http://aa.com/a.owl#"
     xml:base="http://aa.com/a.owl"
>

//a class whose name space is defined in xml:base of this ontoloyg
<owl:Class rdf:about="http://aa.com/a.owl#class_C">
        <rdfs:label xml:lang="en">class c</rdfs:label>
    </owl:Class>
//a class whose name space is defined in the prefix  of this ontoloyg
<owl:Class rdf:about="http://bb.com/b.owl#class_D">
        <rdfs:label xml:lang="en">class d</rdfs:label>
    </owl:Class>

Both class C and class D should be marked as normal class but not external class.
But our current vowl will mark class D as external, which from my understanding is not correct.

A possible solution is like:

public void execute() {
		......
		//read prefixes from ontology
		OWLDocumentFormat format = manager.getOntologyFormat(loadedOntology);
		OWLXMLDocumentFormat owlxmlFormat = new OWLXMLDocumentFormat();

		if (format.isPrefixOWLDocumentFormat()) {
			owlxmlFormat.copyPrefixesFrom(format.asPrefixOWLDocumentFormat());
		}

		//prefixes in ontology is a map of <prefixName, prefixIri>, 
                //here we ignore prefixNames and store all prefixIris into a set
		Set<String> prefixIris = new HashSet<>();
		owlxmlFormat.prefixNames().forEach(prefix -> prefixIris.add(owlxmlFormat.getPrefix(prefix)));

		vowlData.getEntityMap().values().forEach(abstractEntity -> {
			IRI entityIri = abstractEntity.getIri();
			if (entityIri.toString().contains("http://owl2vowl.de#")) {
				return;
			}

			if (ComparisonHelper.hasDifferentNameSpace(entityIri.toString(), loadedOntology, loadPath) //check if entityIri.toString() is baseiri of ontology
					&& !prefixIris.contains(entityIri.getNamespace())) { //check if entityIri's name space is in prefixes of ontology
				addImportedAttribute(entityIri);
			}
		});
	}

Please do point out if anything wrong, thanks.

Cheers,
Tony

@BlackDark
Copy link
Member

@steffen-l is this a valid issue?

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

2 participants