From d17ba8ea75dca29e0934a4d2929f125f57ab6e5a Mon Sep 17 00:00:00 2001 From: HassanAkbar Date: Wed, 6 Mar 2024 12:52:57 +0500 Subject: [PATCH] Use glossarist for reading concepts (#20) * using glossarist for reading concepts * updated specs * code refactoring and updated specs --- jekyll-geolexica.gemspec | 1 + lib/jekyll/geolexica.rb | 1 + lib/jekyll/geolexica/configuration.rb | 5 + lib/jekyll/geolexica/glossary.rb | 82 +--- spec/concept_fixtures/concept-10.json | 147 +++--- spec/concept_fixtures/concept-10.yaml | 215 -------- .../04e539b2-4557-4d05-a603-9881ed6951c6.yaml | 15 - .../04e539b2-4557-4d05-a603-9881ed6951c6.yaml | 39 ++ .../v1_glossary/concept-10.yaml | 181 +++++++ .../geolexica/concept_serializer_spec.rb | 2 +- spec/unit/jekyll/geolexica/glossary_spec.rb | 463 +++++++++++++++++- 11 files changed, 758 insertions(+), 393 deletions(-) delete mode 100644 spec/concept_fixtures/concept-10.yaml delete mode 100644 spec/concept_fixtures/paneron_glossary/localized-concept/04e539b2-4557-4d05-a603-9881ed6951c6.yaml create mode 100644 spec/concept_fixtures/paneron_glossary/localized_concept/04e539b2-4557-4d05-a603-9881ed6951c6.yaml create mode 100644 spec/concept_fixtures/v1_glossary/concept-10.yaml diff --git a/jekyll-geolexica.gemspec b/jekyll-geolexica.gemspec index 7957e45..94f4048 100644 --- a/jekyll-geolexica.gemspec +++ b/jekyll-geolexica.gemspec @@ -35,6 +35,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] + spec.add_runtime_dependency "glossarist", "~> 2.0" # Jekyll 4.1.0 adds some breaking changes which are reverted in 4.1.1. # I doubt we should be worried, but there is no good reason to allow them # either. diff --git a/lib/jekyll/geolexica.rb b/lib/jekyll/geolexica.rb index 6d555da..f4a8b4f 100644 --- a/lib/jekyll/geolexica.rb +++ b/lib/jekyll/geolexica.rb @@ -2,6 +2,7 @@ # require "jekyll" +require "glossarist" module Jekyll module Geolexica diff --git a/lib/jekyll/geolexica/configuration.rb b/lib/jekyll/geolexica/configuration.rb index 693b29c..b6187ae 100644 --- a/lib/jekyll/geolexica/configuration.rb +++ b/lib/jekyll/geolexica/configuration.rb @@ -16,6 +16,11 @@ def localized_concepts_path File.expand_path(path, site.source) end + def glossary_path + glob_string = glossary_config["glossary_path"] + File.expand_path(glob_string, site.source) + end + def glossary_format glossary_config["format"] end diff --git a/lib/jekyll/geolexica/glossary.rb b/lib/jekyll/geolexica/glossary.rb index 9bcc6bb..5d774c5 100644 --- a/lib/jekyll/geolexica/glossary.rb +++ b/lib/jekyll/geolexica/glossary.rb @@ -13,11 +13,27 @@ class Glossary < Hash def initialize(site) @site = site + @collection = Glossarist::ManagedConceptCollection.new end def load_glossary Jekyll.logger.info('Geolexica:', 'Loading concepts') - Dir.glob(concepts_glob).each { |path| load_concept(path) } + @collection.load_from_files(glossary_path) + + @collection.each do |managed_concept| + concept_hash = { + "id" => managed_concept.uuid, + "term" => managed_concept.default_designation, + "termid" => managed_concept.id, + }.merge(managed_concept.to_h) + + managed_concept.localizations.each do |lang, localization| + concept_hash[lang] = localization.to_h["data"] + end + + preprocess_concept_hash(concept_hash) + store(Concept.new(concept_hash)) + end end def store(concept) @@ -37,70 +53,6 @@ def to_liquid protected - def load_concept(concept_file_path) - Jekyll.logger.debug('Geolexica:', - "reading concept from file #{concept_file_path}") - - concept_hash = if glossary_format == 'paneron' - read_paneron_concept_file(concept_file_path) - else - read_concept_file(concept_file_path) - end - - preprocess_concept_hash(concept_hash) - store Concept.new(concept_hash) - rescue StandardError - Jekyll.logger.error('Geolexica:', - "failed to read concept from file #{concept_file_path}") - raise - end - - # Reads and parses concept file located at given path. - def read_concept_file(path) - YAML.safe_load(File.read(path), permitted_classes: [Time]) - end - - def read_paneron_concept_file(path) - safe_load_options = { permitted_classes: [Date, Time] } - concept = YAML.safe_load(File.read(path), **safe_load_options) - concept['termid'] = concept['data']['identifier'] - - (concept['data']['localizedConcepts'] || []).each do |lang, local_concept_id| - localized_concept_path = File.join(localized_concepts_path, "#{local_concept_id}.yaml") - concept[lang] = YAML.safe_load(File.read(localized_concept_path), **safe_load_options)['data'] - - next unless concept[lang] - - normalize_sources(concept[lang]) - concept['term'] = concept[lang]['terms'].first['designation'] if lang == 'eng' - end - - concept - end - - def normalize_sources(concept) - authoritative_sources = concept.delete('authoritativeSource') || [] - concept['sources'] ||= [] - - authoritative_sources.each do |authoritative_source| - if authoritative_source['relationship'] - status = authoritative_source['relationship']['type'] - modification = authoritative_source['relationship']['modification'] - end - - concept['sources'] << { - "status" => status, - "modification" => modification, - "origin" => { - 'ref' => authoritative_source['ref'], - 'clause' => authoritative_source['clause'], - 'link' => authoritative_source['link'], - }.compact, - 'type' => 'authoritative' - }.compact - end - end - # Does nothing, but some sites may replace this method. def preprocess_concept_hash(concept_hash); end diff --git a/spec/concept_fixtures/concept-10.json b/spec/concept_fixtures/concept-10.json index fa27cf3..d8149aa 100644 --- a/spec/concept_fixtures/concept-10.json +++ b/spec/concept_fixtures/concept-10.json @@ -11,27 +11,26 @@ "type" : "expression" } ], - "authoritative_source" : { - "clause" : "3.4.16, modified — the Note 1 to entry has been added.", - "ref" : "ISO 1087-1:2000", - "link" : "https://www.iso.org/standard/20057.html" - }, + "authoritative_source" : [ + { + "clause" : "3.4.16, modified — the Note 1 to entry has been added.", + "ref" : "ISO 1087-1:2000", + "link" : "https://www.iso.org/standard/20057.html" + } + ], "lineage_source_similarity" : 1, "review_decision_event" : "Publication of ISO 19104:2016", "notes" : [], - "definition" : "término clasificado de acuerdo a la escala de aceptanción como un sinónimo de un término preferente", + "definition" : ["término clasificado de acuerdo a la escala de aceptanción como un sinónimo de un término preferente"], "language_code" : "spa", "lineage_source" : "ISO/TS 19104:2008", "review_decision_date" : "2016-10-01 00:00:00 +0800", "examples" : [], "release" : "2", "review_date" : "2013-01-29 00:00:00 +0800", - "review_decision_notes" : "Authoritative reference changed from ISO 1087-1:2000 to ISO 1087-1:2000, 3.4.16, modified — the Note 1 to entry has been added.. Lineage source added as ISO/TS 19104:2008", "date_accepted" : "2008-11-15 00:00:00 +0800", - "review_status" : "final", "entry_status" : "valid", - "id" : 10, - "review_decision" : "accepted" + "id" : "10" }, "ara" : { "terms" : [ @@ -41,27 +40,26 @@ "type" : "expression" } ], - "authoritative_source" : { - "ref" : "ISO 1087-1:2000", - "clause" : "3.4.16, modified — the Note 1 to entry has been added.", - "link" : "https://www.iso.org/standard/20057.html" - }, + "authoritative_source" : [ + { + "ref" : "ISO 1087-1:2000", + "clause" : "3.4.16, modified — the Note 1 to entry has been added.", + "link" : "https://www.iso.org/standard/20057.html" + } + ], "lineage_source_similarity" : 1, "review_decision_event" : "Publication of ISO 19104:2016", "notes" : [], "language_code" : "ara", - "definition" : "مصطلح صنف وفقا لمقياس تصنيف قبول المصطلحات كمرادف للمصطلح المفضل", + "definition" : ["مصطلح صنف وفقا لمقياس تصنيف قبول المصطلحات كمرادف للمصطلح المفضل"], "lineage_source" : "ISO/TS 19104:2008", "review_decision_date" : "2016-10-01 00:00:00 +0800", "examples" : [], - "review_decision_notes" : "Authoritative reference changed from ISO 1087-1:2000 to ISO 1087-1:2000, 3.4.16, modified — the Note 1 to entry has been added.. Lineage source added as ISO/TS 19104:2008", "date_accepted" : "2008-11-15 00:00:00 +0800", "release" : "2", "review_date" : "2013-01-29 00:00:00 +0800", "entry_status" : "valid", - "review_decision" : "accepted", - "id" : 10, - "review_status" : "final" + "id" : "10" }, "msa" : null, "dut" : null, @@ -74,14 +72,16 @@ "designation" : "승인 용어" } ], - "authoritative_source" : { - "link" : "https://www.iso.org/standard/20057.html", - "ref" : "ISO 1087-1:2000", - "clause" : "3.4.16, modified — the Note 1 to entry has been added." - }, + "authoritative_source" : [ + { + "link" : "https://www.iso.org/standard/20057.html", + "ref" : "ISO 1087-1:2000", + "clause" : "3.4.16, modified — the Note 1 to entry has been added." + } + ], "review_decision_event" : "Publication of ISO 19104:2016", "notes" : [], - "definition" : "상용 용어의 동의어로써 용어 수용가능성 등급체계에 의거하여 등급이 부여된 용어", + "definition" : ["상용 용어의 동의어로써 용어 수용가능성 등급체계에 의거하여 등급이 부여된 용어"], "language_code" : "kor", "review_decision_date" : "2016-10-01 00:00:00 +0800", "lineage_source" : "ISO/TS 19104:2008", @@ -89,22 +89,21 @@ "review_date" : "2013-01-29 00:00:00 +0800", "release" : "2", "date_accepted" : "2008-11-15 00:00:00 +0800", - "review_decision_notes" : "Authoritative reference changed from ISO 1087-1:2000 to ISO 1087-1:2000, 3.4.16, modified — the Note 1 to entry has been added.. Lineage source added as ISO/TS 19104:2008", - "review_status" : "final", - "id" : 10, - "review_decision" : "accepted", + "id" : "10", "entry_status" : "valid" }, "eng" : { "notes" : [], "language_code" : "eng", - "definition" : "term rated according to the scale of the term acceptability rating as a synonym for a preferred term", + "definition" : ["term rated according to the scale of the term acceptability rating as a synonym for a preferred term"], "lineage_source_similarity" : 1, - "authoritative_source" : { - "link" : "https://www.iso.org/standard/20057.html", - "clause" : "3.4.16, modified — the Note 1 to entry has been added.", - "ref" : "ISO 1087-1:2000" - }, + "authoritative_source" : [ + { + "link" : "https://www.iso.org/standard/20057.html", + "clause" : "3.4.16, modified — the Note 1 to entry has been added.", + "ref" : "ISO 1087-1:2000" + } + ], "terms" : [ { "designation" : "admitted term", @@ -114,13 +113,10 @@ ], "review_decision_event" : "Publication of ISO 19104:2016", "date_accepted" : "2008-11-15 00:00:00 +0800", - "review_decision_notes" : "Authoritative reference changed from ISO 1087-1:2000 to ISO 1087-1:2000, 3.4.16, modified — the Note 1 to entry has been added.. Lineage source added as ISO/TS 19104:2008", "review_date" : "2013-01-29 00:00:00 +0800", "release" : "2", - "review_decision" : "accepted", - "id" : 10, + "id" : "10", "entry_status" : "valid", - "review_status" : "final", "review_decision_date" : "2016-10-01 00:00:00 +0800", "lineage_source" : "ISO/TS 19104:2008", "examples" : [] @@ -132,17 +128,16 @@ "review_date" : "2013-01-29 00:00:00 +0800", "release" : "2", "date_accepted" : "2008-11-15 00:00:00 +0800", - "review_decision_notes" : "Authoritative reference changed from ISO 1087-1:2000 to ISO 1087-1:2000, 3.4.16, modified — the Note 1 to entry has been added.. Lineage source added as ISO/TS 19104:2008", - "review_status" : "final", - "review_decision" : "accepted", - "id" : 10, + "id" : "10", "entry_status" : "valid", "lineage_source_similarity" : 1, - "authoritative_source" : { - "link" : "https://www.iso.org/standard/20057.html", - "ref" : "ISO 1087-1:2000", - "clause" : "3.4.16, modified — the Note 1 to entry has been added." - }, + "authoritative_source" : [ + { + "link" : "https://www.iso.org/standard/20057.html", + "ref" : "ISO 1087-1:2000", + "clause" : "3.4.16, modified — the Note 1 to entry has been added." + } + ], "terms" : [ { "designation" : "tilladt term", @@ -152,7 +147,7 @@ ], "review_decision_event" : "Publication of ISO 19104:2016", "notes" : [], - "definition" : "term, klassificeret efter en skala for tilladte termer, anvendt som synonym for en foretrukket term", + "definition" : ["term, klassificeret efter en skala for tilladte termer, anvendt som synonym for en foretrukket term"], "language_code" : "dan" }, "fin" : null, @@ -165,11 +160,13 @@ "type" : "expression" } ], - "authoritative_source" : { - "ref" : "ISO 1087-1:2000", - "clause" : "3.4.16, modified — the Note 1 to entry has been added.", - "link" : "https://www.iso.org/standard/20057.html" - }, + "authoritative_source" : [ + { + "ref" : "ISO 1087-1:2000", + "clause" : "3.4.16, modified — the Note 1 to entry has been added.", + "link" : "https://www.iso.org/standard/20057.html" + } + ], "review_decision_event" : "Publication of ISO 19104:2016", "notes" : [], "language_code" : "ger", @@ -179,10 +176,7 @@ "review_date" : "2013-01-29 00:00:00 +0800", "release" : "2", "date_accepted" : "2008-11-15 00:00:00 +0800", - "review_decision_notes" : "Authoritative reference changed from ISO 1087-1:2000 to ISO 1087-1:2000, 3.4.16, modified — the Note 1 to entry has been added.. Lineage source added as ISO/TS 19104:2008", - "review_status" : "final", - "review_decision" : "accepted", - "id" : 10, + "id" : "10", "entry_status" : "valid" }, "jpn" : null, @@ -194,10 +188,7 @@ "review_date" : "2013-01-29 00:00:00 +0800", "release" : "2", "date_accepted" : "2008-11-15 00:00:00 +0800", - "review_decision_notes" : "Authoritative reference changed from ISO 1087-1:2000 to ISO 1087-1:2000, 3.4.16, modified — the Note 1 to entry has been added.. Lineage source added as ISO/TS 19104:2008", - "review_status" : "final", - "id" : 10, - "review_decision" : "accepted", + "id" : "10", "entry_status" : "valid", "lineage_source_similarity" : 1, "terms" : [ @@ -207,22 +198,24 @@ "type" : "expression" } ], - "authoritative_source" : { - "ref" : "ISO 1087-1:2000", - "clause" : "3.4.16, modified — the Note 1 to entry has been added.", - "link" : "https://www.iso.org/standard/20057.html" - }, + "authoritative_source" : [ + { + "ref" : "ISO 1087-1:2000", + "clause" : "3.4.16, modified — the Note 1 to entry has been added.", + "link" : "https://www.iso.org/standard/20057.html" + } + ], "review_decision_event" : "Publication of ISO 19104:2016", "notes" : [], - "definition" : "term som bedömts vara lämplig för ett visst begrepp och som används vid sidan av en rekommenderad term", + "definition" : ["term som bedömts vara lämplig för ett visst begrepp och som används vid sidan av en rekommenderad term"], "language_code" : "swe" }, - "termid" : 10, + "termid" : "10", "rus" : { - "id" : 10, + "id" : "10", "entry_status" : "valid", "language_code" : "rus", - "definition" : "термин, оцененный по шкале рейтинга приемлемости термина как синоним предпочтительного термина", + "definition" : ["термин, оцененный по шкале рейтинга приемлемости термина как синоним предпочтительного термина"], "date_accepted" : "2008-11-15 00:00:00 +0800", "notes" : [], "release" : "2", @@ -236,9 +229,11 @@ "normative_status" : "preferred" } ], - "authoritative_source" : { - "ref" : "ISO 1087-1:2000", - "link" : "https://www.iso.org/standard/20057.html" - } + "authoritative_source" : [ + { + "ref" : "ISO 1087-1:2000", + "link" : "https://www.iso.org/standard/20057.html" + } + ] } } diff --git a/spec/concept_fixtures/concept-10.yaml b/spec/concept_fixtures/concept-10.yaml deleted file mode 100644 index c5757a7..0000000 --- a/spec/concept_fixtures/concept-10.yaml +++ /dev/null @@ -1,215 +0,0 @@ ---- -term: admitted term -termid: 10 -eng: - id: 10 - definition: term rated according to the scale of the term acceptability rating as - a synonym for a preferred term - language_code: eng - notes: [] - examples: [] - entry_status: valid - authoritative_source: - ref: ISO 1087-1:2000 - clause: 3.4.16, modified — the Note 1 to entry has been added. - link: https://www.iso.org/standard/20057.html - lineage_source: ISO/TS 19104:2008 - lineage_source_similarity: 1 - date_accepted: 2008-11-15 00:00:00.000000000 +08:00 - review_date: 2013-01-29 00:00:00.000000000 +08:00 - review_status: final - review_decision: accepted - review_decision_date: 2016-10-01 00:00:00.000000000 +08:00 - review_decision_event: Publication of ISO 19104:2016 - review_decision_notes: Authoritative reference changed from ISO 1087-1:2000 to ISO - 1087-1:2000, 3.4.16, modified — the Note 1 to entry has been added.. Lineage source - added as ISO/TS 19104:2008 - release: '2' - terms: - - type: expression - designation: admitted term - normative_status: preferred -ara: - id: 10 - definition: مصطلح صنف وفقا لمقياس تصنيف قبول المصطلحات كمرادف للمصطلح المفضل - language_code: ara - notes: [] - examples: [] - entry_status: valid - authoritative_source: - ref: ISO 1087-1:2000 - clause: 3.4.16, modified — the Note 1 to entry has been added. - link: https://www.iso.org/standard/20057.html - lineage_source: ISO/TS 19104:2008 - lineage_source_similarity: 1 - date_accepted: 2008-11-15 00:00:00.000000000 +08:00 - review_date: 2013-01-29 00:00:00.000000000 +08:00 - review_status: final - review_decision: accepted - review_decision_date: 2016-10-01 00:00:00.000000000 +08:00 - review_decision_event: Publication of ISO 19104:2016 - review_decision_notes: Authoritative reference changed from ISO 1087-1:2000 to ISO - 1087-1:2000, 3.4.16, modified — the Note 1 to entry has been added.. Lineage source - added as ISO/TS 19104:2008 - release: '2' - terms: - - type: expression - designation: مصطلح معترف به - normative_status: preferred -dan: - id: 10 - definition: term, klassificeret efter en skala for tilladte termer, anvendt som - synonym for en foretrukket term - language_code: dan - notes: [] - examples: [] - entry_status: valid - authoritative_source: - ref: ISO 1087-1:2000 - clause: 3.4.16, modified — the Note 1 to entry has been added. - link: https://www.iso.org/standard/20057.html - lineage_source: ISO/TS 19104:2008 - lineage_source_similarity: 1 - date_accepted: 2008-11-15 00:00:00.000000000 +08:00 - review_date: 2013-01-29 00:00:00.000000000 +08:00 - review_status: final - review_decision: accepted - review_decision_date: 2016-10-01 00:00:00.000000000 +08:00 - review_decision_event: Publication of ISO 19104:2016 - review_decision_notes: Authoritative reference changed from ISO 1087-1:2000 to ISO - 1087-1:2000, 3.4.16, modified — the Note 1 to entry has been added.. Lineage source - added as ISO/TS 19104:2008 - release: '2' - terms: - - type: expression - designation: tilladt term - normative_status: preferred -ger: - id: 10 - language_code: ger - notes: [] - examples: [] - entry_status: valid - authoritative_source: - ref: ISO 1087-1:2000 - clause: 3.4.16, modified — the Note 1 to entry has been added. - link: https://www.iso.org/standard/20057.html - lineage_source: ISO/TS 19104:2008 - lineage_source_similarity: 1 - date_accepted: 2008-11-15 00:00:00.000000000 +08:00 - review_date: 2013-01-29 00:00:00.000000000 +08:00 - review_status: final - review_decision: accepted - review_decision_date: 2016-10-01 00:00:00.000000000 +08:00 - review_decision_event: Publication of ISO 19104:2016 - review_decision_notes: Authoritative reference changed from ISO 1087-1:2000 to ISO - 1087-1:2000, 3.4.16, modified — the Note 1 to entry has been added.. Lineage source - added as ISO/TS 19104:2008 - release: '2' - terms: - - type: expression - designation: zugelassener Begriff - normative_status: preferred -kor: - id: 10 - definition: 상용 용어의 동의어로써 용어 수용가능성 등급체계에 의거하여 등급이 부여된 용어 - language_code: kor - notes: [] - examples: [] - entry_status: valid - authoritative_source: - ref: ISO 1087-1:2000 - clause: 3.4.16, modified — the Note 1 to entry has been added. - link: https://www.iso.org/standard/20057.html - lineage_source: ISO/TS 19104:2008 - lineage_source_similarity: 1 - date_accepted: 2008-11-15 00:00:00.000000000 +08:00 - review_date: 2013-01-29 00:00:00.000000000 +08:00 - review_status: final - review_decision: accepted - review_decision_date: 2016-10-01 00:00:00.000000000 +08:00 - review_decision_event: Publication of ISO 19104:2016 - review_decision_notes: Authoritative reference changed from ISO 1087-1:2000 to ISO - 1087-1:2000, 3.4.16, modified — the Note 1 to entry has been added.. Lineage source - added as ISO/TS 19104:2008 - release: '2' - terms: - - type: expression - designation: 승인 용어 - normative_status: preferred -rus: - id: 10 - definition: термин, оцененный по шкале рейтинга приемлемости термина как синоним - предпочтительного термина - language_code: rus - notes: [] - examples: [] - entry_status: valid - authoritative_source: - ref: ISO 1087-1:2000 - link: https://www.iso.org/standard/20057.html - lineage_source: ISO/TS 19104:2008 - lineage_source_similarity: 1 - date_accepted: 2008-11-15 00:00:00.000000000 +08:00 - release: '2' - terms: - - type: expression - designation: допустимый термин - normative_status: preferred -spa: - id: 10 - definition: término clasificado de acuerdo a la escala de aceptanción como un sinónimo - de un término preferente - language_code: spa - notes: [] - examples: [] - entry_status: valid - authoritative_source: - ref: ISO 1087-1:2000 - clause: 3.4.16, modified — the Note 1 to entry has been added. - link: https://www.iso.org/standard/20057.html - lineage_source: ISO/TS 19104:2008 - lineage_source_similarity: 1 - date_accepted: 2008-11-15 00:00:00.000000000 +08:00 - review_date: 2013-01-29 00:00:00.000000000 +08:00 - review_status: final - review_decision: accepted - review_decision_date: 2016-10-01 00:00:00.000000000 +08:00 - review_decision_event: Publication of ISO 19104:2016 - review_decision_notes: Authoritative reference changed from ISO 1087-1:2000 to ISO - 1087-1:2000, 3.4.16, modified — the Note 1 to entry has been added.. Lineage source - added as ISO/TS 19104:2008 - release: '2' - terms: - - type: expression - designation: término admitido - normative_status: preferred -swe: - id: 10 - definition: term som bedömts vara lämplig för ett visst begrepp och som används - vid sidan av en rekommenderad term - country_code: swe - language_code: swe - notes: [] - examples: [] - entry_status: valid - authoritative_source: - ref: ISO 1087-1:2000 - clause: 3.4.16, modified — the Note 1 to entry has been added. - link: https://www.iso.org/standard/20057.html - lineage_source: ISO/TS 19104:2008 - lineage_source_similarity: 1 - date_accepted: 2008-11-15 00:00:00.000000000 +08:00 - review_date: 2013-01-29 00:00:00.000000000 +08:00 - review_status: final - review_decision: accepted - review_decision_date: 2016-10-01 00:00:00.000000000 +08:00 - review_decision_event: Publication of ISO 19104:2016 - review_decision_notes: Authoritative reference changed from ISO 1087-1:2000 to ISO - 1087-1:2000, 3.4.16, modified — the Note 1 to entry has been added.. Lineage source - added as ISO/TS 19104:2008 - release: '2' - terms: - - type: expression - designation: tillåten term - normative_status: preferred diff --git a/spec/concept_fixtures/paneron_glossary/localized-concept/04e539b2-4557-4d05-a603-9881ed6951c6.yaml b/spec/concept_fixtures/paneron_glossary/localized-concept/04e539b2-4557-4d05-a603-9881ed6951c6.yaml deleted file mode 100644 index d0ad2ab..0000000 --- a/spec/concept_fixtures/paneron_glossary/localized-concept/04e539b2-4557-4d05-a603-9881ed6951c6.yaml +++ /dev/null @@ -1,15 +0,0 @@ -id: 04e539b2-4557-4d05-a603-9881ed6951c6 -data: - terms: - - designation: SPP - type: expression - normative_status: preferred - language_code: eng - definition: - - content: Standards-related Publications and Projects - notes: [] - examples: [] - authoritativeSource: - - ref: MSF -status: valid -dateAccepted: 2023-06-22T19:08:31.601Z diff --git a/spec/concept_fixtures/paneron_glossary/localized_concept/04e539b2-4557-4d05-a603-9881ed6951c6.yaml b/spec/concept_fixtures/paneron_glossary/localized_concept/04e539b2-4557-4d05-a603-9881ed6951c6.yaml new file mode 100644 index 0000000..55db433 --- /dev/null +++ b/spec/concept_fixtures/paneron_glossary/localized_concept/04e539b2-4557-4d05-a603-9881ed6951c6.yaml @@ -0,0 +1,39 @@ +--- +data: + dates: + - date: 2005-07-15 00:00:00.000000000 +05:00 + type: accepted + - date: 2015-07-01 00:00:00.000000000 +05:00 + type: amended + definition: + - content: semantic relationship between two or more classifiers that specifies + connections among their instances + examples: + - content: '0' + id: '17' + notes: + - content: A binary association is an association among exactly two classifiers + (including the possibility of an association from a classifier to itself). + release: "-1" + sources: + - origin: + ref: ISO/IEC 19501 + link: https://www.iso.org/standard/32620.html + type: authoritative + status: restyle + - origin: + ref: ISO/TS 19103:2005 ,4.2.3 + type: lineage + status: identical + terms: + - type: expression + designation: association + language_code: eng + entry_status: superseded + review_date: 2009-08-31 00:00:00.000000000 +06:00 + review_decision_date: 2015-07-01 00:00:00.000000000 +05:00 + review_decision_event: Publication of ISO 19150-2:2015(E) + authoritativeSource: + - link: https://www.iso.org/standard/32620.html +dateAccepted: 2005-07-15 00:00:00.000000000 +05:00 +id: 69a29073-66d4-54ed-9960-22ae9dd98801 diff --git a/spec/concept_fixtures/v1_glossary/concept-10.yaml b/spec/concept_fixtures/v1_glossary/concept-10.yaml new file mode 100644 index 0000000..30e7b7b --- /dev/null +++ b/spec/concept_fixtures/v1_glossary/concept-10.yaml @@ -0,0 +1,181 @@ +--- +term: admitted term +termid: "10" +eng: + id: "10" + definition: + - term rated according to the scale of the term acceptability rating as a synonym for a preferred term + language_code: eng + notes: [] + examples: [] + entry_status: valid + authoritative_source: + - ref: ISO 1087-1:2000 + clause: 3.4.16, modified — the Note 1 to entry has been added. + link: https://www.iso.org/standard/20057.html + lineage_source: ISO/TS 19104:2008 + lineage_source_similarity: 1 + date_accepted: 2008-11-15 00:00:00.000000000 +08:00 + review_date: 2013-01-29 00:00:00.000000000 +08:00 + review_decision_date: 2016-10-01 00:00:00.000000000 +08:00 + review_decision_event: Publication of ISO 19104:2016 + release: '2' + terms: + - type: expression + designation: admitted term + normative_status: preferred +ara: + id: "10" + definition: + - مصطلح صنف وفقا لمقياس تصنيف قبول المصطلحات كمرادف للمصطلح المفضل + language_code: ara + notes: [] + examples: [] + entry_status: valid + authoritative_source: + - ref: ISO 1087-1:2000 + clause: 3.4.16, modified — the Note 1 to entry has been added. + link: https://www.iso.org/standard/20057.html + lineage_source: ISO/TS 19104:2008 + lineage_source_similarity: 1 + date_accepted: 2008-11-15 00:00:00.000000000 +08:00 + review_date: 2013-01-29 00:00:00.000000000 +08:00 + review_decision_date: 2016-10-01 00:00:00.000000000 +08:00 + review_decision_event: Publication of ISO 19104:2016 + release: '2' + terms: + - type: expression + designation: مصطلح معترف به + normative_status: preferred +dan: + id: "10" + definition: + - term, klassificeret efter en skala for tilladte termer, anvendt som synonym for en foretrukket term + language_code: dan + notes: [] + examples: [] + entry_status: valid + authoritative_source: + - ref: ISO 1087-1:2000 + clause: 3.4.16, modified — the Note 1 to entry has been added. + link: https://www.iso.org/standard/20057.html + lineage_source: ISO/TS 19104:2008 + lineage_source_similarity: 1 + date_accepted: 2008-11-15 00:00:00.000000000 +08:00 + review_date: 2013-01-29 00:00:00.000000000 +08:00 + review_decision_date: 2016-10-01 00:00:00.000000000 +08:00 + review_decision_event: Publication of ISO 19104:2016 + release: '2' + terms: + - type: expression + designation: tilladt term + normative_status: preferred +ger: + id: "10" + language_code: ger + notes: [] + examples: [] + entry_status: valid + authoritative_source: + - ref: ISO 1087-1:2000 + clause: 3.4.16, modified — the Note 1 to entry has been added. + link: https://www.iso.org/standard/20057.html + lineage_source: ISO/TS 19104:2008 + lineage_source_similarity: 1 + date_accepted: 2008-11-15 00:00:00.000000000 +08:00 + review_date: 2013-01-29 00:00:00.000000000 +08:00 + review_decision_date: 2016-10-01 00:00:00.000000000 +08:00 + review_decision_event: Publication of ISO 19104:2016 + release: '2' + terms: + - type: expression + designation: zugelassener Begriff + normative_status: preferred +kor: + id: "10" + definition: + - 상용 용어의 동의어로써 용어 수용가능성 등급체계에 의거하여 등급이 부여된 용어 + language_code: kor + notes: [] + examples: [] + entry_status: valid + authoritative_source: + - ref: ISO 1087-1:2000 + clause: 3.4.16, modified — the Note 1 to entry has been added. + link: https://www.iso.org/standard/20057.html + lineage_source: ISO/TS 19104:2008 + lineage_source_similarity: 1 + date_accepted: 2008-11-15 00:00:00.000000000 +08:00 + review_date: 2013-01-29 00:00:00.000000000 +08:00 + review_decision_date: 2016-10-01 00:00:00.000000000 +08:00 + review_decision_event: Publication of ISO 19104:2016 + release: '2' + terms: + - type: expression + designation: 승인 용어 + normative_status: preferred +rus: + id: "10" + definition: + - термин, оцененный по шкале рейтинга приемлемости термина как синоним предпочтительного термина + language_code: rus + notes: [] + examples: [] + entry_status: valid + authoritative_source: + - ref: ISO 1087-1:2000 + link: https://www.iso.org/standard/20057.html + lineage_source: ISO/TS 19104:2008 + lineage_source_similarity: 1 + date_accepted: 2008-11-15 00:00:00.000000000 +08:00 + release: '2' + terms: + - type: expression + designation: допустимый термин + normative_status: preferred +spa: + id: "10" + definition: + - término clasificado de acuerdo a la escala de aceptanción como un sinónimo de un término preferente + language_code: spa + notes: [] + examples: [] + entry_status: valid + authoritative_source: + - ref: ISO 1087-1:2000 + clause: 3.4.16, modified — the Note 1 to entry has been added. + link: https://www.iso.org/standard/20057.html + lineage_source: ISO/TS 19104:2008 + lineage_source_similarity: 1 + date_accepted: 2008-11-15 00:00:00.000000000 +08:00 + review_date: 2013-01-29 00:00:00.000000000 +08:00 + review_decision_date: 2016-10-01 00:00:00.000000000 +08:00 + review_decision_event: Publication of ISO 19104:2016 + release: '2' + terms: + - type: expression + designation: término admitido + normative_status: preferred +swe: + id: "10" + definition: + - term som bedömts vara lämplig för ett visst begrepp och som används vid sidan av en rekommenderad term + language_code: swe + notes: [] + examples: [] + entry_status: valid + authoritative_source: + - ref: ISO 1087-1:2000 + clause: 3.4.16, modified — the Note 1 to entry has been added. + link: https://www.iso.org/standard/20057.html + lineage_source: ISO/TS 19104:2008 + lineage_source_similarity: 1 + date_accepted: 2008-11-15 00:00:00.000000000 +08:00 + review_date: 2013-01-29 00:00:00.000000000 +08:00 + review_decision_date: 2016-10-01 00:00:00.000000000 +08:00 + review_decision_event: Publication of ISO 19104:2016 + release: '2' + terms: + - type: expression + designation: tillåten term + normative_status: preferred diff --git a/spec/unit/jekyll/geolexica/concept_serializer_spec.rb b/spec/unit/jekyll/geolexica/concept_serializer_spec.rb index 9593c19..fa85fe5 100644 --- a/spec/unit/jekyll/geolexica/concept_serializer_spec.rb +++ b/spec/unit/jekyll/geolexica/concept_serializer_spec.rb @@ -2,7 +2,7 @@ # RSpec.describe ::Jekyll::Geolexica::ConceptSerializer do - let(:concept_10) { load_concept_fixture("concept-10.yaml") } + let(:concept_10) { load_concept_fixture("v1_glossary/concept-10.yaml") } let(:serializer_10) { described_class.new(concept_10, fake_site) } let(:fake_site) do diff --git a/spec/unit/jekyll/geolexica/glossary_spec.rb b/spec/unit/jekyll/geolexica/glossary_spec.rb index 3d4f322..7f06de9 100644 --- a/spec/unit/jekyll/geolexica/glossary_spec.rb +++ b/spec/unit/jekyll/geolexica/glossary_spec.rb @@ -37,52 +37,473 @@ end context "Glossarist V2 concepts" do - describe "#load_concept" do - let(:load_concept) { subject.send(:load_concept, file_path) } - let(:file_path) { fixture_path("paneron_glossary/concept/055c7785-e3c2-4df0-bcbc-83c1314864af.yaml") } + describe "#load_glossary" do + let(:load_glossary) { subject.send(:load_glossary) } let(:expected_data) do { "id" => "055c7785-e3c2-4df0-bcbc-83c1314864af", + "term" => "association ", "termid" => "SPP", + "data" => { + "identifier" => "SPP", + "localized_concepts" => { + "eng" => "04e539b2-4557-4d05-a603-9881ed6951c6" + } + }, "eng" => { - "terms" => [{ - "designation" => "SPP", - "type" => "expression", - "normative_status" => "preferred" - }], - "language_code" => "eng", - "definition" => [{ - "content" => "Standards-related Publications and Projects" - }], - "notes" => [], - "examples" => [], + "dates" => [ + { + "date" => Time.parse("2005-07-15 00:00:00 +05:00"), + "type" => "accepted" + }, + { + "date" => Time.parse("2015-07-01 00:00:00 +05:00"), + "type" => "amended" + } + ], + "definition" => [ + { + "content" => "semantic relationship between two or more classifiers that specifies connections among their instances" + } + ], + "examples" => [ + { "content" => "0" } + ], + "id" => "17", + "notes" => [ + { + "content" => "A binary association is an association among exactly two classifiers (including the possibility of an association from a classifier to itself)." + } + ], + "release" => "-1", "sources" => [ { - "origin" => { "ref" => "MSF" }, + "origin" => { + "link" => "https://www.iso.org/standard/32620.html" + }, "type" => "authoritative" } - ] - } + ], + "terms" => [ + { + "type" => "expression", "designation" => "association " + } + ], + "language_code" => "eng", + "entry_status" => "superseded", + "review_date" => Time.parse("2009-08-31 00:00:00 +06:00"), + "review_decision_date" => Time.parse("2015-07-01 00:00:00 +05:00"), + "review_decision_event" => "Publication of ISO 19150-2:2015(E)", + }, } end before(:each) do - allow(subject).to receive(:glossary_format).and_return("paneron") - allow(subject).to receive(:localized_concepts_path).and_return(fixture_path("paneron_glossary/localized-concept")) + allow(subject).to receive(:glossary_path).and_return(fixture_path("paneron_glossary")) + allow(subject).to receive(:concepts_glob).and_return(fixture_path("paneron_glossary/concept/*")) + allow(subject).to receive(:localized_concepts_path).and_return(fixture_path("paneron_glossary/localized_concept")) end it "should change data count" do - expect { load_concept }.to change { subject.count }.from(0).to(1) + expect { load_glossary }.to change { subject.count }.from(0).to(1) end it "should load data" do - load_concept + load_glossary expect(subject["SPP"].data).to include(expected_data) end end end + context "Glossarist V1 concepts" do + describe "#load_glossary" do + let(:load_glossary) { subject.send(:load_glossary) } + + before(:each) do + allow(subject).to receive(:glossary_path).and_return(fixture_path("v1_glossary")) + end + + let(:localized_concepts) do + { + "eng" => "1296fc23-5ab7-52c2-9219-09cc3b04b1e0", + "ara" => "ea6a9deb-46b5-5f36-80d9-cbdc303d7d51", + "dan" => "a0e49de6-2818-5b4a-9ca4-ce8d19993457", + "ger" => "061ec573-6c10-5f70-8b01-062aa28161e4", + "kor" => "436e863c-80d8-5a8b-ac25-e432fac10f5c", + "rus" => "a2c61508-0c23-5c59-be68-efc09c7fe2eb", + "spa" => "b70b2224-9a4f-5583-bd2b-736087c833b5", + "swe" => "a8a854e0-e125-50bd-ac2a-1d95760eb0b5", + } + end + + let(:eng_concept) do + { + "dates" => [ + { + "date" => Time.parse("2008-11-15 00:00:00 +08:00"), + "type" => "accepted", + }, + ], + "definition" => [ + { + "content" => "term rated according to the scale of the term acceptability rating as a synonym for a preferred term", + }, + ], + "examples" => [], + "id" => "10", + "lineage_source_similarity" => 1, + "notes" => [], + "release" => "2", + "sources" => [ + { + "origin" => { + "ref" => "ISO 1087-1:2000", + "clause" => "3.4.16, modified — the Note 1 to entry has been added.", + "link" => "https://www.iso.org/standard/20057.html" + }, + "type" => "authoritative", + }, + ], + "terms" => [ + { + "type" => "expression", + "normative_status" => "preferred", + "designation" => "admitted term", + }, + ], + "language_code" => "eng", + "entry_status" => "valid", + "review_date" => Time.parse("2013-01-29 00:00:00 +08:00"), + "review_decision_date" => Time.parse("2016-10-01 00:00:00 +08:00"), + "review_decision_event" => "Publication of ISO 19104:2016", + } + end + + let(:ara_concept) do + { + "dates" => [ + { + "date" => Time.parse("2008-11-15 00:00:00 +08:00"), + "type" => "accepted", + }, + ], + "definition" => [ + { + "content" => "مصطلح صنف وفقا لمقياس تصنيف قبول المصطلحات كمرادف للمصطلح المفضل" + } + ], + "examples" => [], + "id" => "10", + "lineage_source_similarity" => 1, + "notes" => [], + "release" => "2", + "sources" => [ + { + "origin" => { + "ref" => "ISO 1087-1:2000", + "clause" => "3.4.16, modified — the Note 1 to entry has been added.", + "link" => "https://www.iso.org/standard/20057.html", + }, + "type" => "authoritative", + } + ], + "terms" => [ + { + "type" => "expression", + "normative_status" => "preferred", + "designation" => "مصطلح معترف به", + }, + ], + "language_code" => "ara", + "entry_status" => "valid", + "review_date" => Time.parse("2013-01-29 00:00:00 +08:00"), + "review_decision_date" => Time.parse("2016-10-01 00:00:00 +08:00"), + "review_decision_event" => "Publication of ISO 19104:2016", + } + end + + let(:dan_concept) do + { + "dates" => [ + { + "date" => Time.parse("2008-11-15 00:00:00 +08:00"), + "type" => "accepted", + }, + ], + "definition" => [ + { + "content" => "term, klassificeret efter en skala for tilladte termer, anvendt som synonym for en foretrukket term", + }, + ], + "examples" => [], + "id" => "10", + "lineage_source_similarity" => 1, + "notes" => [], + "release" => "2", + "sources" => [ + { + "origin" => { + "ref" => "ISO 1087-1:2000", + "clause" => "3.4.16, modified — the Note 1 to entry has been added.", + "link" => "https://www.iso.org/standard/20057.html", + }, + "type" => "authoritative", + }, + ], + "terms" => [ + { + "type" => "expression", + "normative_status" => "preferred", + "designation" => "tilladt term", + }, + ], + "language_code" => "dan", + "entry_status" => "valid", + "review_date" => Time.parse("2013-01-29 00:00:00 +08:00"), + "review_decision_date" => Time.parse("2016-10-01 00:00:00 +08:00"), + "review_decision_event" => "Publication of ISO 19104:2016", + } + end + + let(:ger_concept) do + { + "dates" => [ + { + "date" => Time.parse("2008-11-15 00:00:00 +08:00"), + "type" => "accepted", + }, + ], + "definition" => [], + "examples" => [], + "id" => "10", + "lineage_source_similarity" => 1, + "notes" => [], + "release" => "2", + "sources" => [ + { + "origin" => { + "ref" => "ISO 1087-1:2000", + "clause" => "3.4.16, modified — the Note 1 to entry has been added.", + "link" => "https://www.iso.org/standard/20057.html" + }, + "type" => "authoritative", + }, + ], + "terms" => [ + { + "type" => "expression", + "normative_status" => "preferred", + "designation" => "zugelassener Begriff", + }, + ], + "language_code" => "ger", + "entry_status" => "valid", + "review_date" => Time.parse("2013-01-29 00:00:00 +08:00"), + "review_decision_date" => Time.parse("2016-10-01 00:00:00 +08:00"), + "review_decision_event" => "Publication of ISO 19104:2016", + } + end + + let(:kor_concept) do + { + "dates" => [ + { + "date" => Time.parse("2008-11-15 00:00:00 +08:00"), + "type" => "accepted", + }, + ], + "definition" => [ + { + "content" => "상용 용어의 동의어로써 용어 수용가능성 등급체계에 의거하여 등급이 부여된 용어", + }, + ], + "examples" => [], + "id" => "10", + "lineage_source_similarity" => 1, + "notes" => [], + "release" => "2", + "sources" => [ + { + "origin" => { + "ref" => "ISO 1087-1:2000", + "clause" => "3.4.16, modified — the Note 1 to entry has been added.", + "link" => "https://www.iso.org/standard/20057.html", + }, + "type" => "authoritative", + }, + ], + "terms" => [ + { + "type" => "expression", + "normative_status" => "preferred", + "designation" => "승인 용어", + }, + ], + "language_code" => "kor", + "entry_status" => "valid", + "review_date" => Time.parse("2013-01-29 00:00:00 +08:00"), + "review_decision_date" => Time.parse("2016-10-01 00:00:00 +08:00"), + "review_decision_event" => "Publication of ISO 19104:2016", + } + end + + let(:rus_concept) do + { + "dates" => [ + { + "date" => Time.parse("2008-11-15 00:00:00 +08:00"), + "type" => "accepted", + }, + ], + "definition" => [ + { + "content" => "термин, оцененный по шкале рейтинга приемлемости термина как синоним предпочтительного термина", + }, + ], + "examples" => [], + "id" => "10", + "lineage_source_similarity" => 1, + "notes" => [], + "release" => "2", + "sources" => [ + { + "origin" => { + "ref" => "ISO 1087-1:2000", + "link" => "https://www.iso.org/standard/20057.html", + }, + "type" => "authoritative", + }, + ], + "terms" => [ + { + "type" => "expression", + "normative_status" => "preferred", + "designation" => "допустимый термин", + }, + ], + "language_code" => "rus", + "entry_status" => "valid", + } + end + + let(:spa_concept) do + { + "dates" => [ + { + "date" => Time.parse("2008-11-15 00:00:00 +08:00"), + "type" => "accepted", + }, + ], + "definition" => [ + { + "content" => "término clasificado de acuerdo a la escala de aceptanción como un sinónimo de un término preferente", + }, + ], + "examples" => [], + "id" => "10", + "lineage_source_similarity" => 1, + "notes" => [], + "release" => "2", + "sources" => [ + { + "origin" => { + "ref" => "ISO 1087-1:2000", + "clause" => "3.4.16, modified — the Note 1 to entry has been added.", + "link" => "https://www.iso.org/standard/20057.html", + }, + "type" => "authoritative", + }, + ], + "terms" => [ + { + "type" => "expression", + "normative_status" => "preferred", + "designation" => "término admitido", + }, + ], + "language_code" => "spa", + "entry_status" => "valid", + "review_date"=>Time.parse("2013-01-29 00:00:00 +08:00"), + "review_decision_date"=>Time.parse("2016-10-01 00:00:00 +08:00"), + "review_decision_event" => "Publication of ISO 19104:2016", + } + end + + let(:swe_concept) do + { + "dates" => [ + { + "date"=>Time.parse("2008-11-15 00:00:00 +08:00"), + "type" => "accepted", + }, + ], + "definition" => [ + { + "content" => "term som bedömts vara lämplig för ett visst begrepp och som används vid sidan av en rekommenderad term", + }, + ], + "examples" => [], + "id" => "10", + "lineage_source_similarity" => 1, + "notes" => [], + "release" => "2", + "sources" => [ + { + "origin" => { + "ref" => "ISO 1087-1:2000", + "clause" => "3.4.16, modified — the Note 1 to entry has been added.", + "link" => "https://www.iso.org/standard/20057.html", + }, + "type" => "authoritative", + }, + ], + "terms" => [ + { + "type" => "expression", + "normative_status" => "preferred", + "designation" => "tillåten term", + }, + ], + "language_code" => "swe", + "entry_status" => "valid", + "review_date" => Time.parse("2013-01-29 00:00:00 +08:00"), + "review_decision_date" => Time.parse("2016-10-01 00:00:00 +08:00"), + "review_decision_event" => "Publication of ISO 19104:2016", + } + end + + let(:expected_data) do + { + "id" => "18e02fe9-e52d-50a0-84ac-9fccae815fbd", + "term" => "admitted term", + "termid" => "10", + "data" => { + "identifier" => "10", + "localized_concepts" => localized_concepts, + }, + "eng" => eng_concept, + "ara" => ara_concept, + "dan" => dan_concept, + "ger" => ger_concept, + "kor" => kor_concept, + "rus" => rus_concept, + "spa" => spa_concept, + "swe" => swe_concept, + } + end + + it "should change data count" do + expect { load_glossary }.to change { subject.count }.from(0).to(1) + end + + it "should load data" do + load_glossary + expect(subject["10"].data).to include(expected_data) + end + end + end + def add_concepts(*concept_hashes) concepts = concept_hashes.map { |h| described_class::Concept.new(h) } concepts.each { |c| instance.store c }