Skip to content

Commit

Permalink
Merge pull request #467 from EBISPOT/owl2-testcases
Browse files Browse the repository at this point in the history
Added domain and range sections and fixed my silly mistake wrt number…
  • Loading branch information
henrietteharmse authored Aug 11, 2023
2 parents 8c262d6 + b1ca9ce commit fb67055
Show file tree
Hide file tree
Showing 13 changed files with 298 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -649,19 +649,19 @@ public void handleType(OntologyNode subjNode, Node type) {

case "http://www.w3.org/2002/07/owl#AnnotationProperty":
subjNode.types.add(OntologyNode.NodeType.ANNOTATION_PROPERTY);
addAddAndCountProperties(subjNode, numberOfProperties);
addAddAndCountProperties(subjNode);
break;

case "http://www.w3.org/2002/07/owl#ObjectProperty":
subjNode.types.add(OntologyNode.NodeType.OBJECT_PROPERTY);
addAddAndCountProperties(subjNode, numberOfProperties);
addAddAndCountProperties(subjNode);
break;
case "http://www.w3.org/2002/07/owl#DatatypeProperty":
subjNode.types.add(OntologyNode.NodeType.DATA_PROPERTY);
addAddAndCountProperties(subjNode, numberOfProperties);
addAddAndCountProperties(subjNode);
break;
case "http://www.w3.org/1999/02/22-rdf-syntax-ns#Property":
addAddAndCountProperties(subjNode, numberOfProperties);
addAddAndCountProperties(subjNode);
break;

case "http://www.w3.org/2002/07/owl#NamedIndividual":
Expand Down Expand Up @@ -696,7 +696,7 @@ public void handleType(OntologyNode subjNode, Node type) {
}
}

