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

Removed some unnecessary RDF properties #87

Merged
merged 6 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions docs/context/development/phyx.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
"phyloref": "http://ontology.phyloref.org/phyloref.owl#",
"opentree": "http://purl.org/opentree/nexson#",

"subClasses": {
"@reverse": "rdfs:subClassOf"
},

"label": {
"@id": "rdfs:label",
"@type": "xsd:string"
Expand All @@ -38,21 +42,6 @@
"@type": "xsd:string"
},

"internalSpecifiers": {
"@id": "testcase:internal_specifier",
"@container": "@set"
},

"externalSpecifiers": {
"@id": "testcase:external_specifier",
"@container": "@set"
},

"hasComponentClass": {
"@id": "testcase:has_component_class",
"@container": "@set"
},

"hasName": {
"@id": "http://rs.tdwg.org/ontology/voc/TaxonConcept#hasName",
"@type": "http://rs.tdwg.org/ontology/voc/TaxonName#TaxonName"
Expand Down Expand Up @@ -176,11 +165,6 @@
"@container": "@set"
},

"malformedPhyloreference": {
"@id": "testcase:malformed_phyloreference",
"@type": "xsd:string"
},

"title": "dct:title",
"source": "dct:source",
"bibliographicCitation": "dct:bibliographicCitation",
Expand Down
24 changes: 13 additions & 11 deletions src/wrappers/PhylorefWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,15 +408,15 @@ class PhylorefWrapper {

// TODO We need to replace this with an actual object-based comparison,
// rather than trusting the labels to tell us everything.
if (reusePrevious && has(PhylorefWrapper.componentClassesByLabel, componentClassLabel)) {
if (reusePrevious && has(this.componentClassesByLabel, componentClassLabel)) {
// If we see the same label again, return the previously defined component class.
return { '@id': PhylorefWrapper.componentClassesByLabel[componentClassLabel]['@id'] };
return { '@id': this.componentClassesByLabel[componentClassLabel]['@id'] };
}

// Create a new component class for this set of internal and external specifiers.
PhylorefWrapper.componentClassCount += 1;
this.componentClassCount += 1;
const componentClass = {};
componentClass['@id'] = `${jsonld['@id']}_component${PhylorefWrapper.componentClassCount}`;
componentClass['@id'] = `${jsonld['@id']}_component${this.componentClassCount}`;
// process.stderr.write(`Creating new componentClass with id: ${componentClass['@id']}`);

componentClass['@type'] = 'owl:Class';
Expand All @@ -431,10 +431,13 @@ class PhylorefWrapper {
});
}

jsonld.hasComponentClass.push(componentClass);
PhylorefWrapper.componentClassesByLabel[componentClassLabel] = componentClass;
// Save it in the cache for later usage.
this.componentClassesByLabel[componentClassLabel] = componentClass;

return { '@id': componentClass['@id'] };
// The first time we create a componentClass, we include it into the logical
// expression directly. On subsequent calls, we'll only return the `@id`
// (see above).
return componentClass;
}

getIncludesRestrictionForTU(tu) {
Expand Down Expand Up @@ -633,9 +636,8 @@ class PhylorefWrapper {

// We might need to make component classes.
// So we reset our component class counts and records.
PhylorefWrapper.componentClassCount = 0;
PhylorefWrapper.componentClassesByLabel = {};
phylorefAsJSONLD.hasComponentClass = [];
this.componentClassCount = 0;
this.componentClassesByLabel = {};

// The type of this phyloreference.
let calculatedPhylorefType;
Expand Down Expand Up @@ -748,7 +750,7 @@ class PhylorefWrapper {
// 2. We need to set each of these component classes to be a subclass of
// this phyloreference so that it can include instances from each of the
// logical expressions.
logicalExpressions.forEach(classExpr => this.createComponentClass(
phylorefAsJSONLD.subClasses = logicalExpressions.map(classExpr => this.createComponentClass(
phylorefAsJSONLD,
internalSpecifiers,
externalSpecifiers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,6 @@
"externalSpecifiers": [],
"@id": "http://example.org/phyx.js/example#phyloref0",
"@type": "owl:Class",
"hasComponentClass": [],
"equivalentClass": {
"@type": "owl:Restriction",
"onProperty": "obo:CDAO_0000149",
Expand Down
237 changes: 110 additions & 127 deletions test/examples/correct/alligatoridae_default_nomen_code.nq

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1536,7 +1536,6 @@
"externalSpecifiers": [],
"@id": "http://example.org/phyx.js/example#phyloref0",
"@type": "owl:Class",
"hasComponentClass": [],
"equivalentClass": {
"@type": "owl:Restriction",
"onProperty": "obo:CDAO_0000149",
Expand Down
238 changes: 110 additions & 128 deletions test/examples/correct/alligatoridae_inferred_nomen_code.nq

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions test/examples/correct/brochu_2003.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -1632,7 +1632,6 @@
"externalSpecifiers": [],
"@id": "http://example.org/phyx.js/example#phyloref0",
"@type": "owl:Class",
"hasComponentClass": [],
"equivalentClass": {
"@type": "owl:Restriction",
"onProperty": "obo:CDAO_0000149",
Expand Down Expand Up @@ -1775,7 +1774,6 @@
},
"@id": "http://example.org/phyx.js/example#phyloref1",
"@type": "owl:Class",
"hasComponentClass": [],
"equivalentClass": {
"@type": "owl:Class",
"intersectionOf": [
Expand Down Expand Up @@ -1913,7 +1911,6 @@
},
"@id": "http://example.org/phyx.js/example#phyloref2",
"@type": "owl:Class",
"hasComponentClass": [],
"equivalentClass": {
"@type": "owl:Class",
"intersectionOf": [
Expand Down Expand Up @@ -2024,7 +2021,7 @@
},
"@id": "http://example.org/phyx.js/example#phyloref3",
"@type": "owl:Class",
"hasComponentClass": [
"subClasses": [
{
"@id": "http://example.org/phyx.js/example#phyloref3_component1",
"@type": "owl:Class",
Expand Down Expand Up @@ -2305,7 +2302,7 @@
"externalSpecifiers": [],
"@id": "http://example.org/phyx.js/example#phyloref4",
"@type": "owl:Class",
"hasComponentClass": [
"subClasses": [
{
"@id": "http://example.org/phyx.js/example#phyloref4_component1",
"@type": "owl:Class",
Expand Down Expand Up @@ -3362,7 +3359,6 @@
},
"@id": "http://example.org/phyx.js/example#phyloref5",
"@type": "owl:Class",
"hasComponentClass": [],
"equivalentClass": {
"@type": "owl:Class",
"intersectionOf": [
Expand Down
Loading