relaton 2.2.0.pre.alpha.1 → 3.0.0.pre.alpha.2
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} +165 -38
- data/bin/console +0 -1
- data/lib/relaton/3gpp/bibdata.rb +9 -0
- data/lib/relaton/3gpp/bibitem.rb +9 -0
- data/lib/relaton/3gpp/bibliography.rb +123 -0
- data/lib/relaton/3gpp/data_fetcher.rb +303 -0
- data/lib/relaton/3gpp/docidentifier.rb +114 -0
- data/lib/relaton/3gpp/doctype.rb +9 -0
- data/lib/relaton/3gpp/ext.rb +31 -0
- data/lib/relaton/3gpp/item.rb +18 -0
- data/lib/relaton/3gpp/item_data.rb +15 -0
- data/lib/relaton/3gpp/parser.rb +400 -0
- data/lib/relaton/3gpp/processor.rb +71 -0
- data/lib/relaton/3gpp/release.rb +34 -0
- data/lib/relaton/3gpp/util.rb +8 -0
- data/lib/relaton/3gpp.rb +29 -0
- data/lib/relaton/adobe/bibdata.rb +8 -0
- data/lib/relaton/adobe/bibitem.rb +8 -0
- data/lib/relaton/adobe/bibliography.rb +92 -0
- data/lib/relaton/adobe/docidentifier.rb +49 -0
- data/lib/relaton/adobe/doctype.rb +14 -0
- data/lib/relaton/adobe/ext.rb +32 -0
- data/lib/relaton/adobe/item.rb +15 -0
- data/lib/relaton/adobe/item_base.rb +18 -0
- data/lib/relaton/adobe/item_data.rb +6 -0
- data/lib/relaton/adobe/processor.rb +45 -0
- data/lib/relaton/adobe/util.rb +8 -0
- data/lib/relaton/adobe.rb +37 -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 +49 -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 +49 -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 +264 -0
- data/lib/relaton/bib/util.rb +18 -0
- data/lib/relaton/bib/versions.json +35 -0
- data/lib/relaton/bib.rb +46 -0
- data/lib/relaton/bipm/bibliography.rb +231 -0
- data/lib/relaton/bipm/converter/asciibib.rb +64 -0
- data/lib/relaton/bipm/data_fetcher.rb +81 -0
- data/lib/relaton/bipm/data_outcomes_parser.rb +656 -0
- data/lib/relaton/bipm/id_parser.rb +278 -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 +36 -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 +172 -0
- data/lib/relaton/bipm/rawdata_bipm_metrologia/niso_jats_parser.rb +353 -0
- data/lib/relaton/bipm/si_brochure_parser.rb +188 -0
- data/lib/relaton/bipm/util.rb +8 -0
- data/lib/relaton/bipm.rb +38 -0
- data/lib/relaton/bsi/bibliography.rb +196 -0
- data/lib/relaton/bsi/hit.rb +28 -0
- data/lib/relaton/bsi/hit_collection.rb +113 -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 +107 -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 +43 -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 +93 -0
- data/lib/relaton/calconnect/data_fetcher.rb +174 -0
- data/lib/relaton/calconnect/docidentifier.rb +80 -0
- data/lib/relaton/calconnect/hit.rb +14 -0
- data/lib/relaton/calconnect/hit_collection.rb +92 -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 +20 -0
- data/lib/relaton/calconnect/processor.rb +72 -0
- data/lib/relaton/calconnect/scraper.rb +87 -0
- data/lib/relaton/calconnect/util.rb +8 -0
- data/lib/relaton/calconnect.rb +36 -0
- data/lib/relaton/ccsds/bibliography.rb +63 -0
- data/lib/relaton/ccsds/data/fetcher.rb +252 -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 +47 -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/docidentifier.rb +121 -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 +15 -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 +149 -0
- data/lib/relaton/cen/committees.yaml +66 -0
- data/lib/relaton/cen/hit.rb +31 -0
- data/lib/relaton/cen/hit_collection.rb +116 -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 +100 -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 +45 -0
- data/lib/relaton/cen/scraper.rb +218 -0
- data/lib/relaton/cen/util.rb +8 -0
- data/lib/relaton/cen.rb +30 -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 +540 -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 +68 -0
- data/lib/relaton/cie/scrapper.rb +52 -0
- data/lib/relaton/cie/util.rb +8 -0
- data/lib/relaton/cie.rb +29 -0
- data/lib/relaton/core/array_wrapper.rb +20 -0
- data/lib/relaton/core/data_fetcher.rb +244 -0
- data/lib/relaton/core/date_parser.rb +42 -0
- data/lib/relaton/core/governor.rb +320 -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/pacer.rb +134 -0
- data/lib/relaton/core/processor.rb +67 -0
- data/lib/relaton/core/request_error.rb +14 -0
- data/lib/relaton/core/workers_pool.rb +45 -0
- data/lib/relaton/core.rb +12 -0
- data/lib/relaton/db/registry.rb +44 -4
- data/lib/relaton/db.rb +0 -1
- data/lib/relaton/doi/crossref.rb +89 -0
- data/lib/relaton/doi/parser.rb +921 -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/easc/bibdata.rb +8 -0
- data/lib/relaton/easc/bibitem.rb +8 -0
- data/lib/relaton/easc/bibliography.rb +95 -0
- data/lib/relaton/easc/docidentifier.rb +100 -0
- data/lib/relaton/easc/doctype.rb +14 -0
- data/lib/relaton/easc/ext.rb +44 -0
- data/lib/relaton/easc/item.rb +13 -0
- data/lib/relaton/easc/item_base.rb +18 -0
- data/lib/relaton/easc/item_data.rb +6 -0
- data/lib/relaton/easc/processor.rb +46 -0
- data/lib/relaton/easc/util.rb +8 -0
- data/lib/relaton/easc.rb +35 -0
- data/lib/relaton/ecma/bibdata.rb +8 -0
- data/lib/relaton/ecma/bibitem.rb +8 -0
- data/lib/relaton/ecma/bibliography.rb +149 -0
- data/lib/relaton/ecma/data_fetcher.rb +162 -0
- data/lib/relaton/ecma/data_parser.rb +49 -0
- data/lib/relaton/ecma/docidentifier.rb +124 -0
- data/lib/relaton/ecma/edition_parser.rb +80 -0
- data/lib/relaton/ecma/ext.rb +7 -0
- data/lib/relaton/ecma/item.rb +13 -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 +39 -0
- data/lib/relaton/ecma/parser_common.rb +33 -0
- data/lib/relaton/ecma/processor.rb +69 -0
- data/lib/relaton/ecma/standard_parser.rb +134 -0
- data/lib/relaton/ecma/util.rb +8 -0
- data/lib/relaton/ecma.rb +33 -0
- data/lib/relaton/etsi/bibdata.rb +10 -0
- data/lib/relaton/etsi/bibitem.rb +10 -0
- data/lib/relaton/etsi/bibliography.rb +111 -0
- data/lib/relaton/etsi/data_fetcher.rb +167 -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 +71 -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 +26 -0
- data/lib/relaton/gb/bibdata.rb +8 -0
- data/lib/relaton/gb/bibitem.rb +8 -0
- data/lib/relaton/gb/bibliography.rb +171 -0
- data/lib/relaton/gb/ccs.rb +14 -0
- data/lib/relaton/gb/committee.rb +13 -0
- data/lib/relaton/gb/docidentifier.rb +72 -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 +49 -0
- data/lib/relaton/gb/project_number.rb +38 -0
- data/lib/relaton/gb/scraper.rb +221 -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/gost/bibdata.rb +8 -0
- data/lib/relaton/gost/bibitem.rb +8 -0
- data/lib/relaton/gost/bibliography.rb +107 -0
- data/lib/relaton/gost/docidentifier.rb +80 -0
- data/lib/relaton/gost/doctype.rb +16 -0
- data/lib/relaton/gost/ext.rb +46 -0
- data/lib/relaton/gost/item.rb +15 -0
- data/lib/relaton/gost/item_base.rb +18 -0
- data/lib/relaton/gost/item_data.rb +6 -0
- data/lib/relaton/gost/processor.rb +49 -0
- data/lib/relaton/gost/util.rb +8 -0
- data/lib/relaton/gost.rb +36 -0
- data/lib/relaton/iala/bibdata.rb +8 -0
- data/lib/relaton/iala/bibitem.rb +8 -0
- data/lib/relaton/iala/bibliography.rb +146 -0
- data/lib/relaton/iala/docidentifier.rb +89 -0
- data/lib/relaton/iala/doctype.rb +18 -0
- data/lib/relaton/iala/ext.rb +32 -0
- data/lib/relaton/iala/item.rb +21 -0
- data/lib/relaton/iala/item_base.rb +18 -0
- data/lib/relaton/iala/item_data.rb +6 -0
- data/lib/relaton/iala/processor.rb +43 -0
- data/lib/relaton/iala/relation.rb +7 -0
- data/lib/relaton/iala/util.rb +8 -0
- data/lib/relaton/iala.rb +35 -0
- data/lib/relaton/iana/bibdata.rb +8 -0
- data/lib/relaton/iana/bibitem.rb +8 -0
- data/lib/relaton/iana/bibliography.rb +100 -0
- data/lib/relaton/iana/data_fetcher.rb +101 -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 +70 -0
- data/lib/relaton/iana/util.rb +8 -0
- data/lib/relaton/iana.rb +40 -0
- data/lib/relaton/iec/bibliography.rb +283 -0
- data/lib/relaton/iec/data_fetcher.rb +222 -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 +135 -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 +74 -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 +73 -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 +771 -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 +330 -0
- data/lib/relaton/ieee/item.rb +11 -0
- data/lib/relaton/ieee/item_data.rb +7 -0
- data/lib/relaton/ieee/processor.rb +71 -0
- data/lib/relaton/ieee/rawbib_id_parser.rb +753 -0
- data/lib/relaton/ieee/util.rb +8 -0
- data/lib/relaton/ieee.rb +30 -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 +561 -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 +72 -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 +446 -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 +101 -0
- data/lib/relaton/ietf/util.rb +8 -0
- data/lib/relaton/ietf/wg_name_resolver.rb +42 -0
- data/lib/relaton/ietf.rb +30 -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 +66 -0
- data/lib/relaton/index/pool.rb +46 -0
- data/lib/relaton/index/shard_source.rb +201 -0
- data/lib/relaton/index/type.rb +210 -0
- data/lib/relaton/index/util.rb +18 -0
- data/lib/relaton/index.rb +61 -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 +412 -0
- data/lib/relaton/iso/data_fetcher.rb +338 -0
- data/lib/relaton/iso/data_parser.rb +458 -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 +196 -0
- data/lib/relaton/iso/item_data.rb +50 -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 +146 -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 +85 -0
- data/lib/relaton/iso/scraper.rb +635 -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 +95 -0
- data/lib/relaton/itu/data_crawler_r.rb +664 -0
- data/lib/relaton/itu/data_fetcher.rb +550 -0
- data/lib/relaton/itu/data_merge_r.rb +149 -0
- data/lib/relaton/itu/data_parser_r.rb +214 -0
- data/lib/relaton/itu/data_parser_t.rb +228 -0
- data/lib/relaton/itu/family_cache.rb +177 -0
- data/lib/relaton/itu/governor.rb +56 -0
- data/lib/relaton/itu/hit.rb +28 -0
- data/lib/relaton/itu/hit_collection.rb +299 -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 +75 -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 +38 -0
- data/lib/relaton/itu/processor.rb +72 -0
- data/lib/relaton/itu/pubid.rb +199 -0
- data/lib/relaton/itu/radio_regulations_parser.rb +70 -0
- data/lib/relaton/itu/recommendation_fields.rb +334 -0
- data/lib/relaton/itu/recommendation_parser.rb +30 -0
- data/lib/relaton/itu/scraper.rb +203 -0
- data/lib/relaton/itu/util.rb +8 -0
- data/lib/relaton/itu.rb +34 -0
- data/lib/relaton/jcgm/bibdata.rb +8 -0
- data/lib/relaton/jcgm/bibitem.rb +8 -0
- data/lib/relaton/jcgm/bibliography.rb +97 -0
- data/lib/relaton/jcgm/data_fetcher.rb +81 -0
- data/lib/relaton/jcgm/docidentifier.rb +102 -0
- data/lib/relaton/jcgm/doctype.rb +12 -0
- data/lib/relaton/jcgm/ext.rb +23 -0
- data/lib/relaton/jcgm/item.rb +20 -0
- data/lib/relaton/jcgm/item_base.rb +18 -0
- data/lib/relaton/jcgm/item_data.rb +6 -0
- data/lib/relaton/jcgm/meetings_parser.rb +175 -0
- data/lib/relaton/jcgm/processor.rb +71 -0
- data/lib/relaton/jcgm/relation.rb +9 -0
- data/lib/relaton/jcgm/structured_identifier.rb +40 -0
- data/lib/relaton/jcgm/util.rb +8 -0
- data/lib/relaton/jcgm.rb +24 -0
- data/lib/relaton/jis/bibdata.rb +8 -0
- data/lib/relaton/jis/bibitem.rb +8 -0
- data/lib/relaton/jis/bibliography.rb +73 -0
- data/lib/relaton/jis/data_fetcher.rb +183 -0
- data/lib/relaton/jis/docidentifier.rb +120 -0
- data/lib/relaton/jis/doctype.rb +9 -0
- data/lib/relaton/jis/ext.rb +13 -0
- data/lib/relaton/jis/hit.rb +88 -0
- data/lib/relaton/jis/hit_collection.rb +128 -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 +32 -0
- data/lib/relaton/logger/channels/gh_issue.rb +143 -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 +134 -0
- data/lib/relaton/nist/date.rb +7 -0
- data/lib/relaton/nist/docidentifier.rb +165 -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 +19 -0
- data/lib/relaton/nist/item_base.rb +16 -0
- data/lib/relaton/nist/item_data.rb +6 -0
- data/lib/relaton/nist/mods_parser.rb +302 -0
- data/lib/relaton/nist/processor.rb +69 -0
- data/lib/relaton/nist/pubs_export.rb +69 -0
- data/lib/relaton/nist/relation.rb +10 -0
- data/lib/relaton/nist/scraper.rb +293 -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 +201 -0
- data/lib/relaton/oasis/browser_agent.rb +71 -0
- data/lib/relaton/oasis/data_fetcher.rb +130 -0
- data/lib/relaton/oasis/data_parser.rb +305 -0
- data/lib/relaton/oasis/data_parser_utils.rb +330 -0
- data/lib/relaton/oasis/data_part_parser.rb +239 -0
- data/lib/relaton/oasis/docidentifier.rb +54 -0
- data/lib/relaton/oasis/doctype.rb +7 -0
- data/lib/relaton/oasis/ext.rb +19 -0
- data/lib/relaton/oasis/item.rb +14 -0
- data/lib/relaton/oasis/item_data.rb +6 -0
- data/lib/relaton/oasis/processor.rb +74 -0
- data/lib/relaton/oasis/util.rb +8 -0
- data/lib/relaton/oasis.rb +41 -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 +131 -0
- data/lib/relaton/ogc/docidentifier.rb +111 -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 +111 -0
- data/lib/relaton/ogc/item.rb +13 -0
- data/lib/relaton/ogc/item_data.rb +6 -0
- data/lib/relaton/ogc/processor.rb +59 -0
- data/lib/relaton/ogc/scraper.rb +225 -0
- data/lib/relaton/ogc/util.rb +8 -0
- data/lib/relaton/ogc.rb +30 -0
- data/lib/relaton/oiml/bibdata.rb +8 -0
- data/lib/relaton/oiml/bibitem.rb +8 -0
- data/lib/relaton/oiml/bibliography.rb +169 -0
- data/lib/relaton/oiml/docidentifier.rb +48 -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/docidentifier.rb +67 -0
- data/lib/relaton/omg/ext.rb +7 -0
- data/lib/relaton/omg/item.rb +9 -0
- data/lib/relaton/omg/item_data.rb +6 -0
- data/lib/relaton/omg/processor.rb +35 -0
- data/lib/relaton/omg/scraper.rb +186 -0
- data/lib/relaton/omg/util.rb +8 -0
- data/lib/relaton/omg.rb +25 -0
- data/lib/relaton/plateau/bibdata.rb +8 -0
- data/lib/relaton/plateau/bibitem.rb +8 -0
- data/lib/relaton/plateau/bibliography.rb +31 -0
- data/lib/relaton/plateau/data_fetcher.rb +176 -0
- data/lib/relaton/plateau/doctype.rb +7 -0
- data/lib/relaton/plateau/ext.rb +23 -0
- data/lib/relaton/plateau/handbook_parser.rb +102 -0
- data/lib/relaton/plateau/hit.rb +21 -0
- data/lib/relaton/plateau/hit_collection.rb +79 -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 +51 -0
- data/lib/relaton/plateau/technical_report_parser.rb +98 -0
- data/lib/relaton/plateau/util.rb +8 -0
- data/lib/relaton/plateau.rb +29 -0
- data/lib/relaton/sdo/config.rb +34 -0
- data/lib/relaton/sdo/fetcher.rb +52 -0
- data/lib/relaton/sdo/logo.rb +95 -0
- data/lib/relaton/sdo/name.rb +26 -0
- data/lib/relaton/sdo/organization.rb +71 -0
- data/lib/relaton/sdo/store.rb +49 -0
- data/lib/relaton/sdo.rb +29 -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 +174 -0
- data/lib/relaton/w3c/data_fetcher.rb +487 -0
- data/lib/relaton/w3c/data_parser.rb +379 -0
- data/lib/relaton/w3c/docidentifier.rb +48 -0
- data/lib/relaton/w3c/doctype.rb +7 -0
- data/lib/relaton/w3c/ext.rb +11 -0
- data/lib/relaton/w3c/governor.rb +32 -0
- data/lib/relaton/w3c/item.rb +15 -0
- data/lib/relaton/w3c/item_data.rb +6 -0
- data/lib/relaton/w3c/processor.rb +49 -0
- data/lib/relaton/w3c/pubid.rb +85 -0
- data/lib/relaton/w3c/safe_realize.rb +148 -0
- data/lib/relaton/w3c/util.rb +8 -0
- data/lib/relaton/w3c.rb +36 -0
- data/lib/relaton/xsf/bibdata.rb +8 -0
- data/lib/relaton/xsf/bibitem.rb +8 -0
- data/lib/relaton/xsf/bibliography.rb +84 -0
- data/lib/relaton/xsf/data_fetcher.rb +106 -0
- data/lib/relaton/xsf/docidentifier.rb +46 -0
- data/lib/relaton/xsf/hit.rb +17 -0
- data/lib/relaton/xsf/hit_collection.rb +52 -0
- data/lib/relaton/xsf/item.rb +13 -0
- data/lib/relaton/xsf/item_data.rb +6 -0
- data/lib/relaton/xsf/processor.rb +51 -0
- data/lib/relaton/xsf/util.rb +9 -0
- data/lib/relaton/xsf.rb +34 -0
- data/lib/relaton-core.rb +1 -0
- data/lib/relaton.rb +85 -0
- metadata +775 -161
- 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/CLAUDE.md +0 -78
- data/Gemfile +0 -29
- 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/db/version.rb +0 -5
- data/relaton.gemspec +0 -72
- data/spec/relaton/config_spec.rb +0 -10
- data/spec/relaton/db_cache_spec.rb +0 -51
- data/spec/relaton/db_spec.rb +0 -567
- data/spec/relaton/registry_spec.rb +0 -178
- data/spec/relaton/util_spec.rb +0 -3
- data/spec/relaton_meta_spec.rb +0 -25
- data/spec/relaton_spec.rb +0 -800
- 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/api_relaton_org.yml +0 -121
- data/spec/vcr_cassetes/api_relaton_org_unavailable.yml +0 -140
- data/spec/vcr_cassetes/cc_dir_10005_2019.yml +0 -202
- data/spec/vcr_cassetes/cipm_meeting_43.yml +0 -1505
- data/spec/vcr_cassetes/gb_t_20223_2006.yml +0 -729
- data/spec/vcr_cassetes/iso_111111119115_1.yml +0 -12951
- data/spec/vcr_cassetes/iso_19115_1.yml +0 -17334
- data/spec/vcr_cassetes/iso_19115_1_2.yml +0 -322
- data/spec/vcr_cassetes/iso_19115_1_std.yml +0 -17334
- data/spec/vcr_cassetes/iso_19115_all_parts.yml +0 -185
- data/spec/vcr_cassetes/iso_19133_2005.yml +0 -144
- data/spec/vcr_cassetes/iso_combined_applied.yml +0 -318
- data/spec/vcr_cassetes/iso_combined_included.yml +0 -318
- data/spec/vcr_cassetes/ogc_19_025r1.yml +0 -374
- data/spec/vcr_cassetes/omg_ami4ccm_1_0.yml +0 -317
- data/spec/vcr_cassetes/rfc_8341.yml +0 -1278
data/lib/relaton/jcgm.rb
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require "relaton/bib"
|
|
2
|
+
require "relaton/index"
|
|
3
|
+
require "pubid"
|
|
4
|
+
require_relative "version"
|
|
5
|
+
require_relative "jcgm/util"
|
|
6
|
+
require_relative "jcgm/docidentifier"
|
|
7
|
+
require_relative "jcgm/item"
|
|
8
|
+
require_relative "jcgm/bibitem"
|
|
9
|
+
require_relative "jcgm/bibdata"
|
|
10
|
+
require_relative "jcgm/bibliography"
|
|
11
|
+
|
|
12
|
+
module Relaton
|
|
13
|
+
module Jcgm
|
|
14
|
+
INDEXFILE = "index-v1".freeze
|
|
15
|
+
|
|
16
|
+
class Error < StandardError; end
|
|
17
|
+
|
|
18
|
+
# Returns hash of XML grammar
|
|
19
|
+
# @return [String]
|
|
20
|
+
def self.grammar_hash
|
|
21
|
+
Digest::MD5.hexdigest Relaton::VERSION
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Jis
|
|
5
|
+
module Bibliography
|
|
6
|
+
extend self
|
|
7
|
+
|
|
8
|
+
#
|
|
9
|
+
# Search JIS by reference, returning the full candidate collection.
|
|
10
|
+
#
|
|
11
|
+
# The reference is parsed into a {Pubid::Jis::Identifier} and matched
|
|
12
|
+
# against the pubid-based `index-v2` via {HitCollection}. Candidates share
|
|
13
|
+
# the reference's series and number (a supplement is filed under its base
|
|
14
|
+
# number), so an edition and its amendments are returned together.
|
|
15
|
+
#
|
|
16
|
+
# @param [String] code JIS document code
|
|
17
|
+
# @param [String, nil] year JIS document year
|
|
18
|
+
#
|
|
19
|
+
# @return [Relaton::Jis::HitCollection] search result
|
|
20
|
+
#
|
|
21
|
+
# @raise [Pubid::Errors::ParseError] when the reference is not a JIS
|
|
22
|
+
# identifier, so a malformed reference is not reported as "not found"
|
|
23
|
+
#
|
|
24
|
+
def search(code, year = nil)
|
|
25
|
+
pubid = ::Pubid::Jis::Identifier.parse code
|
|
26
|
+
pubid.year ||= year.to_i if year
|
|
27
|
+
HitCollection.new pubid
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
#
|
|
31
|
+
# Get JIS document by reference
|
|
32
|
+
#
|
|
33
|
+
# @param [String] ref JIS document reference
|
|
34
|
+
# @param [String, nil] year JIS document year
|
|
35
|
+
# @param [Hash] opts options
|
|
36
|
+
# @option opts [Boolean] :all_parts return all parts of document
|
|
37
|
+
#
|
|
38
|
+
# @return [Relaton::Jis::Item, nil] JIS document
|
|
39
|
+
#
|
|
40
|
+
# @raise [Pubid::Errors::ParseError] when the reference is not a JIS
|
|
41
|
+
# identifier
|
|
42
|
+
#
|
|
43
|
+
def get(ref, year = nil, opts = {}) # rubocop:disable Metrics/AbcSize
|
|
44
|
+
code = ref.sub(/\s\((all parts|規格群)\)/, "")
|
|
45
|
+
opts[:all_parts] ||= !$1.nil?
|
|
46
|
+
Util.info "Fetching from webdesk.jsa.or.jp ...", key: ref
|
|
47
|
+
hits = search(code, year)
|
|
48
|
+
result = opts[:all_parts] ? hits.find_all_parts : hits.find
|
|
49
|
+
if result.is_a? Bib::ItemData
|
|
50
|
+
Util.info "Found: `#{result.docidentifier[0].content}`", key: ref
|
|
51
|
+
return result
|
|
52
|
+
end
|
|
53
|
+
hint result, ref, year
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
#
|
|
57
|
+
# Log hint message
|
|
58
|
+
#
|
|
59
|
+
# @param [Array] result search result (missed edition years)
|
|
60
|
+
# @param [String] ref reference to search
|
|
61
|
+
# @param [String, nil] year year to search
|
|
62
|
+
#
|
|
63
|
+
def hint(result, ref, year)
|
|
64
|
+
Util.info "Not found.", key: ref
|
|
65
|
+
if result&.any?
|
|
66
|
+
Util.info "TIP: No match for edition year `#{year}`, but " \
|
|
67
|
+
"matches exist for `#{result.uniq.join('`, `')}`.", key: ref
|
|
68
|
+
end
|
|
69
|
+
nil
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../jis"
|
|
4
|
+
require_relative "scraper"
|
|
5
|
+
|
|
6
|
+
module Relaton
|
|
7
|
+
module Jis
|
|
8
|
+
class DataFetcher < Core::DataFetcher
|
|
9
|
+
URL = "https://webdesk.jsa.or.jp/books/"
|
|
10
|
+
|
|
11
|
+
def initialize(output, format)
|
|
12
|
+
super
|
|
13
|
+
@queue = SizedQueue.new 10
|
|
14
|
+
@threads = create_thread_pool 5
|
|
15
|
+
@mutex = Mutex.new
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def log_error(msg)
|
|
19
|
+
Util.error msg
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# The pubid index-v2, the only index a crawl writes. relaton-data-jis
|
|
23
|
+
# rebuilds the legacy string index-v1 from data/ in its own crawler.
|
|
24
|
+
def index
|
|
25
|
+
@index ||= Relaton::Index.find_or_create(
|
|
26
|
+
:jis, file: "#{INDEXFILE}.yaml", pubid_class: ::Pubid::Jis::Identifier
|
|
27
|
+
)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Parse a primary docidentifier string into a pubid identifier; nil (with
|
|
31
|
+
# a warning) if pubid can't parse it, so a single bad id never aborts the
|
|
32
|
+
# crawl or corrupts the index.
|
|
33
|
+
def pubid(id)
|
|
34
|
+
::Pubid::Jis::Identifier.parse id
|
|
35
|
+
rescue StandardError => e
|
|
36
|
+
Util.warn "Failed to parse `#{id}` with pubid: #{e.message}"
|
|
37
|
+
nil
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def to_yaml(bib)
|
|
41
|
+
Item.to_yaml bib
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def to_xml(bib)
|
|
45
|
+
Bibdata.to_xml bib
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def to_bibxml(bib)
|
|
49
|
+
bib.to_rfcxml
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def create_thread_pool(size)
|
|
53
|
+
Array.new(size) do
|
|
54
|
+
Thread.new do
|
|
55
|
+
until (url = @queue.shift) == :END
|
|
56
|
+
fetch_doc url
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def fetch_doc(url) # rubocop:disable Metrics/MethodLength
|
|
63
|
+
attempts = 0
|
|
64
|
+
begin
|
|
65
|
+
bib = Scraper.new(url, @errors).fetch
|
|
66
|
+
rescue StandardError => e
|
|
67
|
+
attempts += 1
|
|
68
|
+
if attempts < 5
|
|
69
|
+
sleep 2
|
|
70
|
+
retry
|
|
71
|
+
else
|
|
72
|
+
Util.warn "URL: #{url}"
|
|
73
|
+
Util.warn "#{e.message}\n#{e.backtrace[0..6].join("\n")}"
|
|
74
|
+
end
|
|
75
|
+
else
|
|
76
|
+
save_doc bib, url
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def fetch(_source = nil)
|
|
81
|
+
return unless initial_post
|
|
82
|
+
|
|
83
|
+
resp = agent.get "#{URL}W11M0070/index"
|
|
84
|
+
parse_page resp
|
|
85
|
+
index.save
|
|
86
|
+
report_errors
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def initial_post
|
|
90
|
+
return true if @initial_time && Time.now - @initial_time < 600
|
|
91
|
+
|
|
92
|
+
body = { record: 0, dantai: "JIS", searchtype2: 1,
|
|
93
|
+
status_1: 1, status_2: 2 } # rubocop:disable Naming/VariableNumber
|
|
94
|
+
resp = agent.post "#{URL}W11M0270/index", body
|
|
95
|
+
disp = JSON.parse resp.body
|
|
96
|
+
@initial_time = Time.now
|
|
97
|
+
disp["status"] || Util.warn("No results found for JIS")
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def agent
|
|
101
|
+
@agent ||= Mechanize.new
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def parse_page(resp)
|
|
105
|
+
while resp
|
|
106
|
+
xpath = '//div[@class="blockGenaral"]/a'
|
|
107
|
+
resp.xpath(xpath).each { |a| @queue << a[:href] }
|
|
108
|
+
offset = parse_offset resp
|
|
109
|
+
break if offset >= count
|
|
110
|
+
|
|
111
|
+
resp = get_next_page(offset)
|
|
112
|
+
end
|
|
113
|
+
end_threads_and_wait
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def parse_offset(resp) # rubocop:disable Metrics/AbcSize
|
|
117
|
+
if resp.at('//*[@id="btnPaging"]') # first page
|
|
118
|
+
xpath = '//script[contains(.,"var count =")]'
|
|
119
|
+
@count = resp.at(xpath).text.match(/var count = (\d+);/)[1]
|
|
120
|
+
resp.at("//*[@id='offset']")[:value].to_i
|
|
121
|
+
else
|
|
122
|
+
script = resp.at("//script").text
|
|
123
|
+
script.match(/\("offset"\)\.value = '(\d+)'/)[1].to_i
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
def end_threads_and_wait
|
|
128
|
+
@threads.size.times { @queue << :END }
|
|
129
|
+
@queue.close
|
|
130
|
+
@threads.each(&:join)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def count
|
|
134
|
+
@count.to_i
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def get_next_page(offset) # rubocop:disable Metrics/MethodLength
|
|
138
|
+
attempts = 0
|
|
139
|
+
begin
|
|
140
|
+
if initial_post
|
|
141
|
+
url = "#{URL}W11M0070/getAddList"
|
|
142
|
+
agent.post url, search_type: "JIS", offset: offset
|
|
143
|
+
end
|
|
144
|
+
rescue StandardError => e
|
|
145
|
+
attempts += 1
|
|
146
|
+
if attempts < 5
|
|
147
|
+
sleep 2
|
|
148
|
+
retry
|
|
149
|
+
else
|
|
150
|
+
Util.warn "#{e.message}\n#{e.backtrace[0..6].join("\n")}"
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def save_doc(bib, url) # rubocop:disable Metrics/MethodLength
|
|
156
|
+
return unless bib
|
|
157
|
+
|
|
158
|
+
id = bib.docidentifier.find(&:primary).content
|
|
159
|
+
@mutex.synchronize do
|
|
160
|
+
# Two distinct ids can sanitize to one filename, in which case the
|
|
161
|
+
# second document used to be dropped. Give it a path of its own; a
|
|
162
|
+
# genuine duplicate (same id) still resolves to one path and is still
|
|
163
|
+
# skipped. Inside the lock: unique_output_file reserves state.
|
|
164
|
+
file = unique_output_file id
|
|
165
|
+
# A reserved path only ever belongs to one id, so a hit here is the
|
|
166
|
+
# same document again. Checked FIRST: a disambiguated path stays !=
|
|
167
|
+
# output_file forever, so gating this on that comparison would make a
|
|
168
|
+
# repeat of a disambiguated id skip the skip and overwrite itself.
|
|
169
|
+
if @files.include?(file)
|
|
170
|
+
Util.warn "File #{file} already exists. Duplication URL: #{url}"
|
|
171
|
+
next
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
Util.warn "File #{output_file id} already exists; writing #{file} instead" if file != output_file(id)
|
|
175
|
+
@files << file
|
|
176
|
+
File.write file, serialize(bib), encoding: "UTF-8"
|
|
177
|
+
pid = pubid id
|
|
178
|
+
index.add_or_update pid, file if pid
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
end
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Jis
|
|
5
|
+
# A JIS document identifier, backed by `Pubid::Jis`.
|
|
6
|
+
#
|
|
7
|
+
# `content` stays the source string for serialization. `#pubid` parses it
|
|
8
|
+
# into a `Pubid::Jis::Identifier`, and the three mutators change that pubid
|
|
9
|
+
# and render it back into `content`. There is no string surgery.
|
|
10
|
+
#
|
|
11
|
+
# The parse is lazy and soft, as in `Relaton::Itu::Docidentifier`: it runs
|
|
12
|
+
# on first use, and content that does not parse gives a nil `#pubid`, with
|
|
13
|
+
# no log. The all-parts form "JIS C 0364 (all parts)" does not parse, and
|
|
14
|
+
# a cached all-parts item is deserialized again, so a log would be noise.
|
|
15
|
+
# With a nil `#pubid` the mutators do nothing.
|
|
16
|
+
#
|
|
17
|
+
# ## Rendering rules
|
|
18
|
+
#
|
|
19
|
+
# - The `JIS ` publisher is rendered only when the source has it. pubid
|
|
20
|
+
# always adds it, but the source spells a technical report
|
|
21
|
+
# `TR Z 0010:2008`.
|
|
22
|
+
# - Everything else is the pubid canonical spelling. pubid does not keep the
|
|
23
|
+
# source spelling `AMENDMENT 1` / `EXPLANATION 1`, so a changed supplement
|
|
24
|
+
# renders as `AMD 1` / `EXPL 1`, the form that the index uses.
|
|
25
|
+
# - The all-parts marker is ` (all parts)`, as in
|
|
26
|
+
# `Relaton::Jis::StructuredIdentifier`, not the pubid `(規格群)`.
|
|
27
|
+
# `Bibliography.get` accepts both as a reference.
|
|
28
|
+
class Docidentifier < Bib::Docidentifier
|
|
29
|
+
# Capture the inherited content setter before the override, so that a
|
|
30
|
+
# mutation can write the rendered string back and keep the changed pubid.
|
|
31
|
+
# `content=` would clear it, and a new parse of "… (all parts)" fails.
|
|
32
|
+
alias_method :store_content, :content=
|
|
33
|
+
|
|
34
|
+
def content=(value)
|
|
35
|
+
super
|
|
36
|
+
@pubid = nil
|
|
37
|
+
@pubid_parsed = false
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @return [Pubid::Jis::Identifier, nil] nil if the content does not parse
|
|
41
|
+
def pubid
|
|
42
|
+
return @pubid if @pubid_parsed
|
|
43
|
+
|
|
44
|
+
@pubid_parsed = true
|
|
45
|
+
@pubid = parse
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Removes every part level: `JIS C 0364-2-21:1999` -> `JIS C 0364:1999`.
|
|
49
|
+
# For a supplement, the part is on its base.
|
|
50
|
+
def remove_part!
|
|
51
|
+
return unless pubid
|
|
52
|
+
|
|
53
|
+
change_document { |id| id.exclude(:parts) }
|
|
54
|
+
refresh_content!
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Removes the year and the reaffirmation marker:
|
|
58
|
+
# `JIS C 9901:2019R` -> `JIS C 9901`.
|
|
59
|
+
#
|
|
60
|
+
# For a supplement, only the base loses its date, and the supplement keeps
|
|
61
|
+
# its own year: `JIS B 3700-101:1996/CORRIGENDUM 1:2002` ->
|
|
62
|
+
# `JIS B 3700-101/CORRIGENDUM 1:2002`. pubid renders a supplement without
|
|
63
|
+
# a year as `…/CORRIGENDUM 1:`, with a trailing colon.
|
|
64
|
+
def remove_date!
|
|
65
|
+
return unless pubid
|
|
66
|
+
|
|
67
|
+
change_document { |id| id.exclude(:year, :reaffirmed) }
|
|
68
|
+
refresh_content!
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# `JIS C 0364-2-21:1999` -> `JIS C 0364 (all parts)`, with `all_parts`
|
|
72
|
+
# set on `#pubid`.
|
|
73
|
+
def to_all_parts!
|
|
74
|
+
return if !pubid || pubid.all_parts?
|
|
75
|
+
|
|
76
|
+
# `#exclude` (no args) rebuilds a full independent copy;
|
|
77
|
+
# `change_document` itself never mutates in place (it only reassigns
|
|
78
|
+
# `@pubid`), but this stays correct even if that changes.
|
|
79
|
+
original = @pubid.exclude
|
|
80
|
+
change_document { |id| id.exclude(:parts, :year, :reaffirmed) }
|
|
81
|
+
document = render(@pubid)
|
|
82
|
+
@pubid = original.to_all_parts
|
|
83
|
+
store_content "#{document} (all parts)"
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
private
|
|
87
|
+
|
|
88
|
+
def parse
|
|
89
|
+
return unless content
|
|
90
|
+
|
|
91
|
+
require "pubid"
|
|
92
|
+
::Pubid::Jis::Identifier.parse content.to_s
|
|
93
|
+
rescue LoadError, StandardError
|
|
94
|
+
nil
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Applies the change to the document identifier: the pubid itself, or the
|
|
98
|
+
# base of a supplement. Copy on write, as `Pubid::Identifier#exclude` is:
|
|
99
|
+
# an argument-less `exclude` copies the supplement, so a pubid that a
|
|
100
|
+
# caller got before the mutation does not change.
|
|
101
|
+
def change_document(&)
|
|
102
|
+
@pubid = document_changed(@pubid, &)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def document_changed(id, &)
|
|
106
|
+
return yield(id) unless id.is_a?(::Pubid::Jis::SupplementIdentifier)
|
|
107
|
+
|
|
108
|
+
id.exclude.tap { |copy| copy.base &&= document_changed(copy.base, &) }
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def refresh_content!
|
|
112
|
+
store_content render(@pubid)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def render(id)
|
|
116
|
+
id.to_s(with_publisher: content.to_s.start_with?("JIS"))
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require_relative "doctype"
|
|
2
|
+
require_relative "structured_identifier"
|
|
3
|
+
|
|
4
|
+
module Relaton
|
|
5
|
+
module Jis
|
|
6
|
+
class Ext < Iso::Ext
|
|
7
|
+
attribute :doctype, Doctype
|
|
8
|
+
attribute :structuredidentifier, StructuredIdentifier
|
|
9
|
+
|
|
10
|
+
def get_schema_version = Relaton.schema_versions["relaton-model-jis"]
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Relaton
|
|
4
|
+
module Jis
|
|
5
|
+
class Hit < Core::Hit
|
|
6
|
+
#
|
|
7
|
+
# Create new hit
|
|
8
|
+
#
|
|
9
|
+
# @param [Hash] hit found hit
|
|
10
|
+
# @param [Relaton::Jis::HitCollection] collection hit collection
|
|
11
|
+
#
|
|
12
|
+
# @return [Relaton::Jis::Hit] new hit
|
|
13
|
+
#
|
|
14
|
+
def self.create(hit, collection)
|
|
15
|
+
new hit, collection
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# The edition aspects. {HitCollection} picks the edition, so a match
|
|
19
|
+
# ignores them. The reaffirmation mark `R` goes with the year:
|
|
20
|
+
# `exclude(:year)` keeps it, and `JIS L 4107` must match
|
|
21
|
+
# `JIS L 4107:2000R`.
|
|
22
|
+
EDITION = %i[year reaffirmed].freeze
|
|
23
|
+
|
|
24
|
+
#
|
|
25
|
+
# Check if the hit matches the collection's reference.
|
|
26
|
+
#
|
|
27
|
+
# The candidate must be the same document type, so a plain standard
|
|
28
|
+
# query never matches its amendments. The class check is explicit
|
|
29
|
+
# because pubid's JIS `==` does not compare the class
|
|
30
|
+
# (`JIS TR X 0014:1999 == JIS X 0014:1999`). The other aspects are
|
|
31
|
+
# compared, except the edition, and the parts when `all_parts` is on.
|
|
32
|
+
# This includes the base document of a supplement. The `SYMBOL` is
|
|
33
|
+
# compared on a standard, but not on a supplement: pubid's supplement
|
|
34
|
+
# `==` ignores it. {HitCollection#find_by_year} puts the exact printed id
|
|
35
|
+
# first for that reason.
|
|
36
|
+
#
|
|
37
|
+
# @param [Boolean] all_parts match any part of the document
|
|
38
|
+
#
|
|
39
|
+
# @return [Boolean] true if the hit matches
|
|
40
|
+
#
|
|
41
|
+
def matches?(all_parts: false)
|
|
42
|
+
return false unless pubid.instance_of?(reference.class)
|
|
43
|
+
|
|
44
|
+
ignore = all_parts ? EDITION + [:parts] : EDITION
|
|
45
|
+
reference.matches? pubid, ignore: ignore
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
#
|
|
49
|
+
# The hit's pubid identifier. `index-v2` rows are already deserialized to
|
|
50
|
+
# {Pubid::Jis::Identifier} via `pubid_class`; a Hash or String id is
|
|
51
|
+
# converted for robustness.
|
|
52
|
+
#
|
|
53
|
+
# @return [Pubid::Jis::Identifier, nil] identifier, or nil when it cannot
|
|
54
|
+
# be built
|
|
55
|
+
#
|
|
56
|
+
def pubid
|
|
57
|
+
return @pubid if defined? @pubid
|
|
58
|
+
|
|
59
|
+
id = hit[:id]
|
|
60
|
+
@pubid = case id
|
|
61
|
+
when Hash then ::Pubid::Jis::Identifier.from_hash id
|
|
62
|
+
when String then ::Pubid::Jis::Identifier.parse id
|
|
63
|
+
else id
|
|
64
|
+
end
|
|
65
|
+
rescue StandardError
|
|
66
|
+
Util.warn "Unable to create an identifier from `#{hit[:id]}`"
|
|
67
|
+
@pubid = nil
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# @return [Relaton::Jis::Item]
|
|
71
|
+
def item
|
|
72
|
+
@item ||= begin
|
|
73
|
+
url = "#{HitCollection::GH_URL}#{hit[:file]}"
|
|
74
|
+
resp = Net::HTTP.get_response URI(url)
|
|
75
|
+
item = Item.from_yaml resp.body
|
|
76
|
+
item.fetched = Date.today.to_s
|
|
77
|
+
item
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
private
|
|
82
|
+
|
|
83
|
+
def reference
|
|
84
|
+
hit_collection.pubid
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "hit"
|
|
4
|
+
|
|
5
|
+
module Relaton
|
|
6
|
+
module Jis
|
|
7
|
+
class HitCollection < Core::HitCollection
|
|
8
|
+
GH_URL = "https://raw.githubusercontent.com/relaton/relaton-data-jis/v2/"
|
|
9
|
+
|
|
10
|
+
#
|
|
11
|
+
# Initialize hit collection.
|
|
12
|
+
#
|
|
13
|
+
# Searches the pubid-based `index-v2` for every entry sharing the
|
|
14
|
+
# reference's series and number (a supplement is filed under its base
|
|
15
|
+
# number, so editions and amendments come back together). Narrowing to a
|
|
16
|
+
# specific type/year/part happens later in {#find}.
|
|
17
|
+
#
|
|
18
|
+
# @param [Pubid::Jis::Identifier] pubid parsed reference
|
|
19
|
+
#
|
|
20
|
+
def initialize(pubid)
|
|
21
|
+
super(pubid, pubid.year&.to_s)
|
|
22
|
+
@array = index.search(pubid) { |row| same_base? row[:id] }
|
|
23
|
+
.map { |row| Hit.new row, self }
|
|
24
|
+
.sort_by { |hit| hit.pubid.to_s }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# @return [Pubid::Jis::Identifier] parsed reference
|
|
28
|
+
def pubid
|
|
29
|
+
ref
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
#
|
|
33
|
+
# Find the best hit for the reference.
|
|
34
|
+
#
|
|
35
|
+
# @return [Relaton::Bib::ItemData, Array<Integer>] the matching item, or
|
|
36
|
+
# the list of available edition years when none match the requested year
|
|
37
|
+
#
|
|
38
|
+
def find
|
|
39
|
+
pubid.year ? find_by_year : find_all_years
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# The item of the requested edition. When no edition has the requested
|
|
43
|
+
# year, the years of the matching editions are returned.
|
|
44
|
+
def find_by_year
|
|
45
|
+
editions = @array.select(&:matches?)
|
|
46
|
+
hit = edition_hit editions
|
|
47
|
+
hit ? hit.item : editions.map { |h| h.pubid.year }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# The main item is the latest edition of the requested type; every other
|
|
51
|
+
# candidate sharing the series and number (older editions, amendments,
|
|
52
|
+
# explanations) is attached as an `instanceOf` relation.
|
|
53
|
+
def find_all_years
|
|
54
|
+
editions = @array.select(&:matches?)
|
|
55
|
+
return [] if editions.empty?
|
|
56
|
+
|
|
57
|
+
item = editions.max_by { |hit| hit.pubid.year.to_i }.item
|
|
58
|
+
attach_relations item.to_most_recent_reference,
|
|
59
|
+
item.docidentifier.first.content
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# The lowest-numbered part becomes the all-parts umbrella; every candidate
|
|
63
|
+
# sharing the series and number is attached as an `instanceOf` relation.
|
|
64
|
+
# A part-less document counts as part 0. Its index row deserializes with
|
|
65
|
+
# `parts` nil, not [].
|
|
66
|
+
def find_all_parts
|
|
67
|
+
parts = @array.select { |hit| hit.matches? all_parts: true }
|
|
68
|
+
lowest = parts.min_by { |hit| Array(hit.pubid.parts).first.to_i }
|
|
69
|
+
item = lowest.item.to_all_parts
|
|
70
|
+
attach_relations item, item.docidentifier.first.content
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Attach every candidate except `skip_id` to `umbrella` as an `instanceOf`
|
|
74
|
+
# relation and return the umbrella.
|
|
75
|
+
def attach_relations(umbrella, skip_id)
|
|
76
|
+
@array.each do |hit|
|
|
77
|
+
next if hit.pubid.to_s == skip_id
|
|
78
|
+
|
|
79
|
+
umbrella.relation << create_relation(hit)
|
|
80
|
+
end
|
|
81
|
+
umbrella
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def create_relation(hit)
|
|
85
|
+
id = hit.pubid.to_s
|
|
86
|
+
docid = Docidentifier.new content: id, type: "JIS", primary: true
|
|
87
|
+
bibitem = ItemData.new(
|
|
88
|
+
formattedref: Bib::Formattedref.new(content: id),
|
|
89
|
+
docidentifier: [docid],
|
|
90
|
+
)
|
|
91
|
+
Relation.new type: "instanceOf", bibitem: bibitem
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Index of pubid identifiers (`index-v2`), deserialized via `pubid_class`.
|
|
95
|
+
def index
|
|
96
|
+
@index ||= Relaton::Index.find_or_create(
|
|
97
|
+
:jis,
|
|
98
|
+
url: "#{GH_URL}#{INDEXFILE}.zip",
|
|
99
|
+
file: "#{INDEXFILE}.yaml",
|
|
100
|
+
pubid_class: ::Pubid::Jis::Identifier,
|
|
101
|
+
)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
private
|
|
105
|
+
|
|
106
|
+
# The exact printed id comes first, then the same identifier without the
|
|
107
|
+
# reaffirmation mark (`JIS L 4107:2000` finds `JIS L 4107:2000R`).
|
|
108
|
+
def edition_hit(editions)
|
|
109
|
+
editions.find { |h| h.pubid.to_s == pubid.to_s } ||
|
|
110
|
+
editions.find { |h| h.pubid.matches? pubid, ignore: [:reaffirmed] }
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Broad candidate filter: same series and number as the reference. For a
|
|
114
|
+
# supplement (amendment/corrigendum/explanation) the document series and
|
|
115
|
+
# number live on `base`, so compare against that.
|
|
116
|
+
def same_base?(candidate)
|
|
117
|
+
cand = base_of candidate
|
|
118
|
+
ours = base_of pubid
|
|
119
|
+
cand.series == ours.series && cand.number.to_s == ours.number.to_s
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def base_of(identifier)
|
|
123
|
+
supplement = identifier.respond_to?(:base) && identifier.base
|
|
124
|
+
supplement || identifier
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require_relative "docidentifier"
|
|
2
|
+
require_relative "ext"
|
|
3
|
+
require_relative "item_data"
|
|
4
|
+
|
|
5
|
+
module Relaton
|
|
6
|
+
module Jis
|
|
7
|
+
class Relation < Bib::Relation
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class Item < Iso::Item
|
|
11
|
+
model ItemData
|
|
12
|
+
|
|
13
|
+
attribute :docidentifier, Docidentifier,
|
|
14
|
+
collection: true, initialize_empty: true
|
|
15
|
+
attribute :relation, Relation,
|
|
16
|
+
collection: true, initialize_empty: true
|
|
17
|
+
attribute :ext, Ext
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
require_relative "relation"
|