Skip to content

Commit

Permalink
Merge pull request #169 from ncbo/multilingual_preflabels
Browse files Browse the repository at this point in the history
fix:Multilingual preflabels
  • Loading branch information
alexskr authored Oct 21, 2024
2 parents ebf586c + d06a9f4 commit 106143a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 32 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ gem 'ncbo_annotator', github: 'ncbo/ncbo_annotator', branch: 'develop'
gem 'ncbo_cron', github: 'ncbo/ncbo_cron', branch: 'develop'
gem 'ncbo_ontology_recommender', github: 'ncbo/ncbo_ontology_recommender', branch: 'develop'
gem 'sparql-client', github: 'ncbo/sparql-client', branch: 'develop'
gem 'goo', github: 'ncbo/goo', branch: 'develop'
gem 'ontologies_linked_data', github: 'ncbo/ontologies_linked_data', branch: 'develop'
gem 'goo', github: 'ncbo/goo', branch: 'multilingual_preflabels'
gem 'ontologies_linked_data', github: 'ncbo/ontologies_linked_data', branch: 'multilingual_preflabels'


group :development do
Expand Down
28 changes: 11 additions & 17 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GIT
remote: https://github.com/ncbo/goo.git
revision: 74a012eebb9433d031eb00df5abbe488cb8b4512
branch: develop
revision: a27d6ca79d47eb045b1bdfe311531827428aa504
branch: multilingual_preflabels
specs:
goo (0.0.2)
addressable (~> 2.8)
Expand All @@ -27,7 +27,7 @@ GIT

GIT
remote: https://github.com/ncbo/ncbo_cron.git
revision: b279f9caa9a6a169bad7350890d7015d56e9e9b2
revision: 17b2f2b8522e6b36baa1d003b5e27cb536c04a03
branch: develop
specs:
ncbo_cron (0.0.1)
Expand Down Expand Up @@ -56,8 +56,8 @@ GIT

