From c2468e308af1103a433ae555b39f4c91cb6eaf83 Mon Sep 17 00:00:00 2001 From: Richard Eckart de Castilho Date: Sat, 27 Jan 2024 11:13:16 +0100 Subject: [PATCH] #4463 - Add Human Phenotype Ontology knowledge base profile - Added HPO (and IAO) ontology profiles - Improve information displayed in the KB info panel --- .../inception/kb/yaml/KnowledgeBaseInfo.java | 43 +++++++++-- .../kb/yaml/KnowledgeBaseProfile.java | 7 +- .../kb/yaml/knowledgebase-profiles.yaml | 73 +++++++++++++++++-- ...owledgeBaseProfileDeserializationTest.java | 2 +- .../ui/kb/project/KnowledgeBaseInfoPanel.html | 16 +++- .../ui/kb/project/KnowledgeBaseInfoPanel.java | 30 ++++++-- 6 files changed, 141 insertions(+), 30 deletions(-) diff --git a/inception/inception-kb/src/main/java/de/tudarmstadt/ukp/inception/kb/yaml/KnowledgeBaseInfo.java b/inception/inception-kb/src/main/java/de/tudarmstadt/ukp/inception/kb/yaml/KnowledgeBaseInfo.java index 2df76604c88..e31c85585e6 100644 --- a/inception/inception-kb/src/main/java/de/tudarmstadt/ukp/inception/kb/yaml/KnowledgeBaseInfo.java +++ b/inception/inception-kb/src/main/java/de/tudarmstadt/ukp/inception/kb/yaml/KnowledgeBaseInfo.java @@ -37,7 +37,13 @@ public class KnowledgeBaseInfo private String authorName; @JsonProperty("website-url") - private String websiteURL; + private String websiteUrl; + + @JsonProperty("license-name") + private String licenseName; + + @JsonProperty("license-url") + private String licenseUrl; public String getDescription() { @@ -69,14 +75,34 @@ public void setAuthorName(String aAuthorName) authorName = aAuthorName; } - public String getWebsiteURL() + public String getWebsiteUrl() + { + return websiteUrl; + } + + public void setWebsiteUrl(String aWebsiteURL) + { + websiteUrl = aWebsiteURL; + } + + public String getLicenseName() + { + return licenseName; + } + + public void setLicenseName(String aLicenseName) + { + licenseName = aLicenseName; + } + + public String getLicenseUrl() { - return websiteURL; + return licenseUrl; } - public void setWebsiteURL(String aWebsiteURL) + public void setLicenseUrl(String aLicenseUrl) { - websiteURL = aWebsiteURL; + licenseUrl = aLicenseUrl; } @Override @@ -92,12 +118,15 @@ public boolean equals(Object o) return Objects.equals(description, that.description) && Objects.equals(hostInstitutionName, that.hostInstitutionName) && Objects.equals(authorName, that.authorName) - && Objects.equals(websiteURL, that.websiteURL); + && Objects.equals(websiteUrl, that.websiteUrl) + && Objects.equals(licenseName, that.licenseName) + && Objects.equals(licenseUrl, that.licenseUrl); } @Override public int hashCode() { - return Objects.hash(description, hostInstitutionName, authorName, websiteURL); + return Objects.hash(description, hostInstitutionName, authorName, websiteUrl, licenseName, + licenseUrl); } } diff --git a/inception/inception-kb/src/main/java/de/tudarmstadt/ukp/inception/kb/yaml/KnowledgeBaseProfile.java b/inception/inception-kb/src/main/java/de/tudarmstadt/ukp/inception/kb/yaml/KnowledgeBaseProfile.java index b07edb01ab7..717bfcbfb34 100644 --- a/inception/inception-kb/src/main/java/de/tudarmstadt/ukp/inception/kb/yaml/KnowledgeBaseProfile.java +++ b/inception/inception-kb/src/main/java/de/tudarmstadt/ukp/inception/kb/yaml/KnowledgeBaseProfile.java @@ -17,13 +17,12 @@ */ package de.tudarmstadt.ukp.inception.kb.yaml; +import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Collections.emptyList; import java.io.IOException; import java.io.InputStreamReader; -import java.io.Reader; import java.io.Serializable; -import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -217,9 +216,9 @@ public void setDefaultDataset(String aDefaultDataset) public static Map readKnowledgeBaseProfiles() throws IOException { - try (Reader r = new InputStreamReader( + try (var r = new InputStreamReader( KnowledgeBaseProfile.class.getResourceAsStream(KNOWLEDGEBASE_PROFILES_YAML), - StandardCharsets.UTF_8)) { + UTF_8)) { ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); return mapper.readValue(r, new TypeReference>() { diff --git a/inception/inception-kb/src/main/resources/de/tudarmstadt/ukp/inception/kb/yaml/knowledgebase-profiles.yaml b/inception/inception-kb/src/main/resources/de/tudarmstadt/ukp/inception/kb/yaml/knowledgebase-profiles.yaml index 1ecee543af8..713bdc68271 100644 --- a/inception/inception-kb/src/main/resources/de/tudarmstadt/ukp/inception/kb/yaml/knowledgebase-profiles.yaml +++ b/inception/inception-kb/src/main/resources/de/tudarmstadt/ukp/inception/kb/yaml/knowledgebase-profiles.yaml @@ -38,7 +38,7 @@ babel_net: property-description: http://www.w3.org/2000/01/rdf-schema#comment subproperty-of: http://www.w3.org/2000/01/rdf-schema#subPropertyOf info: - description: > + description: | BabelNet is a multilingual lexicalized semantic network and ontology that was automatically created by linking Wikipedia to WordNet. host-institution-name: Linguistic Computing Laboratory at Sapienza University of Rome @@ -64,7 +64,7 @@ db_pedia: property-description: http://www.w3.org/2000/01/rdf-schema#comment subproperty-of: http://www.w3.org/2000/01/rdf-schema#subPropertyOf info: - description: > + description: | DBpedia is a crowd-sourced community effort to extract structured content from the information created in various Wikimedia projects. host-institution-name: Leipzig University, University of Mannheim, OpenLink Software @@ -92,7 +92,7 @@ wikidata: property-description: http://www.w3.org/2000/01/rdf-schema#comment subproperty-of: http://www.wikidata.org/prop/direct/P1647 info: - description: > + description: | Wikidata is a free and open knowledge base and acts as central storage for the structured data of its Wikimedia sister projects including Wikipedia, Wikivoyage, Wikisource, and others. host-institution-name: Wikimedia Foundation, Inc. @@ -147,7 +147,7 @@ zbw-stw-economics: property-description: http://www.w3.org/2000/01/rdf-schema#comment subproperty-of: http://www.w3.org/2000/01/rdf-schema#subPropertyOf info: - description: > + description: | Thesaurus that provides vocabulary on any economic subject. Almost 6,000 standardized subject headings and about 20,000 additional entry terms to support individual keywords. host-institution-name: ZBW - Leibniz Information Centre for Economics @@ -173,7 +173,7 @@ zbw-gnd: property-description: http://www.w3.org/2000/01/rdf-schema#comment subproperty-of: http://www.w3.org/2000/01/rdf-schema#subPropertyOf info: - description: > + description: | Mapping Integrated Authority File (GND).The Integrated Authority File (GND) is a controlled keyword system, that is mainly used for indexing in German libraries. host-institution-name: ZBW - Leibniz Information Centre for Economics @@ -251,7 +251,7 @@ wine_ontology: property-description: http://www.w3.org/2000/01/rdf-schema#comment subproperty-of: http://www.w3.org/2000/01/rdf-schema#subPropertyOf info: - description: > + description: | An example OWL ontology. Derived from the DAML Wine ontology at http://ontolingua.stanford.edu/doc/chimaera/ontologies/wines.daml host-institution-name: "-" @@ -277,9 +277,66 @@ olia_penn.owl: property-description: http://www.w3.org/2000/01/rdf-schema#comment subproperty-of: http://www.w3.org/2000/01/rdf-schema#subPropertyOf info: - description: > + description: | Ontologies of Linguistic Annotation (OLiA) host-institution-name: Applied Computational Linguistics (ACoLi) Lab at the Goethe University Frankfurt, Germany author-name: Christian Chiarcos and Maria Sukhareva website-url: http://www.acoli.informatik.uni-frankfurt.de/resources/olia/ - \ No newline at end of file + +iao: + name: Information Artifact Ontology (IAO) (v2022-11-07) + type: LOCAL + default-language: en + reification: NONE + access: + access-url: https://raw.githubusercontent.com/information-artifact-ontology/IAO/v2022-11-07/iao.owl + full-text-search: http://www.openrdf.org/contrib/lucenesail#matches + mapping: + class: http://www.w3.org/2000/01/rdf-schema#Class + subclass-of: http://www.w3.org/2000/01/rdf-schema#subClassOf + instance-of: http://www.w3.org/1999/02/22-rdf-syntax-ns#type + label: http://www.w3.org/2000/01/rdf-schema#label + property-type: http://www.w3.org/1999/02/22-rdf-syntax-ns#Property + description: http://www.w3.org/2000/01/rdf-schema#comment + property-label: http://www.w3.org/2000/01/rdf-schema#label + property-description: http://www.w3.org/2000/01/rdf-schema#comment + subproperty-of: http://www.w3.org/2000/01/rdf-schema#subPropertyOf + info: + description: | + The Information Artifact Ontology (IAO) is a new ontology of information entities, originally driven by work by + the OBI digital entity and realizable information entity branch. + + For more information, please refer to the project's website. + website-url: https://github.com/information-artifact-ontology/IAO/ + +hpo-2024-01-16: + name: Human Phenotype Ontology (v2024-01-16) + type: LOCAL + default-language: en + reification: NONE + access: + access-url: https://github.com/obophenotype/human-phenotype-ontology/releases/download/v2024-01-16/hp-full.owl + full-text-search: http://www.openrdf.org/contrib/lucenesail#matches + mapping: + class: http://www.w3.org/2002/07/owl#Class + subclass-of: http://www.w3.org/2000/01/rdf-schema#subClassOf + instance-of: http://www.w3.org/1999/02/22-rdf-syntax-ns#type + description: http://purl.obolibrary.org/obo/IAO_0000115 + label: http://www.w3.org/2000/01/rdf-schema#label + property-type: http://www.w3.org/1999/02/22-rdf-syntax-ns#Property + subproperty-of: http://www.w3.org/2000/01/rdf-schema#subPropertyOf + property-label: http://www.w3.org/2000/01/rdf-schema#label + property-description: http://www.w3.org/2000/01/rdf-schema#comment + additional-matching-properties: + - http://www.geneontology.org/formats/oboInOwl#hasExactSynonym + info: + description: | + The Human Phenotype Ontology (HPO) project provides an ontology of medically relevant phenotypes, + disease-phenotype annotations, and the algorithms that operate on these. + + This resources is quite large. Downloading and importing it may take some time. + + Find out more at [http://www.human-phenotype-ontology.org](http://www.human-phenotype-ontology.org). + host-institution-name: The Jackson Laboratory + website-url: https://hpo.jax.org/app/ + license-url: https://hpo.jax.org/app/license diff --git a/inception/inception-kb/src/test/java/de/tudarmstadt/ukp/inception/kb/KnowledgeBaseProfileDeserializationTest.java b/inception/inception-kb/src/test/java/de/tudarmstadt/ukp/inception/kb/KnowledgeBaseProfileDeserializationTest.java index 2ed30cdd6d8..7074244207c 100644 --- a/inception/inception-kb/src/test/java/de/tudarmstadt/ukp/inception/kb/KnowledgeBaseProfileDeserializationTest.java +++ b/inception/inception-kb/src/test/java/de/tudarmstadt/ukp/inception/kb/KnowledgeBaseProfileDeserializationTest.java @@ -87,7 +87,7 @@ private KnowledgeBaseInfo createReferenceInfo() referenceInfo.setDescription(description); referenceInfo.setAuthorName(author); referenceInfo.setHostInstitutionName(host); - referenceInfo.setWebsiteURL(website); + referenceInfo.setWebsiteUrl(website); return referenceInfo; } diff --git a/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/project/KnowledgeBaseInfoPanel.html b/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/project/KnowledgeBaseInfoPanel.html index 2d6c82b200f..66d5a2e22a7 100644 --- a/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/project/KnowledgeBaseInfoPanel.html +++ b/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/project/KnowledgeBaseInfoPanel.html @@ -39,11 +39,23 @@ -
+
- +
+ + +
+
+
+ +
+ + +
diff --git a/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/project/KnowledgeBaseInfoPanel.java b/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/project/KnowledgeBaseInfoPanel.java index 9556dccdb71..36808f4590d 100644 --- a/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/project/KnowledgeBaseInfoPanel.java +++ b/inception/inception-ui-kb/src/main/java/de/tudarmstadt/ukp/inception/ui/kb/project/KnowledgeBaseInfoPanel.java @@ -19,6 +19,7 @@ import static de.tudarmstadt.ukp.inception.support.lambda.LambdaBehavior.visibleWhen; +import org.apache.commons.lang3.StringUtils; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.link.ExternalLink; import org.apache.wicket.markup.html.panel.Panel; @@ -36,13 +37,26 @@ public KnowledgeBaseInfoPanel(String aId, CompoundPropertyModel aModel.getObject() != null))); - queue(new Label("hostInstitutionName", aModel.bind("hostInstitutionName")) - .add(visibleWhen(() -> aModel.getObject() != null))); - queue(new Label("authorName", aModel.bind("authorName")) - .add(visibleWhen(() -> aModel.getObject() != null))); - queue(new ExternalLink("websiteURL", aModel.bind("websiteURL"), aModel.bind("websiteURL")) - .add(visibleWhen(() -> aModel.getObject() != null))); + var description = aModel.map(KnowledgeBaseInfo::getDescription); + queue(new MarkdownLabel("description", description) + .add(visibleWhen(description.map(StringUtils::isNotBlank)))); + + var hostInstitutionName = aModel.map(KnowledgeBaseInfo::getHostInstitutionName); + queue(new Label("hostInstitutionName", hostInstitutionName) + .add(visibleWhen(hostInstitutionName.map(StringUtils::isNotBlank)))); + + var authorName = aModel.map(KnowledgeBaseInfo::getAuthorName); + queue(new Label("authorName", authorName) + .add(visibleWhen(authorName.map(StringUtils::isNotBlank)))); + + var websiteURL = aModel.map(KnowledgeBaseInfo::getWebsiteUrl); + queue(new ExternalLink("websiteUrl", websiteURL, websiteURL) + .add(visibleWhen(websiteURL.map(StringUtils::isNotBlank)))); + + var licenseUrl = aModel.map(KnowledgeBaseInfo::getLicenseUrl); + var licenseName = aModel.map(KnowledgeBaseInfo::getLicenseName) + .orElseGet(licenseUrl::getObject); + queue(new ExternalLink("licenseUrl", licenseUrl, licenseName) + .add(visibleWhen(licenseUrl.map(StringUtils::isNotBlank)))); } }