diff --git a/frontend/src/model/Entity.ts b/frontend/src/model/Entity.ts index b3ed61c0f..e647a651e 100644 --- a/frontend/src/model/Entity.ts +++ b/frontend/src/model/Entity.ts @@ -68,6 +68,14 @@ export default abstract class Entity extends Thing { return Reified.fromJson(this.properties["synonym"]); } + getExactSynonyms(): Reified[] { + return Reified.fromJson(this.extractExactMatchSynonyms()) || []; + } + + getCloseMatchSynonyms(): Reified[] { + return Reified.fromJson(this.extractCloseMatchSynonyms()) || []; + } + getAppearsIn(): string[] { return (this.properties["appearsIn"] || []) as string[]; } @@ -189,4 +197,40 @@ export default abstract class Entity extends Thing { } } } + + + extractExactMatchSynonyms(): string[] { + let result = [] + + if(this.properties["synonymProperty"]) { + let synonymProperties = this.properties["synonymProperty"]; + if (!Array.isArray(synonymProperties)) { + synonymProperties = [synonymProperties]; + } + synonymProperties.map((synonymProperty: string) => { + if (synonymProperty === "http://www.geneontology.org/formats/oboInOwl#hasExactSynonym" || + synonymProperty === "http://www.geneontology.org/formats/oboInOwl#hasSynonym") { + result = result.concat(this.properties[synonymProperty]) || []; + } + }) + } + return result || []; + } + + extractCloseMatchSynonyms(): string[] { + let result = [] + if(this.properties["synonymProperty"]) { + let synonymProperties = this.properties["synonymProperty"]; + if (!Array.isArray(synonymProperties)) { + synonymProperties = [synonymProperties]; + } + synonymProperties.map((synonymProperty: string) => { + if (synonymProperty !== "http://www.geneontology.org/formats/oboInOwl#hasExactSynonym" && + synonymProperty !== "http://www.geneontology.org/formats/oboInOwl#hasSynonym") { + result = result.concat(this.properties[synonymProperty]) || []; + } + }) + } + return result || []; + } } diff --git a/frontend/src/pages/ontologies/entities/entityPageSections/EntitySynonymsSection.tsx b/frontend/src/pages/ontologies/entities/entityPageSections/EntitySynonymsSection.tsx index d6c3f9a67..80d3e0f33 100644 --- a/frontend/src/pages/ontologies/entities/entityPageSections/EntitySynonymsSection.tsx +++ b/frontend/src/pages/ontologies/entities/entityPageSections/EntitySynonymsSection.tsx @@ -12,34 +12,65 @@ export default function EntitySynonymsSection({ entity: Entity; linkedEntities: LinkedEntities; }) { - let synonyms = entity.getSynonyms(); + let exactSynonyms = entity.getExactSynonyms(); - if (!synonyms || synonyms.length === 0) { + let closeMatchSynonyms = entity.getCloseMatchSynonyms(); + + if ((!exactSynonyms || exactSynonyms.length === 0) && (!closeMatchSynonyms || closeMatchSynonyms.length === 0)) { return ; } return ( -
-
Synonym
- {synonyms - .map((synonym: Reified) => { - const hasMetadata = synonym.hasMetadata(); - return ( -
- {synonym.value} - {hasMetadata && ( - - )} +
+ {exactSynonyms && exactSynonyms.length > 0 && ( +
+
Exact Synonyms
+ {exactSynonyms + .map((synonym: Reified) => { + const hasMetadata = synonym.hasMetadata(); + return ( +
+ {synonym.value} + {hasMetadata && ( + + )} +
+ ); + }) + .sort((a, b) => sortByKeys(a, b))} +
+ )} + + {closeMatchSynonyms && closeMatchSynonyms.length > 0 && ( +
+
CloseMatch Synonyms
+ {closeMatchSynonyms + .map((synonym: Reified) => { + const hasMetadata = synonym.hasMetadata(); + return ( +
+ {synonym.value} + {hasMetadata && ( + + )} +
+ ); + }) + .sort((a, b) => sortByKeys(a, b))}
- ); - }) - .sort((a, b) => sortByKeys(a, b))} -
+ )} +
); } \ No newline at end of file