GIT
remote: https://github.com/ncbo/ontologies_linked_data.git
revision: 812dd78f02b77c9c6d579b0febf1c2a42d513022
branch: develop
revision: e7d2124381003283696ff863de5ed0dc4c18ecda
branch: multilingual_preflabels
specs:
ontologies_linked_data (0.0.1)
activesupport
Expand Down Expand Up @@ -155,7 +155,6 @@ GEM
faraday (~> 2.0)
ffi (1.17.0-aarch64-linux-gnu)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
gapic-common (0.22.0)
faraday (>= 1.9, < 3.a)
faraday-retry (>= 1.0, < 3.a)
Expand All @@ -180,7 +179,6 @@ GEM
google-cloud-errors (1.4.0)
google-protobuf (3.25.5-aarch64-linux)
google-protobuf (3.25.5-arm64-darwin)
google-protobuf (3.25.5-x86_64-linux)
googleapis-common-protos (1.6.0)
google-protobuf (>= 3.18, < 5.a)
googleapis-common-protos-types (~> 1.7)
Expand All @@ -194,13 +192,10 @@ GEM
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
grpc (1.66.0-aarch64-linux)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.66.0-arm64-darwin)
grpc (1.67.0-aarch64-linux)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
grpc (1.66.0-x86_64-linux)
grpc (1.67.0-arm64-darwin)
google-protobuf (>= 3.25, < 5.0)
googleapis-common-protos-types (~> 1.0)
haml (5.2.2)
Expand Down Expand Up @@ -245,7 +240,7 @@ GEM
net-http (0.4.1)
uri
net-http-persistent (2.9.4)
net-imap (0.4.16)
net-imap (0.4.17)
date
net-protocol
net-pop (0.1.2)
Expand Down Expand Up @@ -323,7 +318,7 @@ GEM
rsolr (2.6.0)
builder (>= 2.1.2)
faraday (>= 0.9, < 3, != 2.0.0)
rubocop (1.66.1)
rubocop (1.67.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
Expand Down Expand Up @@ -367,7 +362,7 @@ GEM
rack-test
sinatra (~> 1.4.0)
tilt (>= 1.3, < 3)
sshkit (1.23.1)
sshkit (1.23.2)
base64
net-scp (>= 1.1.2)
net-sftp (>= 2.1.2)
Expand Down Expand Up @@ -399,7 +394,6 @@ GEM
PLATFORMS
aarch64-linux
arm64-darwin-22
x86_64-linux

DEPENDENCIES
activesupport (~> 5)
Expand Down Expand Up @@ -456,4 +450,4 @@ DEPENDENCIES
webrick

BUNDLED WITH
2.5.20
2.5.7
39 changes: 26 additions & 13 deletions test/controllers/test_classes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def test_notation_lookup
assert response["@id"] == "http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Ontology_Development_and_Management"
end


def test_all_class_pages
ont = Ontology.find("TEST-ONT-0").include(:acronym).first

Expand All @@ -99,7 +98,7 @@ def test_all_class_pages
assert last_response.ok?
page_response = MultiJson.load(last_response.body)
page_response["collection"].each do |item|
assert_instance_of String, item["prefLabel"]
assert_instance_of String, item["prefLabel"], item["@id"]
assert_instance_of String, item["@id"]
assert_instance_of Hash, item["@context"]
assert_instance_of Hash, item["links"]
Expand Down Expand Up @@ -131,6 +130,7 @@ def test_single_cls_all
ont = Ontology.find("TEST-ONT-0").include(:acronym).first
clss_ids = [ 'http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Molecular_Interaction',
"http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Electron_Microscope" ]

clss_ids.each do |cls_id|
escaped_cls= CGI.escape(cls_id)
call = "/ontologies/#{ont.acronym}/classes/#{escaped_cls}?include=all"
Expand All @@ -149,6 +149,7 @@ def test_single_cls_properties
ont = Ontology.find("TEST-ONT-0").include(:acronym).first
clss_ids = [ 'http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Molecular_Interaction',
"http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Electron_Microscope" ]

clss_ids.each do |cls_id|
escaped_cls= CGI.escape(cls_id)
call = "/ontologies/#{ont.acronym}/classes/#{escaped_cls}?include=properties"
Expand All @@ -163,7 +164,6 @@ def test_single_cls_properties

def test_single_cls
ont = Ontology.find("TEST-ONT-0").include(:acronym).first

clss_ids = [ 'http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Molecular_Interaction',
"http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Electron_Microscope" ]

Expand Down Expand Up @@ -208,7 +208,7 @@ def test_roots_for_cls
roots = MultiJson.load(last_response.body)
assert_equal 9, roots.length
roots.each do |r|
assert_instance_of String, r["prefLabel"]
assert_instance_of String, r["prefLabel"], r["@id"]
assert_instance_of String, r["@id"]
assert r.include?"hasChildren"
#By definition roots have no parents
Expand All @@ -221,7 +221,6 @@ def test_roots_for_cls
end

def test_classes_for_not_parsed_ontology

ont = Ontology.find("TEST-ONT-0").include(:acronym).first

#first submission was not parsed
Expand All @@ -232,7 +231,6 @@ def test_classes_for_not_parsed_ontology
end

def test_tree

ont = Ontology.find("TEST-ONT-0").include(:acronym).first

clss_ids = [ 'http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Molecular_Interaction',
Expand All @@ -251,7 +249,6 @@ def test_tree
end

def test_path_to_root_for_cls

ont = Ontology.find("TEST-ONT-0").include(:acronym).first
clss_ids = [ 'http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Molecular_Interaction',
"http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Electron_Microscope" ]
Expand All @@ -264,7 +261,6 @@ def test_path_to_root_for_cls
end

def test_ancestors_for_cls

ont = Ontology.find("TEST-ONT-0").include(:acronym).first
ancestors_data = {}
ancestors_data['http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Molecular_Interaction'] =[
Expand Down Expand Up @@ -454,7 +450,6 @@ def test_calls_not_found
end

def test_children_for_cls_round_trip

clss_ids = [ 'http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Molecular_and_Cellular_Data',
"http://bioontology.org/ontologies/BiomedicalResourceOntology.owl#Microscope" ]

Expand Down Expand Up @@ -511,7 +506,7 @@ def test_class_page_with_metric_count
assert last_response.ok?
page_response = MultiJson.load(last_response.body)
page_response["collection"].each do |item|
assert_instance_of String, item["prefLabel"]
assert_instance_of String, item["prefLabel"], item["@id"]
assert_instance_of String, item["@id"]
assert_instance_of Hash, item["@context"]
assert_instance_of Hash, item["links"]
Expand All @@ -536,22 +531,40 @@ def test_default_multilingual
sub = ont.latest_submission
sub.bring_remaining

get "/ontologies/#{ont.acronym}/classes/#{CGI.escape('http://bioontology.org/ontologies/Activity.owl#Biospecimen_Management')}"
# rdfs:label is NOT present and the prefLabel is NOT defined for the ontology or portal language
sub.naturalLanguage = ['es']
sub.save
get "/ontologies/#{ont.acronym}/classes/#{CGI.escape('http://bioontology.org/ontologies/Activity.owl#Community_Engagement')}"
assert last_response.ok?
page_response = MultiJson.load(last_response.body)
# does not contain a value in english show the generated one
assert_equal 'Community_Engagement', page_response["prefLabel"]

# rdfs:label is present but NOT for either the ontology or portal language
get "/ontologies/#{ont.acronym}/classes/#{CGI.escape('http://bioontology.org/ontologies/Activity.owl#Biospecimen_Management')}"
assert last_response.ok?
page_response = MultiJson.load(last_response.body)
# does not contain a value in english show the generated one
assert_equal 'Biospecimen_Management', page_response["prefLabel"]

# prefLabel NOT present, rdfs:label is present but NOT for either the ontology or portal language
get "/ontologies/#{ont.acronym}/classes/#{CGI.escape('http://bioontology.org/ontologies/Activity.owl#Gene_Therapy')}"
assert last_response.ok?
page_response = MultiJson.load(last_response.body)
# does not contain a value in english show the generated one
assert_equal 'Gene_Therapy', page_response["prefLabel"]

# prefLabel is present in the ontology language
sub.naturalLanguage = ['fr']
sub.save

get "/ontologies/#{ont.acronym}/classes/#{CGI.escape('http://bioontology.org/ontologies/Activity.owl#Biospecimen_Management')}"
assert last_response.ok?
page_response = MultiJson.load(last_response.body)

# show french value as specified in submission naturalLanguage
assert_equal 'Biospecimen Management', page_response["prefLabel"]

sub.naturalLanguage = []
sub.save
end

end

0 comments on commit 106143a

Please sign in to comment.