private void addAddAndCountProperties(OntologyNode subjNode, int numberOfProperties) {
private void addAddAndCountProperties(OntologyNode subjNode) {
subjNode.types.add(OntologyNode.NodeType.PROPERTY);

if (subjNode.uri != null) {
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/model/Class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ export default class Class extends Entity {
return asArray(this.properties['http://www.w3.org/2002/07/owl#disjointWith'])
}

getHasKey() {
return asArray(this.properties['http://www.w3.org/2002/07/owl#hasKey'])
}
}
4 changes: 1 addition & 3 deletions frontend/src/model/Entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,8 @@ export default abstract class Entity extends Thing {
// ...apart from these ones
if (
predicate !== "http://www.w3.org/2000/01/rdf-schema#comment" &&
predicate !== "http://www.w3.org/2000/01/rdf-schema#domain" &&
predicate !== "http://www.w3.org/2000/01/rdf-schema#range" &&
predicate !== "http://www.w3.org/2000/01/rdf-schema#seeAlso" &&
predicate !== "http://www.w3.org/2002/07/owl#hasKey" &&
// predicate !== "http://www.w3.org/2002/07/owl#hasKey" &&
predicate !== "http://www.w3.org/2002/07/owl#disjointUnionOf"
) {
continue;
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/model/Property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ export default class Property extends Entity {
return asArray(this.properties["http://www.w3.org/2002/07/owl#inverseOf"]);
}

getDomain() {
return asArray(this.properties['http://www.w3.org/2000/01/rdf-schema#domain'])
}

getRange() {
return asArray(this.properties['http://www.w3.org/2000/01/rdf-schema#range'])
}

getPropertyChains():Reified<any>[] {
return Reified.fromJson<any>(
this.properties["http://www.w3.org/2002/07/owl#propertyChainAxiom"]
Expand Down
15 changes: 15 additions & 0 deletions frontend/src/pages/ontologies/entities/EntityPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ import IndividualPropertyAssertionsSection from "./entityPageSections/Individual
import IndividualSameAsSection from "./entityPageSections/IndividualSameAsSection";
import IndividualTypesSection from "./entityPageSections/IndividualTypesSection";
import MetadataTooltip from "./entityPageSections/MetadataTooltip";
import DomainSection from "./entityPageSections/DomainSection";
import RangeSection from "./entityPageSections/RangeSection";
import HasKeySection from "./entityPageSections/HasKeySection";
import PropertyChainSection from "./entityPageSections/PropertyChainSection";
import PropertyCharacteristicsSection from "./entityPageSections/PropertyCharacteristicsSection";
import PropertyInverseOfSection from "./entityPageSections/PropertyInverseOfSection";
Expand Down Expand Up @@ -403,7 +406,19 @@ export default function EntityPage({
</span>
</summary>
<div className="py-2 break-words space-y-4">
<HasKeySection
entity={entity}
linkedEntities={linkedEntities}
/>
<PropertyCharacteristicsSection entity={entity} />
<DomainSection
entity={entity}
linkedEntities={linkedEntities}
/>
<RangeSection
entity={entity}
linkedEntities={linkedEntities}
/>
<IndividualPropertyAssertionsSection
entity={entity}
linkedEntities={linkedEntities}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { Fragment } from "react";
import { randomString } from "../../../../app/util";
import ClassExpression from "../../../../components/ClassExpression";
import EntityLink from "../../../../components/EntityLink";
import Entity from "../../../../model/Entity";
import Class from "../../../../model/Class";
import LinkedEntities from "../../../../model/LinkedEntities";
import Property from "../../../../model/Property";

export default function DomainSection({
entity,
linkedEntities,
}: {
entity: Entity;
linkedEntities: LinkedEntities;
}) {
if (!(entity instanceof Property)) {
return <Fragment />;
}

let domains = entity.getDomain();

if (!domains || domains.length === 0) {
return <Fragment />;
}

return (
<div>
<div className="font-bold">Domain</div>
{domains.length === 1 ? (
<p>
{typeof domains[0] === "object" &&
!Array.isArray(domains[0]) ? (
<ClassExpression
ontologyId={entity.getOntologyId()}
currentEntity={entity}
expr={domains[0]}
linkedEntities={linkedEntities}
/>
) : (
<EntityLink
ontologyId={entity.getOntologyId()}
currentEntity={entity}
entityType={
entity.getType() === "property" ? "properties" : "classes"
}
iri={domains[0]}
linkedEntities={linkedEntities}
/>
)}
</p>
) : (
<ul className="list-disc list-inside">
{domains.map((domains) => {
return (
<li key={randomString()}>
{typeof domains === "object" &&
!Array.isArray(domains) ? (
<ClassExpression
ontologyId={entity.getOntologyId()}
currentEntity={entity}
expr={domains}
linkedEntities={linkedEntities}
/>
) : (
<EntityLink
ontologyId={entity.getOntologyId()}
currentEntity={entity}
entityType={
entity.getType() === "property" ? "properties" : "classes"
}
iri={domains}
linkedEntities={linkedEntities}
/>
)}
</li>
);
})}
</ul>
)}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import { Fragment } from "react";
import { randomString } from "../../../../app/util";
import ClassExpression from "../../../../components/ClassExpression";
import EntityLink from "../../../../components/EntityLink";
import Entity from "../../../../model/Entity";
import Class from "../../../../model/Class";
import LinkedEntities from "../../../../model/LinkedEntities";
import Property from "../../../../model/Property";

export default function HasKeySection({
entity,
linkedEntities,
}: {
entity: Entity;
linkedEntities: LinkedEntities;
}) {
if (!(entity instanceof Class)) {
return <Fragment />;
}

let keys = entity.getHasKey();

if (!keys || keys.length === 0) {
return <Fragment />;
}

return (
<div>
<div className="font-bold">Has Key</div>
{keys.length === 1 ? (
<p>
{typeof keys[0] === "object" &&
!Array.isArray(keys[0]) ? (
<ClassExpression
ontologyId={entity.getOntologyId()}
currentEntity={entity}
expr={keys[0]}
linkedEntities={linkedEntities}
/>
) : (
<EntityLink
ontologyId={entity.getOntologyId()}
currentEntity={entity}
entityType={
entity.getType() === "property" ? "properties" : "classes"
}
iri={keys[0]}
linkedEntities={linkedEntities}
/>
)}
</p>
) : (
<ul className="list-disc list-inside">
{keys.map((keys) => {
return (
<li key={randomString()}>
{typeof keys === "object" &&
!Array.isArray(keys) ? (
<ClassExpression
ontologyId={entity.getOntologyId()}
currentEntity={entity}
expr={keys}
linkedEntities={linkedEntities}
/>
) : (
<EntityLink
ontologyId={entity.getOntologyId()}
currentEntity={entity}
entityType={
entity.getType() === "property" ? "properties" : "classes"
}
iri={keys}
linkedEntities={linkedEntities}
/>
)}
</li>
);
})}
</ul>
)}
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,27 @@ export default function IndividualPropertyAssertionsSection({
}) {
if (entity.getType() !== "individual") return <Fragment />;

console.log("entity.getIri()=" + entity.getIri())
let propertyIris = Object.keys(entity.properties);

let negativeProperties = propertyIris.filter((k) =>
k.startsWith("negativePropertyAssertion+")
);
console.log("entity=" + entity.getIri() + " negativeProperties.length = " + negativeProperties.length)

// let annotationProperties = propertyIris.filter(
// (k) =>
// linkedEntities.get(k) &&
// linkedEntities.get(k)!.type.indexOf("annotationProperty") !== -1
// );
// console.log("entity=" + entity.getIri() + " annotationProperties.length = " + annotationProperties.length)

let objectProperties = propertyIris.filter(
(k) =>
linkedEntities.get(k) &&
linkedEntities.get(k)!.type.indexOf("objectProperty") !== -1
);

console.log("entity=" + entity.getIri() + " objectProperties.length = " + objectProperties.length)

let dataProperties = propertyIris.filter(
(k) =>
linkedEntities.get(k) &&
linkedEntities.get(k)!.type.indexOf("dataProperty") !== -1
);

console.log("entity=" + entity.getIri() + " dataProperties.length = " + dataProperties.length)


let propertyAssertions: JSX.Element[] = [];

for (let iri of objectProperties) {
console.log("iri = " + iri)
const values = asArray(entity.properties[iri]);
for (let v of values) {
propertyAssertions.push(
Expand Down Expand Up @@ -97,7 +82,6 @@ export default function IndividualPropertyAssertionsSection({
}

for (let iri of dataProperties) {
console.log("iri = " + iri)
const values = asArray(entity.properties[iri]);
for (let v of values) {
propertyAssertions.push(
Expand Down Expand Up @@ -131,13 +115,11 @@ export default function IndividualPropertyAssertionsSection({

for (let k of negativeProperties) {
let iri = k.slice("negativePropertyAssertion+".length);
console.log("k=" + k + " iri = " + iri)
let linkedEntity = linkedEntities.get(iri)
let dataProperty = linkedEntity!.type.indexOf("dataProperty") !== -1
let objectProperty = linkedEntity!.type.indexOf("objectProperty") !== -1
const values = asArray(entity.properties[k]);
for (let v of values) {
console.log("typeof v = " + typeof v)
propertyAssertions.push(
<span>
<span className="px-1 text-embl-purple-default italic">not</span>{" "}
Expand Down
Loading

0 comments on commit fb67055

Please sign in to comment.