Skip to content

Commit

Permalink
handle the case that in ontoportal-lirmm branch we use "@none" not "n…
Browse files Browse the repository at this point in the history
…one"
  • Loading branch information
syphax-bouazzouni committed Oct 24, 2024
1 parent 51cca3a commit 1ac8d68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,15 @@ def generate_missing_labels_each(artifacts = {}, logger, paging, page_classes, p
pref_label = nil
portal_lang = Goo.portal_language
pref_label_lang = c.prefLabel(include_languages: true)
no_default_pref_label = pref_label_lang.nil? || (pref_label_lang.keys & [portal_lang, :none]).empty?
no_default_pref_label = pref_label_lang.nil? || (pref_label_lang.keys & [portal_lang, :none, '@none']).empty?

if no_default_pref_label
lang_rdfs_labels = c.label(include_languages: true)

# Set lang_rdfs_labels to { none: [] } if empty or no match for default label
lang_rdfs_labels = { none: [] } if Array(lang_rdfs_labels).empty? || (lang_rdfs_labels.keys & [portal_lang, :none]).empty?
if Array(lang_rdfs_labels).empty? || (lang_rdfs_labels.keys & [portal_lang, :none, '@none']).empty?
lang_rdfs_labels = { none: [] }
end

lang_rdfs_labels.each do |lang, rdfs_labels|
# Remove synonyms from rdfs_labels if there are multiple labels and synonyms exist
Expand All @@ -210,7 +212,7 @@ def generate_missing_labels_each(artifacts = {}, logger, paging, page_classes, p
label = rdfs_labels&.min || LinkedData::Utils::Triples.last_iri_fragment(c.id.to_s)

# Set language to nil for :none and assign pref_label
lang = nil if lang.eql?(:none)
lang = nil if lang.eql?(:none) || lang.to_s.eql?('@none')
pref_label = label if lang.nil? || lang.eql?(portal_lang)
pref_label ||= label

Expand Down
4 changes: 2 additions & 2 deletions lib/ontologies_linked_data/utils/triples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ def self.label_for_class_triple(class_id, property, label, language=nil)
params = { datatype: RDF::XSD.string }
lang = language.to_s.downcase

if !lang.empty? && lang.to_sym != :none
if !lang.empty? && lang.to_sym != :none && !lang.to_s.eql?('@none')
params[:datatype] = RDF.langString
params[:language] = lang.to_sym
end
return triple(class_id, property, RDF::Literal.new(label, params))
triple(class_id, property, RDF::Literal.new(label, params))
end

def self.generated_label(class_id, existing_label)
Expand Down

0 comments on commit 1ac8d68

Please sign in to comment.