lib/bolognese/readers/schema_org_reader.rb in bolognese-1.1.17 vs lib/bolognese/readers/schema_org_reader.rb in bolognese-1.2

- old
+ new

@@ -3,17 +3,28 @@ module Bolognese module Readers module SchemaOrgReader SO_TO_DC_RELATION_TYPES = { "citation" => "References", + "isBasedOn" => "IsSupplementedBy", "sameAs" => "IsIdenticalTo", "isPartOf" => "IsPartOf", "hasPart" => "HasPart", "isPredecessor" => "IsPreviousVersionOf", "isSuccessor" => "IsNewVersionOf" } + SO_TO_DC_REVERSE_RELATION_TYPES = { + "citation" => "IsReferencedBy", + "isBasedOn" => "IsSupplementTo", + "sameAs" => "IsIdenticalTo", + "isPartOf" => "HasPart", + "hasPart" => "IsPartOf", + "isPredecessor" => "IsNewVersionOf", + "isSuccessor" => "IsPreviousVersionOf" + } + def get_schema_org(id: nil, **options) return { "string" => nil, "state" => "not_found" } unless id.present? id = normalize_id(id) response = Maremma.get(id) @@ -174,10 +185,10 @@ def schema_org_related_identifier(meta, relation_type: nil) normalize_ids(ids: meta.fetch(relation_type, nil), relation_type: SO_TO_DC_RELATION_TYPES[relation_type]) end def schema_org_reverse_related_identifier(meta, relation_type: nil) - normalize_ids(ids: meta.dig("@reverse", relation_type), relation_type: SO_TO_DC_RELATION_TYPES[relation_type]) + normalize_ids(ids: meta.dig("@reverse", relation_type), relation_type: SO_TO_DC_REVERSE_RELATION_TYPES[relation_type]) end def schema_org_is_identical_to(meta) schema_org_related_identifier(meta, relation_type: "sameAs") end