relaton 2.1.0 → 3.0.0.pre.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/{docs/README.adoc → README.adoc} +109 -38
- data/lib/relaton/3gpp/bibdata.rb +9 -0
- data/lib/relaton/3gpp/bibitem.rb +9 -0
- data/lib/relaton/3gpp/bibliography.rb +48 -0
- data/lib/relaton/3gpp/data_fetcher.rb +255 -0
- data/lib/relaton/3gpp/doctype.rb +9 -0
- data/lib/relaton/3gpp/ext.rb +31 -0
- data/lib/relaton/3gpp/item.rb +12 -0
- data/lib/relaton/3gpp/item_data.rb +15 -0
- data/lib/relaton/3gpp/parser.rb +400 -0
- data/lib/relaton/3gpp/processor.rb +68 -0
- data/lib/relaton/3gpp/release.rb +34 -0
- data/lib/relaton/3gpp/util.rb +8 -0
- data/lib/relaton/3gpp.rb +25 -0
- data/lib/relaton/bib/converter/asciibib/to_asciibib.rb +663 -0
- data/lib/relaton/bib/converter/asciibib.rb +13 -0
- data/lib/relaton/bib/converter/bibtex/from_bibtex.rb +245 -0
- data/lib/relaton/bib/converter/bibtex/to_bibtex.rb +341 -0
- data/lib/relaton/bib/converter/bibtex.rb +23 -0
- data/lib/relaton/bib/converter/bibxml/from_rfcxml.rb +386 -0
- data/lib/relaton/bib/converter/bibxml/from_rfcxml_referencegroup.rb +71 -0
- data/lib/relaton/bib/converter/bibxml/to_rfcxml.rb +308 -0
- data/lib/relaton/bib/converter/bibxml/to_rfcxml_referencegroup.rb +52 -0
- data/lib/relaton/bib/converter/bibxml.rb +51 -0
- data/lib/relaton/bib/hash_parser_v1.rb +767 -0
- data/lib/relaton/bib/item_data.rb +229 -0
- data/lib/relaton/bib/model/abstract.rb +16 -0
- data/lib/relaton/bib/model/address.rb +22 -0
- data/lib/relaton/bib/model/affiliation.rb +16 -0
- data/lib/relaton/bib/model/bibdata.rb +11 -0
- data/lib/relaton/bib/model/bibdata_shared.rb +12 -0
- data/lib/relaton/bib/model/bibitem.rb +11 -0
- data/lib/relaton/bib/model/bibitem_shared.rb +12 -0
- data/lib/relaton/bib/model/contact.rb +18 -0
- data/lib/relaton/bib/model/contribution_info.rb +15 -0
- data/lib/relaton/bib/model/contributor.rb +29 -0
- data/lib/relaton/bib/model/copyright.rb +27 -0
- data/lib/relaton/bib/model/date.rb +31 -0
- data/lib/relaton/bib/model/depiction.rb +16 -0
- data/lib/relaton/bib/model/docidentifier.rb +34 -0
- data/lib/relaton/bib/model/doctype.rb +14 -0
- data/lib/relaton/bib/model/edition.rb +14 -0
- data/lib/relaton/bib/model/ext.rb +39 -0
- data/lib/relaton/bib/model/extent.rb +16 -0
- data/lib/relaton/bib/model/formattedref.rb +43 -0
- data/lib/relaton/bib/model/full_name_type.rb +64 -0
- data/lib/relaton/bib/model/fullname.rb +11 -0
- data/lib/relaton/bib/model/ics.rb +49 -0
- data/lib/relaton/bib/model/image.rb +28 -0
- data/lib/relaton/bib/model/item.rb +96 -0
- data/lib/relaton/bib/model/item_base.rb +20 -0
- data/lib/relaton/bib/model/item_shared.rb +88 -0
- data/lib/relaton/bib/model/keyword.rb +30 -0
- data/lib/relaton/bib/model/locality.rb +18 -0
- data/lib/relaton/bib/model/locality_stack.rb +14 -0
- data/lib/relaton/bib/model/localized_string.rb +48 -0
- data/lib/relaton/bib/model/localized_string_attrs.rb +24 -0
- data/lib/relaton/bib/model/logo.rb +14 -0
- data/lib/relaton/bib/model/medium.rb +22 -0
- data/lib/relaton/bib/model/note.rb +16 -0
- data/lib/relaton/bib/model/organization.rb +13 -0
- data/lib/relaton/bib/model/organization_type.rb +42 -0
- data/lib/relaton/bib/model/person.rb +36 -0
- data/lib/relaton/bib/model/phone.rb +14 -0
- data/lib/relaton/bib/model/place.rb +33 -0
- data/lib/relaton/bib/model/price.rb +14 -0
- data/lib/relaton/bib/model/relation.rb +43 -0
- data/lib/relaton/bib/model/series.rb +34 -0
- data/lib/relaton/bib/model/size.rb +23 -0
- data/lib/relaton/bib/model/source_locality_stack.rb +14 -0
- data/lib/relaton/bib/model/status.rb +27 -0
- data/lib/relaton/bib/model/structured_identifier.rb +48 -0
- data/lib/relaton/bib/model/subdivision.rb +16 -0
- data/lib/relaton/bib/model/title.rb +56 -0
- data/lib/relaton/bib/model/type/plain_date.rb +16 -0
- data/lib/relaton/bib/model/type/string_date.rb +48 -0
- data/lib/relaton/bib/model/uri.rb +18 -0
- data/lib/relaton/bib/model/validity.rb +16 -0
- data/lib/relaton/bib/model/version.rb +43 -0
- data/lib/relaton/bib/namespace_helper.rb +21 -0
- data/lib/relaton/bib/sanitizer.rb +68 -0
- data/lib/relaton/bib/util.rb +18 -0
- data/lib/relaton/bib/versions.json +35 -0
- data/lib/relaton/bib.rb +48 -0
- data/lib/relaton/bipm/bibliography.rb +82 -0
- data/lib/relaton/bipm/converter/asciibib.rb +64 -0
- data/lib/relaton/bipm/data_fetcher.rb +57 -0
- data/lib/relaton/bipm/data_outcomes_parser.rb +657 -0
- data/lib/relaton/bipm/id_parser.rb +277 -0
- data/lib/relaton/bipm/item_data.rb +47 -0
- data/lib/relaton/bipm/model/bibdata.rb +9 -0
- data/lib/relaton/bipm/model/bibitem.rb +9 -0
- data/lib/relaton/bipm/model/comment_period.rb +13 -0
- data/lib/relaton/bipm/model/doctype.rb +12 -0
- data/lib/relaton/bipm/model/ext.rb +38 -0
- data/lib/relaton/bipm/model/item.rb +11 -0
- data/lib/relaton/bipm/model/structured_identifier.rb +15 -0
- data/lib/relaton/bipm/processor.rb +69 -0
- data/lib/relaton/bipm/rawdata_bipm_metrologia/affiliations.rb +111 -0
- data/lib/relaton/bipm/rawdata_bipm_metrologia/fetcher.rb +174 -0
- data/lib/relaton/bipm/rawdata_bipm_metrologia/niso_jats_parser.rb +353 -0
- data/lib/relaton/bipm/si_brochure_parser.rb +186 -0
- data/lib/relaton/bipm/util.rb +8 -0
- data/lib/relaton/bipm.rb +32 -0
- data/lib/relaton/bsi/bibliography.rb +124 -0
- data/lib/relaton/bsi/hit.rb +14 -0
- data/lib/relaton/bsi/hit_collection.rb +114 -0
- data/lib/relaton/bsi/item_data.rb +13 -0
- data/lib/relaton/bsi/model/bibdata.rb +8 -0
- data/lib/relaton/bsi/model/bibitem.rb +8 -0
- data/lib/relaton/bsi/model/docidentifier.rb +9 -0
- data/lib/relaton/bsi/model/doctype.rb +14 -0
- data/lib/relaton/bsi/model/ext.rb +17 -0
- data/lib/relaton/bsi/model/item.rb +17 -0
- data/lib/relaton/bsi/model/item_base.rb +22 -0
- data/lib/relaton/bsi/model/relation.rb +9 -0
- data/lib/relaton/bsi/processor.rb +42 -0
- data/lib/relaton/bsi/schema.json +24882 -0
- data/lib/relaton/bsi/scraper.rb +288 -0
- data/lib/relaton/bsi/util.rb +8 -0
- data/lib/relaton/bsi.rb +25 -0
- data/lib/relaton/calconnect/bibliography.rb +95 -0
- data/lib/relaton/calconnect/data_fetcher.rb +106 -0
- data/lib/relaton/calconnect/hit.rb +14 -0
- data/lib/relaton/calconnect/hit_collection.rb +84 -0
- data/lib/relaton/calconnect/item_data.rb +12 -0
- data/lib/relaton/calconnect/model/bibdata.rb +8 -0
- data/lib/relaton/calconnect/model/bibitem.rb +8 -0
- data/lib/relaton/calconnect/model/doctype.rb +11 -0
- data/lib/relaton/calconnect/model/ext.rb +11 -0
- data/lib/relaton/calconnect/model/item.rb +13 -0
- data/lib/relaton/calconnect/processor.rb +66 -0
- data/lib/relaton/calconnect/scraper.rb +87 -0
- data/lib/relaton/calconnect/util.rb +8 -0
- data/lib/relaton/calconnect.rb +26 -0
- data/lib/relaton/ccsds/bibliography.rb +63 -0
- data/lib/relaton/ccsds/data/fetcher.rb +247 -0
- data/lib/relaton/ccsds/data/iso_references.rb +30 -0
- data/lib/relaton/ccsds/data/parser.rb +194 -0
- data/lib/relaton/ccsds/hit.rb +24 -0
- data/lib/relaton/ccsds/hit_collection.rb +42 -0
- data/lib/relaton/ccsds/item_data.rb +9 -0
- data/lib/relaton/ccsds/model/bibdata.rb +8 -0
- data/lib/relaton/ccsds/model/bibitem.rb +8 -0
- data/lib/relaton/ccsds/model/doctype.rb +9 -0
- data/lib/relaton/ccsds/model/ext.rb +19 -0
- data/lib/relaton/ccsds/model/item.rb +13 -0
- data/lib/relaton/ccsds/processor.rb +68 -0
- data/lib/relaton/ccsds/util.rb +10 -0
- data/lib/relaton/ccsds.rb +33 -0
- data/lib/relaton/cen/bibliography.rb +121 -0
- data/lib/relaton/cen/committees.yaml +66 -0
- data/lib/relaton/cen/hit.rb +16 -0
- data/lib/relaton/cen/hit_collection.rb +68 -0
- data/lib/relaton/cen/item_data.rb +7 -0
- data/lib/relaton/cen/model/bibdata.rb +8 -0
- data/lib/relaton/cen/model/bibitem.rb +8 -0
- data/lib/relaton/cen/model/docidentifier.rb +9 -0
- data/lib/relaton/cen/model/ext.rb +11 -0
- data/lib/relaton/cen/model/item.rb +14 -0
- data/lib/relaton/cen/model/structured_identifier.rb +9 -0
- data/lib/relaton/cen/processor.rb +40 -0
- data/lib/relaton/cen/scraper.rb +210 -0
- data/lib/relaton/cen/util.rb +8 -0
- data/lib/relaton/cen.rb +29 -0
- data/lib/relaton/cie/bibdata.rb +8 -0
- data/lib/relaton/cie/bibitem.rb +8 -0
- data/lib/relaton/cie/bibliography.rb +31 -0
- data/lib/relaton/cie/data_fetcher.rb +355 -0
- data/lib/relaton/cie/ext.rb +7 -0
- data/lib/relaton/cie/item.rb +11 -0
- data/lib/relaton/cie/item_data.rb +6 -0
- data/lib/relaton/cie/processor.rb +66 -0
- data/lib/relaton/cie/scrapper.rb +39 -0
- data/lib/relaton/cie/util.rb +8 -0
- data/lib/relaton/cie.rb +28 -0
- data/lib/relaton/core/array_wrapper.rb +20 -0
- data/lib/relaton/core/data_fetcher.rb +97 -0
- data/lib/relaton/core/date_parser.rb +42 -0
- data/lib/relaton/core/hash_keys_sybolizer.rb +19 -0
- data/lib/relaton/core/hit.rb +49 -0
- data/lib/relaton/core/hit_collection.rb +118 -0
- data/lib/relaton/core/processor.rb +48 -0
- data/lib/relaton/core/workers_pool.rb +45 -0
- data/lib/relaton/core.rb +9 -0
- data/lib/relaton/db/cache.rb +232 -0
- data/lib/relaton/db/config.rb +24 -0
- data/lib/relaton/db/registry.rb +119 -0
- data/lib/relaton/db/util.rb +9 -0
- data/lib/relaton/db/workers_pool.rb +22 -0
- data/lib/relaton/db.rb +20 -206
- data/lib/relaton/doi/crossref.rb +72 -0
- data/lib/relaton/doi/parser.rb +827 -0
- data/lib/relaton/doi/processor.rb +65 -0
- data/lib/relaton/doi/util.rb +8 -0
- data/lib/relaton/doi.rb +20 -0
- data/lib/relaton/ecma/bibdata.rb +8 -0
- data/lib/relaton/ecma/bibitem.rb +8 -0
- data/lib/relaton/ecma/bibliography.rb +81 -0
- data/lib/relaton/ecma/data_fetcher.rb +103 -0
- data/lib/relaton/ecma/data_parser.rb +49 -0
- data/lib/relaton/ecma/edition_parser.rb +80 -0
- data/lib/relaton/ecma/ext.rb +7 -0
- data/lib/relaton/ecma/item.rb +11 -0
- data/lib/relaton/ecma/item_data.rb +6 -0
- data/lib/relaton/ecma/memento_parser.rb +60 -0
- data/lib/relaton/ecma/page_fetcher.rb +27 -0
- data/lib/relaton/ecma/parser_common.rb +33 -0
- data/lib/relaton/ecma/processor.rb +66 -0
- data/lib/relaton/ecma/standard_parser.rb +134 -0
- data/lib/relaton/ecma/util.rb +8 -0
- data/lib/relaton/ecma.rb +24 -0
- data/lib/relaton/etsi/bibdata.rb +10 -0
- data/lib/relaton/etsi/bibitem.rb +10 -0
- data/lib/relaton/etsi/bibliography.rb +46 -0
- data/lib/relaton/etsi/data_fetcher.rb +128 -0
- data/lib/relaton/etsi/data_parser.rb +208 -0
- data/lib/relaton/etsi/doctype.rb +30 -0
- data/lib/relaton/etsi/ext.rb +31 -0
- data/lib/relaton/etsi/item.rb +15 -0
- data/lib/relaton/etsi/item_data.rb +6 -0
- data/lib/relaton/etsi/processor.rb +69 -0
- data/lib/relaton/etsi/pubid.rb +37 -0
- data/lib/relaton/etsi/status.rb +13 -0
- data/lib/relaton/etsi/util.rb +8 -0
- data/lib/relaton/etsi.rb +25 -0
- data/lib/relaton/gb/bibdata.rb +8 -0
- data/lib/relaton/gb/bibitem.rb +8 -0
- data/lib/relaton/gb/bibliography.rb +145 -0
- data/lib/relaton/gb/ccs.rb +14 -0
- data/lib/relaton/gb/committee.rb +13 -0
- data/lib/relaton/gb/docidentifier.rb +23 -0
- data/lib/relaton/gb/doctype.rb +9 -0
- data/lib/relaton/gb/ext.rb +36 -0
- data/lib/relaton/gb/gb_scraper.rb +61 -0
- data/lib/relaton/gb/gb_type.rb +20 -0
- data/lib/relaton/gb/hit.rb +48 -0
- data/lib/relaton/gb/hit_collection.rb +19 -0
- data/lib/relaton/gb/item.rb +13 -0
- data/lib/relaton/gb/item_data.rb +6 -0
- data/lib/relaton/gb/processor.rb +46 -0
- data/lib/relaton/gb/project_number.rb +38 -0
- data/lib/relaton/gb/scraper.rb +204 -0
- data/lib/relaton/gb/sec_scraper.rb +92 -0
- data/lib/relaton/gb/stage_name.rb +13 -0
- data/lib/relaton/gb/structured_identifier.rb +26 -0
- data/lib/relaton/gb/t_scraper.rb +126 -0
- data/lib/relaton/gb/util.rb +8 -0
- data/lib/relaton/gb/yaml/prefixes.yaml +200 -0
- data/lib/relaton/gb.rb +33 -0
- data/lib/relaton/iana/bibdata.rb +8 -0
- data/lib/relaton/iana/bibitem.rb +8 -0
- data/lib/relaton/iana/bibliography.rb +47 -0
- data/lib/relaton/iana/data_fetcher.rb +71 -0
- data/lib/relaton/iana/item.rb +7 -0
- data/lib/relaton/iana/item_data.rb +6 -0
- data/lib/relaton/iana/parser.rb +146 -0
- data/lib/relaton/iana/processor.rb +68 -0
- data/lib/relaton/iana/util.rb +8 -0
- data/lib/relaton/iana.rb +29 -0
- data/lib/relaton/iec/bibliography.rb +283 -0
- data/lib/relaton/iec/data_fetcher.rb +216 -0
- data/lib/relaton/iec/data_parser.rb +391 -0
- data/lib/relaton/iec/hit.rb +26 -0
- data/lib/relaton/iec/hit_collection.rb +138 -0
- data/lib/relaton/iec/item_data.rb +7 -0
- data/lib/relaton/iec/model/bibdata.rb +8 -0
- data/lib/relaton/iec/model/bibitem.rb +8 -0
- data/lib/relaton/iec/model/docidentifier.rb +131 -0
- data/lib/relaton/iec/model/doctype.rb +12 -0
- data/lib/relaton/iec/model/ext.rb +53 -0
- data/lib/relaton/iec/model/item.rb +20 -0
- data/lib/relaton/iec/model/item_base.rb +12 -0
- data/lib/relaton/iec/model/relation.rb +7 -0
- data/lib/relaton/iec/model/stage_name.rb +13 -0
- data/lib/relaton/iec/processor.rb +73 -0
- data/lib/relaton/iec/statuses.yml +199 -0
- data/lib/relaton/iec/util.rb +8 -0
- data/lib/relaton/iec.rb +98 -0
- data/lib/relaton/ieee/balloting_group.rb +13 -0
- data/lib/relaton/ieee/bibdata.rb +8 -0
- data/lib/relaton/ieee/bibitem.rb +8 -0
- data/lib/relaton/ieee/bibliography.rb +51 -0
- data/lib/relaton/ieee/converter/bibxml/from_rfcxml.rb +10 -0
- data/lib/relaton/ieee/converter/bibxml/from_rfcxml_referencegroup.rb +10 -0
- data/lib/relaton/ieee/converter/bibxml.rb +20 -0
- data/lib/relaton/ieee/data_fetcher.rb +630 -0
- data/lib/relaton/ieee/doctype.rb +9 -0
- data/lib/relaton/ieee/editorial_group.rb +19 -0
- data/lib/relaton/ieee/ext.rb +36 -0
- data/lib/relaton/ieee/idams_parser.rb +323 -0
- data/lib/relaton/ieee/item.rb +11 -0
- data/lib/relaton/ieee/item_data.rb +7 -0
- data/lib/relaton/ieee/processor.rb +68 -0
- data/lib/relaton/ieee/pub_id.rb +161 -0
- data/lib/relaton/ieee/rawbib_id_parser.rb +548 -0
- data/lib/relaton/ieee/util.rb +8 -0
- data/lib/relaton/ieee.rb +29 -0
- data/lib/relaton/ietf/bibdata.rb +8 -0
- data/lib/relaton/ietf/bibitem.rb +8 -0
- data/lib/relaton/ietf/bibliography.rb +35 -0
- data/lib/relaton/ietf/bibxml_parser.rb +232 -0
- data/lib/relaton/ietf/data_fetcher.rb +278 -0
- data/lib/relaton/ietf/doctype.rb +9 -0
- data/lib/relaton/ietf/ext.rb +63 -0
- data/lib/relaton/ietf/item.rb +16 -0
- data/lib/relaton/ietf/item_base.rb +18 -0
- data/lib/relaton/ietf/item_data.rb +6 -0
- data/lib/relaton/ietf/processing_instructions.rb +79 -0
- data/lib/relaton/ietf/processor.rb +68 -0
- data/lib/relaton/ietf/relation.rb +9 -0
- data/lib/relaton/ietf/rfc/abstract.rb +19 -0
- data/lib/relaton/ietf/rfc/author.rb +21 -0
- data/lib/relaton/ietf/rfc/entry.rb +410 -0
- data/lib/relaton/ietf/rfc/entry_date.rb +21 -0
- data/lib/relaton/ietf/rfc/format.rb +19 -0
- data/lib/relaton/ietf/rfc/index.rb +46 -0
- data/lib/relaton/ietf/rfc/is_also.rb +21 -0
- data/lib/relaton/ietf/rfc/keywords.rb +19 -0
- data/lib/relaton/ietf/rfc/rfc_index_namespace.rb +11 -0
- data/lib/relaton/ietf/scraper.rb +68 -0
- data/lib/relaton/ietf/util.rb +8 -0
- data/lib/relaton/ietf/wg_name_resolver.rb +42 -0
- data/lib/relaton/ietf.rb +27 -0
- data/lib/relaton/iho/bibdata.rb +8 -0
- data/lib/relaton/iho/bibitem.rb +8 -0
- data/lib/relaton/iho/bibliography.rb +114 -0
- data/lib/relaton/iho/comment_period.rb +13 -0
- data/lib/relaton/iho/docidentifier.rb +31 -0
- data/lib/relaton/iho/doctype.rb +10 -0
- data/lib/relaton/iho/ext.rb +20 -0
- data/lib/relaton/iho/hash_parser_v1.rb +144 -0
- data/lib/relaton/iho/item.rb +20 -0
- data/lib/relaton/iho/item_base.rb +18 -0
- data/lib/relaton/iho/item_data.rb +6 -0
- data/lib/relaton/iho/processor.rb +54 -0
- data/lib/relaton/iho/relation.rb +9 -0
- data/lib/relaton/iho/structured_identifier.rb +20 -0
- data/lib/relaton/iho/util.rb +8 -0
- data/lib/relaton/iho.rb +27 -0
- data/lib/relaton/index/config.rb +52 -0
- data/lib/relaton/index/file_io.rb +305 -0
- data/lib/relaton/index/file_storage.rb +61 -0
- data/lib/relaton/index/id_number.rb +30 -0
- data/lib/relaton/index/pool.rb +41 -0
- data/lib/relaton/index/type.rb +159 -0
- data/lib/relaton/index/util.rb +18 -0
- data/lib/relaton/index.rb +60 -0
- data/lib/relaton/isbn/isbn.rb +61 -0
- data/lib/relaton/isbn/open_library.rb +43 -0
- data/lib/relaton/isbn/parser.rb +88 -0
- data/lib/relaton/isbn/processor.rb +48 -0
- data/lib/relaton/isbn/util.rb +8 -0
- data/lib/relaton/isbn.rb +19 -0
- data/lib/relaton/iso/bibliography.rb +407 -0
- data/lib/relaton/iso/data_fetcher.rb +338 -0
- data/lib/relaton/iso/data_parser.rb +444 -0
- data/lib/relaton/iso/hash_parser_v1.rb +177 -0
- data/lib/relaton/iso/hit.rb +57 -0
- data/lib/relaton/iso/hit_collection.rb +184 -0
- data/lib/relaton/iso/item_data.rb +28 -0
- data/lib/relaton/iso/model/bibdata.rb +10 -0
- data/lib/relaton/iso/model/bibitem.rb +8 -0
- data/lib/relaton/iso/model/contributor.rb +6 -0
- data/lib/relaton/iso/model/contributor_info.rb +9 -0
- data/lib/relaton/iso/model/docidentifier.rb +134 -0
- data/lib/relaton/iso/model/doctype.rb +13 -0
- data/lib/relaton/iso/model/ext.rb +35 -0
- data/lib/relaton/iso/model/item.rb +17 -0
- data/lib/relaton/iso/model/item_base.rb +22 -0
- data/lib/relaton/iso/model/organization.rb +9 -0
- data/lib/relaton/iso/model/project_number.rb +22 -0
- data/lib/relaton/iso/model/relation.rb +9 -0
- data/lib/relaton/iso/model/stagename.rb +14 -0
- data/lib/relaton/iso/model/structured_identifier.rb +31 -0
- data/lib/relaton/iso/processor.rb +84 -0
- data/lib/relaton/iso/scraper.rb +619 -0
- data/lib/relaton/iso/type/pubid.rb +50 -0
- data/lib/relaton/iso/util.rb +8 -0
- data/lib/relaton/iso.rb +30 -0
- data/lib/relaton/itu/bibliography.rb +90 -0
- data/lib/relaton/itu/data_fetcher.rb +104 -0
- data/lib/relaton/itu/data_parser_r.rb +140 -0
- data/lib/relaton/itu/hit.rb +22 -0
- data/lib/relaton/itu/hit_collection.rb +127 -0
- data/lib/relaton/itu/item_data.rb +6 -0
- data/lib/relaton/itu/model/approval_stage.rb +13 -0
- data/lib/relaton/itu/model/bibdata.rb +8 -0
- data/lib/relaton/itu/model/bibitem.rb +8 -0
- data/lib/relaton/itu/model/docidentifier.rb +9 -0
- data/lib/relaton/itu/model/doctype.rb +13 -0
- data/lib/relaton/itu/model/ext.rb +47 -0
- data/lib/relaton/itu/model/item.rb +13 -0
- data/lib/relaton/itu/model/meeting.rb +13 -0
- data/lib/relaton/itu/model/meeting_date.rb +15 -0
- data/lib/relaton/itu/model/question.rb +13 -0
- data/lib/relaton/itu/model/recommendation_status.rb +11 -0
- data/lib/relaton/itu/model/structured_identifier.rb +19 -0
- data/lib/relaton/itu/processor.rb +66 -0
- data/lib/relaton/itu/pubid.rb +177 -0
- data/lib/relaton/itu/radio_regulations_parser.rb +70 -0
- data/lib/relaton/itu/recommendation_parser.rb +161 -0
- data/lib/relaton/itu/scraper.rb +193 -0
- data/lib/relaton/itu/util.rb +8 -0
- data/lib/relaton/itu.rb +33 -0
- data/lib/relaton/jis/bibdata.rb +8 -0
- data/lib/relaton/jis/bibitem.rb +8 -0
- data/lib/relaton/jis/bibliography.rb +75 -0
- data/lib/relaton/jis/data_fetcher.rb +181 -0
- data/lib/relaton/jis/docidentifier.rb +21 -0
- data/lib/relaton/jis/doctype.rb +9 -0
- data/lib/relaton/jis/ext.rb +13 -0
- data/lib/relaton/jis/hit.rb +93 -0
- data/lib/relaton/jis/hit_collection.rb +127 -0
- data/lib/relaton/jis/item.rb +22 -0
- data/lib/relaton/jis/item_base.rb +26 -0
- data/lib/relaton/jis/item_data.rb +8 -0
- data/lib/relaton/jis/processor.rb +55 -0
- data/lib/relaton/jis/relation.rb +11 -0
- data/lib/relaton/jis/scraper.rb +232 -0
- data/lib/relaton/jis/structured_identifier.rb +13 -0
- data/lib/relaton/jis/util.rb +8 -0
- data/lib/relaton/jis.rb +33 -0
- data/lib/relaton/logger/channels/gh_issue.rb +78 -0
- data/lib/relaton/logger/config.rb +34 -0
- data/lib/relaton/logger/formatter_json.rb +8 -0
- data/lib/relaton/logger/formatter_string.rb +12 -0
- data/lib/relaton/logger/log.rb +64 -0
- data/lib/relaton/logger/log_device.rb +27 -0
- data/lib/relaton/logger/pool.rb +24 -0
- data/lib/relaton/logger.rb +18 -0
- data/lib/relaton/nist/bibdata.rb +8 -0
- data/lib/relaton/nist/bibitem.rb +8 -0
- data/lib/relaton/nist/bibliography.rb +191 -0
- data/lib/relaton/nist/comment_period.rb +15 -0
- data/lib/relaton/nist/data_fetcher.rb +84 -0
- data/lib/relaton/nist/date.rb +7 -0
- data/lib/relaton/nist/doctype.rb +7 -0
- data/lib/relaton/nist/ext.rb +16 -0
- data/lib/relaton/nist/hit.rb +18 -0
- data/lib/relaton/nist/hit_collection.rb +362 -0
- data/lib/relaton/nist/item.rb +17 -0
- data/lib/relaton/nist/item_data.rb +6 -0
- data/lib/relaton/nist/mods_parser.rb +276 -0
- data/lib/relaton/nist/processor.rb +68 -0
- data/lib/relaton/nist/pubs_export.rb +69 -0
- data/lib/relaton/nist/relation.rb +7 -0
- data/lib/relaton/nist/scraper.rb +290 -0
- data/lib/relaton/nist/series.yaml +49 -0
- data/lib/relaton/nist/util.rb +8 -0
- data/lib/relaton/nist.rb +34 -0
- data/lib/relaton/oasis/bibdata.rb +8 -0
- data/lib/relaton/oasis/bibitem.rb +8 -0
- data/lib/relaton/oasis/bibliography.rb +60 -0
- data/lib/relaton/oasis/browser_agent.rb +71 -0
- data/lib/relaton/oasis/data_fetcher.rb +94 -0
- data/lib/relaton/oasis/data_parser.rb +305 -0
- data/lib/relaton/oasis/data_parser_utils.rb +296 -0
- data/lib/relaton/oasis/data_part_parser.rb +239 -0
- data/lib/relaton/oasis/doctype.rb +7 -0
- data/lib/relaton/oasis/ext.rb +19 -0
- data/lib/relaton/oasis/item.rb +11 -0
- data/lib/relaton/oasis/item_data.rb +6 -0
- data/lib/relaton/oasis/processor.rb +68 -0
- data/lib/relaton/oasis/util.rb +8 -0
- data/lib/relaton/oasis.rb +28 -0
- data/lib/relaton/ogc/bibdata.rb +8 -0
- data/lib/relaton/ogc/bibitem.rb +8 -0
- data/lib/relaton/ogc/bibliography.rb +64 -0
- data/lib/relaton/ogc/data_fetcher.rb +110 -0
- data/lib/relaton/ogc/docidentifier.rb +6 -0
- data/lib/relaton/ogc/doctype.rb +12 -0
- data/lib/relaton/ogc/ext.rb +15 -0
- data/lib/relaton/ogc/hit.rb +18 -0
- data/lib/relaton/ogc/hit_collection.rb +36 -0
- data/lib/relaton/ogc/item.rb +13 -0
- data/lib/relaton/ogc/item_data.rb +6 -0
- data/lib/relaton/ogc/processor.rb +58 -0
- data/lib/relaton/ogc/scraper.rb +225 -0
- data/lib/relaton/ogc/util.rb +8 -0
- data/lib/relaton/ogc.rb +26 -0
- data/lib/relaton/oiml/bibdata.rb +8 -0
- data/lib/relaton/oiml/bibitem.rb +8 -0
- data/lib/relaton/oiml/bibliography.rb +94 -0
- data/lib/relaton/oiml/docidentifier.rb +33 -0
- data/lib/relaton/oiml/doctype.rb +13 -0
- data/lib/relaton/oiml/ext.rb +42 -0
- data/lib/relaton/oiml/item.rb +20 -0
- data/lib/relaton/oiml/item_base.rb +18 -0
- data/lib/relaton/oiml/item_data.rb +6 -0
- data/lib/relaton/oiml/processor.rb +54 -0
- data/lib/relaton/oiml/relation.rb +9 -0
- data/lib/relaton/oiml/util.rb +8 -0
- data/lib/relaton/oiml.rb +24 -0
- data/lib/relaton/omg/bibdata.rb +8 -0
- data/lib/relaton/omg/bibitem.rb +8 -0
- data/lib/relaton/omg/bibliography.rb +31 -0
- data/lib/relaton/omg/ext.rb +7 -0
- data/lib/relaton/omg/item.rb +8 -0
- data/lib/relaton/omg/item_data.rb +6 -0
- data/lib/relaton/omg/processor.rb +34 -0
- data/lib/relaton/omg/scraper.rb +141 -0
- data/lib/relaton/omg/util.rb +8 -0
- data/lib/relaton/omg.rb +24 -0
- data/lib/relaton/plateau/bibdata.rb +8 -0
- data/lib/relaton/plateau/bibitem.rb +8 -0
- data/lib/relaton/plateau/bibliography.rb +24 -0
- data/lib/relaton/plateau/data_fetcher.rb +153 -0
- data/lib/relaton/plateau/doctype.rb +7 -0
- data/lib/relaton/plateau/ext.rb +23 -0
- data/lib/relaton/plateau/handbook_parser.rb +95 -0
- data/lib/relaton/plateau/hit.rb +13 -0
- data/lib/relaton/plateau/hit_collection.rb +59 -0
- data/lib/relaton/plateau/item.rb +12 -0
- data/lib/relaton/plateau/item_data.rb +6 -0
- data/lib/relaton/plateau/parser.rb +101 -0
- data/lib/relaton/plateau/processor.rb +49 -0
- data/lib/relaton/plateau/technical_report_parser.rb +91 -0
- data/lib/relaton/plateau/util.rb +8 -0
- data/lib/relaton/plateau.rb +28 -0
- data/lib/relaton/un/bibdata.rb +8 -0
- data/lib/relaton/un/bibitem.rb +8 -0
- data/lib/relaton/un/bibliography.rb +48 -0
- data/lib/relaton/un/doctype.rb +10 -0
- data/lib/relaton/un/ext.rb +30 -0
- data/lib/relaton/un/hit.rb +56 -0
- data/lib/relaton/un/hit_collection.rb +61 -0
- data/lib/relaton/un/item.rb +11 -0
- data/lib/relaton/un/item_data.rb +6 -0
- data/lib/relaton/un/parser.rb +108 -0
- data/lib/relaton/un/processor.rb +38 -0
- data/lib/relaton/un/session.rb +25 -0
- data/lib/relaton/un/token_generator.rb +105 -0
- data/lib/relaton/un/util.rb +8 -0
- data/lib/relaton/un/wasm/decoder.rb +434 -0
- data/lib/relaton/un/wasm/instance.rb +101 -0
- data/lib/relaton/un/wasm/interpreter.rb +613 -0
- data/lib/relaton/un/wasm/memory.rb +112 -0
- data/lib/relaton/un/wasm/module.rb +47 -0
- data/lib/relaton/un/wasm.rb +17 -0
- data/lib/relaton/un/wasm_v_bg.wasm +0 -0
- data/lib/relaton/un.rb +28 -0
- data/lib/relaton/version.rb +1 -1
- data/lib/relaton/w3c/bibdata.rb +8 -0
- data/lib/relaton/w3c/bibitem.rb +8 -0
- data/lib/relaton/w3c/bibliography.rb +54 -0
- data/lib/relaton/w3c/data_fetcher.rb +309 -0
- data/lib/relaton/w3c/data_parser.rb +379 -0
- data/lib/relaton/w3c/doctype.rb +7 -0
- data/lib/relaton/w3c/ext.rb +11 -0
- data/lib/relaton/w3c/item.rb +12 -0
- data/lib/relaton/w3c/item_data.rb +6 -0
- data/lib/relaton/w3c/processor.rb +49 -0
- data/lib/relaton/w3c/pubid.rb +73 -0
- data/lib/relaton/w3c/safe_realize.rb +59 -0
- data/lib/relaton/w3c/util.rb +8 -0
- data/lib/relaton/w3c.rb +25 -0
- data/lib/relaton/xsf/bibdata.rb +8 -0
- data/lib/relaton/xsf/bibitem.rb +8 -0
- data/lib/relaton/xsf/bibliography.rb +24 -0
- data/lib/relaton/xsf/data_fetcher.rb +56 -0
- data/lib/relaton/xsf/hit.rb +17 -0
- data/lib/relaton/xsf/hit_collection.rb +24 -0
- data/lib/relaton/xsf/item.rb +7 -0
- data/lib/relaton/xsf/item_data.rb +6 -0
- data/lib/relaton/xsf/processor.rb +50 -0
- data/lib/relaton/xsf/util.rb +9 -0
- data/lib/relaton/xsf.rb +30 -0
- data/lib/relaton-core.rb +1 -0
- data/lib/relaton.rb +44 -9
- metadata +708 -150
- data/.github/workflows/rake.yml +0 -14
- data/.github/workflows/release.yml +0 -24
- data/.github/workflows/rubocop.yml +0 -48
- data/.gitignore +0 -12
- data/.rspec +0 -3
- data/.rubocop.yml +0 -12
- data/CLAUDE.md +0 -70
- data/Gemfile +0 -21
- data/Rakefile +0 -6
- data/docs/CHANGELOG.adoc +0 -16
- data/docs/VERSIONING_POLICY.adoc +0 -38
- data/docs/navigation.adoc +0 -6
- data/lib/relaton/config.rb +0 -24
- data/lib/relaton/db_cache.rb +0 -230
- data/lib/relaton/registry.rb +0 -118
- data/lib/relaton/util.rb +0 -7
- data/lib/relaton/workers_pool.rb +0 -21
- data/relaton.gemspec +0 -61
- data/spec/relaton/config_spec.rb +0 -10
- data/spec/relaton/db_cache_spec.rb +0 -51
- data/spec/relaton/db_spec.rb +0 -556
- data/spec/relaton/registry_spec.rb +0 -178
- data/spec/relaton/util_spec.rb +0 -3
- data/spec/relaton_spec.rb +0 -725
- data/spec/spec_helper.rb +0 -45
- data/spec/support/gb_t_20223_2006.xml +0 -33
- data/spec/support/iso_111111119115_1.xml +0 -0
- data/spec/support/iso_19115_1.xml +0 -115
- data/spec/support/iso_19115_2.xml +0 -95
- data/spec/support/rfc_8341.xml +0 -46
- data/spec/vcr_cassetes/3gpp_tr_00_01u_umts_3_0_0.yml +0 -12720
- data/spec/vcr_cassetes/api_relaton_org.yml +0 -121
- data/spec/vcr_cassetes/api_relaton_org_unavailable.yml +0 -143
- data/spec/vcr_cassetes/cc_dir_10005_2019.yml +0 -199
- data/spec/vcr_cassetes/cie_001_1980.yml +0 -401
- data/spec/vcr_cassetes/cipm_meeting_43.yml +0 -1513
- data/spec/vcr_cassetes/doi_10_6028_nist_ir_8245.yml +0 -86
- data/spec/vcr_cassetes/ecma_6.yml +0 -112
- data/spec/vcr_cassetes/en_10160_1999.yml +0 -13624
- data/spec/vcr_cassetes/gb_t_20223_2006.yml +0 -733
- data/spec/vcr_cassetes/ieee_528_2019.yml +0 -2786
- data/spec/vcr_cassetes/iso_111111119115_1.yml +0 -12951
- data/spec/vcr_cassetes/iso_19115_1.yml +0 -13177
- data/spec/vcr_cassetes/iso_19115_1_2.yml +0 -369
- data/spec/vcr_cassetes/iso_19115_1_std.yml +0 -13177
- data/spec/vcr_cassetes/iso_19115_all_parts.yml +0 -229
- data/spec/vcr_cassetes/iso_19133_2005.yml +0 -148
- data/spec/vcr_cassetes/iso_combined_applied.yml +0 -364
- data/spec/vcr_cassetes/iso_combined_included.yml +0 -364
- data/spec/vcr_cassetes/iso_dis.yml +0 -157
- data/spec/vcr_cassetes/ogc_19_025r1.yml +0 -371
- data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +0 -317
- data/spec/vcr_cassetes/rfc_8341.yml +0 -1272
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "date"
|
|
4
|
+
|
|
5
|
+
# require 'relaton_iso/iso_bibliographic_item'
|
|
6
|
+
# require "relaton_iso/scrapper"
|
|
7
|
+
# require "relaton_iso/hit_collection"
|
|
8
|
+
# require "relaton_iec"
|
|
9
|
+
|
|
10
|
+
module Relaton
|
|
11
|
+
module Iso
|
|
12
|
+
# Methods for search ISO standards.
|
|
13
|
+
module Bibliography
|
|
14
|
+
extend self
|
|
15
|
+
|
|
16
|
+
# @param text [Pubid::Iso::Identifier, String]
|
|
17
|
+
# @return [RelatonIso::HitCollection]
|
|
18
|
+
def search(pubid, opts = {})
|
|
19
|
+
pubid = ::Pubid::Iso::Identifier.parse(pubid) if pubid.is_a? String
|
|
20
|
+
HitCollection.new(pubid, opts).find
|
|
21
|
+
rescue SocketError, Timeout::Error, Errno::EINVAL, Errno::ECONNRESET,
|
|
22
|
+
EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError,
|
|
23
|
+
Net::ProtocolError, OpenSSL::SSL::SSLError, Errno::ETIMEDOUT => e
|
|
24
|
+
raise Relaton::RequestError, e.message
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# @param ref [String] the ISO standard Code to look up (e..g "ISO 9000")
|
|
28
|
+
# @param year [String, NilClass] the year the standard was published
|
|
29
|
+
# @param opts [Hash] options; restricted to :all_parts if all-parts
|
|
30
|
+
# @option opts [Boolean] :all_parts if all-parts reference is required
|
|
31
|
+
# @option opts [Boolean] :keep_year if undated reference should return
|
|
32
|
+
# actual reference with year
|
|
33
|
+
#
|
|
34
|
+
# @return [RelatonIsoBib::IsoBibliographicItem] Bibliographic item
|
|
35
|
+
def get(ref, year = nil, opts = {}) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity,Metrics/AbcSize
|
|
36
|
+
code = ref.gsub("\u2013", "-")
|
|
37
|
+
|
|
38
|
+
# parse "all parts" request
|
|
39
|
+
# code.sub! " (all parts)", ""
|
|
40
|
+
# opts[:all_parts] ||= $~ && opts[:all_parts].nil?
|
|
41
|
+
|
|
42
|
+
query_pubid = ::Pubid::Iso::Identifier.parse(code)
|
|
43
|
+
if year&.respond_to?(:to_i)
|
|
44
|
+
query_pubid.root.date = ::Pubid::Components::Date.new(year: year.to_s)
|
|
45
|
+
end
|
|
46
|
+
query_pubid.root.all_parts = opts[:all_parts] if opts[:all_parts]
|
|
47
|
+
Util.info "Fetching from Relaton repository ...", key: query_pubid.to_s
|
|
48
|
+
|
|
49
|
+
hits, missed_year_ids = isobib_search_filter(query_pubid, opts)
|
|
50
|
+
tip_ids = look_up_with_any_types_stages(hits, ref, opts)
|
|
51
|
+
|
|
52
|
+
date_filter = opts[:publication_date_before] || opts[:publication_date_after]
|
|
53
|
+
if date_filter && !query_pubid.root.all_parts
|
|
54
|
+
ret = find_match_by_date(hits, query_pubid, opts)
|
|
55
|
+
else
|
|
56
|
+
ret = hits.fetch_doc(date_filter ? opts : {})
|
|
57
|
+
end
|
|
58
|
+
return fetch_ref_err(query_pubid, missed_year_ids, tip_ids) unless ret
|
|
59
|
+
|
|
60
|
+
response_pubid = ret.docidentifier.find(&:primary) # .sub(" (all parts)", "")
|
|
61
|
+
Util.info "Found: `#{response_pubid}`", key: query_pubid.to_s
|
|
62
|
+
# A publication-date cutoff only bounds which edition is selected; it must
|
|
63
|
+
# not by itself retain the year. An undated citation stays undated (year
|
|
64
|
+
# stripped) unless the citation genuinely asks for a year via an explicit
|
|
65
|
+
# year, keep_year, or all_parts.
|
|
66
|
+
filter_item_by_date(ret, opts) if date_filter
|
|
67
|
+
get_all = (query_pubid.root.date&.year && opts[:keep_year].nil?) ||
|
|
68
|
+
opts[:keep_year] || opts[:all_parts]
|
|
69
|
+
return ret if get_all
|
|
70
|
+
|
|
71
|
+
ret.to_most_recent_reference
|
|
72
|
+
rescue Parslet::ParseFailed
|
|
73
|
+
Util.warn "Is not recognized as a standards identifier.", key: code
|
|
74
|
+
nil
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# @param query_pubid [Pubid::Iso::Identifier]
|
|
78
|
+
# @param pubid [Pubid::Iso::Identifier]
|
|
79
|
+
# @param all_parts [Boolean] match with any parts when true
|
|
80
|
+
# @return [Boolean]
|
|
81
|
+
def matches_parts?(query_pubid, pubid, all_parts: false)
|
|
82
|
+
# match only with documents with part number
|
|
83
|
+
return !pubid.part.nil? if all_parts
|
|
84
|
+
|
|
85
|
+
query_pubid.part == pubid.part
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
#
|
|
89
|
+
# Matches base of query_pubid and pubid.
|
|
90
|
+
#
|
|
91
|
+
# @param [Pubid::Iso::Identifier] query_pubid pubid to match
|
|
92
|
+
# @param [Pubid::Iso::Identifier] pubid pubid to match
|
|
93
|
+
# @param [Boolean] any_types_stages match with any types and stages
|
|
94
|
+
#
|
|
95
|
+
# @return [<Type>] <description>
|
|
96
|
+
#
|
|
97
|
+
def matches_base?(query_pubid, pubid, any_types_stages: false) # rubocop:disable Metrics?PerceivedComplexity
|
|
98
|
+
return false unless pubid.respond_to?(:publisher)
|
|
99
|
+
|
|
100
|
+
query_pubid.publisher == pubid.publisher &&
|
|
101
|
+
query_pubid.number == pubid.number &&
|
|
102
|
+
query_pubid.copublishers == pubid.copublishers &&
|
|
103
|
+
(any_types_stages || query_pubid.stage == pubid.stage) &&
|
|
104
|
+
(any_types_stages || query_pubid.is_a?(pubid.class))
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# @param hit_collection [RelatonIso::HitCollection]
|
|
108
|
+
# @param year [String]
|
|
109
|
+
# @return [Array<RelatonIso::HitCollection, Array<String>>] hits and missed year IDs
|
|
110
|
+
def filter_hits_by_year(hit_collection, year)
|
|
111
|
+
missed_year_ids = Set.new
|
|
112
|
+
return [hit_collection, missed_year_ids] if year.nil?
|
|
113
|
+
|
|
114
|
+
# filter by year
|
|
115
|
+
hit_collection.select! do |hit|
|
|
116
|
+
if hit.pubid.date&.year.nil? && hit.hit[:year]
|
|
117
|
+
hit.pubid.date = ::Pubid::Components::Date.new(year: hit.hit[:year].to_s)
|
|
118
|
+
end
|
|
119
|
+
next true if check_year(year, hit)
|
|
120
|
+
|
|
121
|
+
missed_year_ids << hit.pubid.to_s if hit.pubid.date&.year
|
|
122
|
+
false
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
[hit_collection, missed_year_ids]
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
private
|
|
129
|
+
|
|
130
|
+
# Filter out relations and dates that fall outside the date range.
|
|
131
|
+
# @param item [Relaton::Iso::ItemData]
|
|
132
|
+
# @param opts [Hash]
|
|
133
|
+
def filter_item_by_date(item, opts)
|
|
134
|
+
if item.relation&.any?
|
|
135
|
+
rewind_withdrawn_status(item, opts)
|
|
136
|
+
item.relation.reject! { |rel| relation_outside_date_range?(rel, opts) }
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
# Filter dates that occurred after the cut-off (keep published date always)
|
|
140
|
+
if item.date&.any? && opts[:publication_date_before]
|
|
141
|
+
item.date.reject! do |d|
|
|
142
|
+
next false if d.type == "published"
|
|
143
|
+
|
|
144
|
+
date_val = d.at&.to_date || d.from&.to_date
|
|
145
|
+
date_val && date_val >= opts[:publication_date_before]
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# ISO harmonized stage 95.99 = withdrawn, 60.60 = published. relaton stores
|
|
151
|
+
# only the current stage with no history, but a standard withdrawn by a
|
|
152
|
+
# successor published *after* the cutoff was, as of the cutoff, still the
|
|
153
|
+
# current (published) edition. Rewind 95 -> 60 in that case so a citing
|
|
154
|
+
# document does not render an anachronistic "withdrawn/replaced" annotation.
|
|
155
|
+
# A withdrawal with no obsoletedBy successor (or one that predates the
|
|
156
|
+
# cutoff) is left untouched. metanorma/metanorma-standoc#941.
|
|
157
|
+
# @param item [Relaton::Iso::ItemData]
|
|
158
|
+
# @param opts [Hash]
|
|
159
|
+
def rewind_withdrawn_status(item, opts)
|
|
160
|
+
cutoff = opts[:publication_date_before] or return
|
|
161
|
+
st = item.status or return
|
|
162
|
+
(st.stage&.content == "95" && st.substage&.content == "99") or return
|
|
163
|
+
|
|
164
|
+
obs = item.relation.select { |rel| rel.type == "obsoletedBy" }
|
|
165
|
+
return if obs.empty?
|
|
166
|
+
# Only rewind when every obsoleting successor postdates the cutoff.
|
|
167
|
+
obs.all? { |rel| (d = relation_date(rel)) && d >= cutoff } or return
|
|
168
|
+
|
|
169
|
+
st.stage.content = "60"
|
|
170
|
+
st.substage.content = "60"
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# Check if a relation's bibitem date falls outside the given date range.
|
|
174
|
+
# @param rel [Relaton::Iso::Relation]
|
|
175
|
+
# @param opts [Hash]
|
|
176
|
+
# @return [Boolean]
|
|
177
|
+
def relation_outside_date_range?(rel, opts)
|
|
178
|
+
rel_date = relation_date(rel)
|
|
179
|
+
return false unless rel_date
|
|
180
|
+
|
|
181
|
+
return true if opts[:publication_date_before] && rel_date >= opts[:publication_date_before]
|
|
182
|
+
return true if opts[:publication_date_after] && rel_date < opts[:publication_date_after]
|
|
183
|
+
|
|
184
|
+
false
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# Extract a Date from the relation's bibitem using circulated/published date or docidentifier year.
|
|
188
|
+
# @param rel [Relaton::Iso::Relation]
|
|
189
|
+
# @return [Date, nil]
|
|
190
|
+
def relation_date(rel)
|
|
191
|
+
bib = rel.bibitem
|
|
192
|
+
date_entry = bib.date&.find { |d| d.type == "circulated" } ||
|
|
193
|
+
bib.date&.find { |d| d.type == "published" }
|
|
194
|
+
return date_entry.at.to_date if date_entry&.at
|
|
195
|
+
|
|
196
|
+
docid = bib.docidentifier&.find(&:primary)&.content || bib.formattedref
|
|
197
|
+
return unless docid
|
|
198
|
+
|
|
199
|
+
year = docid.to_s[/:(\d{4})/, 1]
|
|
200
|
+
Date.new(year.to_i, 1, 1) if year
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# Find the best match among hits using date filters.
|
|
204
|
+
# @param hits [Relaton::Iso::HitCollection]
|
|
205
|
+
# @param pubid [Pubid::Iso::Identifier]
|
|
206
|
+
# @param opts [Hash]
|
|
207
|
+
# @return [Relaton::Iso::ItemData, nil]
|
|
208
|
+
def find_match_by_date(hits, pubid, opts) # rubocop:disable Metrics/AbcSize
|
|
209
|
+
candidates = []
|
|
210
|
+
hits.each { |h| candidates << h if year_in_range?(hit_year(h), opts) }
|
|
211
|
+
candidates.sort_by { |h| -hit_year(h) }.each do |h|
|
|
212
|
+
ret = fetch_and_check_date(h, pubid, opts)
|
|
213
|
+
return ret if ret
|
|
214
|
+
end
|
|
215
|
+
nil
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# Extract year from a hit as an integer.
|
|
219
|
+
#
|
|
220
|
+
# Amendments, corrigendums and supplements carry no year on their own
|
|
221
|
+
# identifier; the year lives on the underlying standard reachable via
|
|
222
|
+
# `root` (which walks the full base chain, however deeply nested). Fall
|
|
223
|
+
# back to it so a date filter does not drop such references (issue #181).
|
|
224
|
+
#
|
|
225
|
+
# @param hit [Relaton::Iso::Hit]
|
|
226
|
+
# @return [Integer]
|
|
227
|
+
def hit_year(hit)
|
|
228
|
+
yr = hit.pubid&.date&.year || hit.hit[:year] || hit.pubid&.root&.date&.year
|
|
229
|
+
yr.to_i
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
# Check if a year falls within the date filter range.
|
|
233
|
+
# @param year [Integer]
|
|
234
|
+
# @param opts [Hash]
|
|
235
|
+
# @return [Boolean]
|
|
236
|
+
def year_in_range?(year, opts)
|
|
237
|
+
return false if year.zero?
|
|
238
|
+
|
|
239
|
+
if opts[:publication_date_before]
|
|
240
|
+
return false if year > opts[:publication_date_before].year
|
|
241
|
+
end
|
|
242
|
+
if opts[:publication_date_after]
|
|
243
|
+
return false if year < opts[:publication_date_after].year
|
|
244
|
+
end
|
|
245
|
+
true
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
# Check if the item's published date falls within the filter range.
|
|
249
|
+
# @param item [Relaton::Iso::ItemData]
|
|
250
|
+
# @param opts [Hash]
|
|
251
|
+
# @return [Boolean]
|
|
252
|
+
def publication_date_in_range?(item, opts)
|
|
253
|
+
pub_date_entry = item.date.find { |d| d.type == "published" }
|
|
254
|
+
return true unless pub_date_entry&.at
|
|
255
|
+
|
|
256
|
+
pub_date = pub_date_entry.at.to_date
|
|
257
|
+
return true unless pub_date
|
|
258
|
+
|
|
259
|
+
if opts[:publication_date_before]
|
|
260
|
+
return false if pub_date >= opts[:publication_date_before]
|
|
261
|
+
end
|
|
262
|
+
if opts[:publication_date_after]
|
|
263
|
+
return false if pub_date < opts[:publication_date_after]
|
|
264
|
+
end
|
|
265
|
+
true
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
# Fetch the item for a hit and check if its publication date is in range.
|
|
269
|
+
# @param hit [Relaton::Iso::Hit]
|
|
270
|
+
# @param pubid [Pubid::Iso::Identifier]
|
|
271
|
+
# @param opts [Hash]
|
|
272
|
+
# @return [Relaton::Iso::ItemData, nil]
|
|
273
|
+
def fetch_and_check_date(hit, pubid, opts)
|
|
274
|
+
ret = hit.item
|
|
275
|
+
# A data file that fails to load (e.g. the index references a file that
|
|
276
|
+
# 404s) yields an item with no docidentifier; skip it rather than crash.
|
|
277
|
+
return unless ret&.docidentifier&.first
|
|
278
|
+
|
|
279
|
+
if publication_date_in_range?(ret, opts)
|
|
280
|
+
Util.info "Found: `#{ret.docidentifier.first.content}`", key: pubid.to_s
|
|
281
|
+
ret
|
|
282
|
+
end
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
def check_year(year, hit) # rubocop:disable Metrics/AbcSize
|
|
286
|
+
pub = hit.pubid
|
|
287
|
+
own_year = pub.date&.year.to_s
|
|
288
|
+
base_year = pub.base_identifier&.date&.year.to_s
|
|
289
|
+
if pub.base_identifier.nil?
|
|
290
|
+
own_year == year.to_s
|
|
291
|
+
else
|
|
292
|
+
base_year == year.to_s || own_year == year.to_s
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
# @param pubid [Pubid::Iso::Identifier] PubID with no results
|
|
297
|
+
def fetch_ref_err(pubid, missed_year_ids, tip_ids) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
|
298
|
+
Util.info "Not found.", key: pubid.to_s
|
|
299
|
+
|
|
300
|
+
if missed_year_ids.any?
|
|
301
|
+
ids = missed_year_ids.map { |i| "`#{i}`" }.join(", ")
|
|
302
|
+
Util.info "TIP: No match for edition year #{pubid.date&.year}, but matches exist for #{ids}.", key: pubid.to_s
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
if tip_ids.any?
|
|
306
|
+
ids = tip_ids.map { |i| "`#{i}`" }.join(", ")
|
|
307
|
+
Util.info "TIP: Matches exist for #{ids}.", key: pubid.to_s
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
if pubid.part
|
|
311
|
+
Util.info "TIP: If it cannot be found, the document may no longer be published in parts.", key: pubid.to_s
|
|
312
|
+
else
|
|
313
|
+
Util.info "TIP: If you wish to cite all document parts for the reference, " \
|
|
314
|
+
"use `#{pubid.exclude(:date)} (all parts)`.", key: pubid.to_s
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
nil
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
def look_up_with_any_types_stages(hits, ref, opts)
|
|
321
|
+
return [] if hits.any? || !ref.match?(/^ISO[\/\s][A-Z]/)
|
|
322
|
+
|
|
323
|
+
ref_no_type_stage = ref.sub(/^ISO[\/\s][A-Z]+/, "ISO")
|
|
324
|
+
pubid = ::Pubid::Iso::Identifier.parse(ref_no_type_stage)
|
|
325
|
+
resp, = isobib_search_filter(pubid, opts, any_types_stages: true)
|
|
326
|
+
resp.map &:pubid
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
#
|
|
330
|
+
# Search for hits. If no found then trying missed stages.
|
|
331
|
+
#
|
|
332
|
+
# @param query_pubid [Pubid::Iso::Identifier] reference without correction
|
|
333
|
+
# @param opts [Hash]
|
|
334
|
+
# @param any_types_stages [Boolean] match with any stages
|
|
335
|
+
#
|
|
336
|
+
# @return [Array<RelatonIso::HitCollection, Array<String>>] hits and missed years
|
|
337
|
+
#
|
|
338
|
+
def isobib_search_filter(query_pubid, opts, any_types_stages: false)
|
|
339
|
+
hit_collection = search(query_pubid, opts)
|
|
340
|
+
|
|
341
|
+
# filter only matching hits
|
|
342
|
+
filter_hits hit_collection, query_pubid, any_types_stages
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
#
|
|
346
|
+
# Filter hits by query_pubid.
|
|
347
|
+
#
|
|
348
|
+
# @param hit_collection [RelatonIso::HitCollection]
|
|
349
|
+
# @param query_pubid [Pubid::Iso::Identifier]
|
|
350
|
+
# @param all_parts [Boolean]
|
|
351
|
+
# @param any_types_stages [Boolean]
|
|
352
|
+
#
|
|
353
|
+
# @return [Array<RelatonIso::HitCollection, Array<String>>] hits and missed year IDs
|
|
354
|
+
#
|
|
355
|
+
def filter_hits(hit_collection, query_pubid, any_types_stages) # rubocop:disable Metrics/AbcSize
|
|
356
|
+
# filter out
|
|
357
|
+
excludings = build_excludings(query_pubid.root.all_parts, any_types_stages)
|
|
358
|
+
no_year_ref = hit_collection.ref_pubid_no_year.exclude(*excludings)
|
|
359
|
+
hit_collection.select! do |i|
|
|
360
|
+
pubid_match?(i.pubid, query_pubid, excludings, no_year_ref) &&
|
|
361
|
+
!(query_pubid.root.all_parts && i.pubid.part.nil?)
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
filter_hits_by_year(hit_collection, query_pubid.root.date&.year)
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
def build_excludings(all_parts, any_types_stages)
|
|
368
|
+
# 2.x attribute names: :year → :date, :iteration → :stage_iteration.
|
|
369
|
+
# Always exclude :typed_stage: parse fills the default-published
|
|
370
|
+
# typed_stage with original_abbr="" while .create leaves it nil,
|
|
371
|
+
# so equality would never hold against indexed/created rows
|
|
372
|
+
# otherwise.
|
|
373
|
+
excludings = %i[date edition all_parts typed_stage]
|
|
374
|
+
excludings += %i[type stage stage_iteration] if any_types_stages
|
|
375
|
+
excludings << :part if all_parts
|
|
376
|
+
excludings
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
def pubid_match?(pubid, query_pubid, excludings, no_year_ref)
|
|
380
|
+
if pubid.is_a? String then pubid == query_pubid.to_s
|
|
381
|
+
else
|
|
382
|
+
pubid = pubid.dup
|
|
383
|
+
pubid.base_identifier = pubid.base_identifier.exclude(:date, :edition) if pubid.base_identifier
|
|
384
|
+
normalize_compound_part(pubid.exclude(*excludings)) == no_year_ref
|
|
385
|
+
end
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
# @TODO TEMP WORKAROUND (pubid 2.x migration): the v1-generated index
|
|
389
|
+
# stores a compound part such as "5-1-3" in :part with no :subpart, and
|
|
390
|
+
# Relaton::Index builds each row via Pubid::Iso::Identifier.from_hash(id),
|
|
391
|
+
# which keeps it as part="5-1-3" subpart=nil. A parsed query (no_year_ref)
|
|
392
|
+
# splits it (part="5", subpart="1-3"), so the two never compare equal.
|
|
393
|
+
# Re-split the candidate's compound part on the first dash to mirror parse
|
|
394
|
+
# before comparing. `exclude` returns a fresh instance, so mutating this
|
|
395
|
+
# copy is safe. Remove once pubid create() splits compound parts itself.
|
|
396
|
+
def normalize_compound_part(pubid)
|
|
397
|
+
num = pubid.part&.value.to_s
|
|
398
|
+
return pubid unless pubid.subpart.nil? && num.include?("-")
|
|
399
|
+
|
|
400
|
+
head, tail = num.split("-", 2)
|
|
401
|
+
pubid.part = ::Pubid::Iso::Components::Code.new(value: head)
|
|
402
|
+
pubid.subpart = ::Pubid::Iso::Components::Code.new(value: tail)
|
|
403
|
+
pubid
|
|
404
|
+
end
|
|
405
|
+
end
|
|
406
|
+
end
|
|
407
|
+
end
|