Open alexskr opened 1 week ago
@syphax-bouazzouni, The error happens in resource.rb
(GOO) on line 250 because of a conflict introduced by the multilingual code:
if include_languages && [RDF::URI, Hash].all?{|c| object.map(&:class).include?(c)}
object = object.reduce({}) do |all, new_v|
new_v = { none: [new_v] } if new_v.is_a?(RDF::URI)
all.merge(new_v) {|_, a, b| a + b }
end
elsif include_languages
=> object = object.first
end
The elsif
condition turns the object from an Array to an Object. However, later in the code, there's no handling for when the object is NOT an Array. The method map
is being called in the else
block, which is a method of an Array:
if object.is_a?(Hash)
object = object.transform_values{|values| Array(values).map{|o|o.is_a?(RDF::URI) ? o : o.object}}
else
=> object = object.map {|o| o.is_a?(RDF::URI) ? o : o.object}
end
How do we reproduce this error so that we can catch it in our unit tests?
@syphax-bouazzouni, some additional findings to help troubleshoot the issue:
When generating labels, for some reason the language information is NOT included in the unmapped
property of each class:
@unmapped=
{#<RDF::URI:0x238c(http://www.w3.org/2000/01/rdf-schema#label)>=>[#<RDF::Literal:0x23a0("Energy Metabolism"@en)>],
#<RDF::URI:0x23b4(http://www.w3.org/2000/01/rdf-schema#comment)>=>
[#<RDF::Literal:0x23c8("A set of metabolic pathways that are involved in the generation and use of energy within an organism, typically through processes like cellular
respiration and photosynthesis."@en)>],
However, when indexing, the language information IS included in unmapped
of each class:
@unmapped=
{#<RDF::URI:0x4fc4(http://www.w3.org/2000/01/rdf-schema#label)>=>{:en=>[#<RDF::Literal:0x4fd8("Energy Metabolism"@en)>]},
#<RDF::URI:0x4fec(http://www.w3.org/2000/01/rdf-schema#comment)>=>
{:en=>
[#<RDF::Literal:0x5000("A set of metabolic pathways that are involved in the generation and use of energy within an organism, typically through processes like cellula
r respiration and photosynthesis."@en)>]},
This has been fixed in #220
We are encountering errors when processing some ontologies. EFO:
FYPO:
STATO:
ECTO: