relaton 2.2.0.pre.alpha.1 → 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/registry.rb +4 -4
- data/lib/relaton/db.rb +0 -1
- 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 +43 -0
- metadata +673 -170
- 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
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
module Relaton
|
|
2
|
+
module Bib
|
|
3
|
+
module Converter
|
|
4
|
+
module Bibtex
|
|
5
|
+
class FromBibtex
|
|
6
|
+
# @param entry [BibTeX::Entry]
|
|
7
|
+
def initialize(entry)
|
|
8
|
+
@entry = entry
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# @return [Relaton::Bib::ItemData]
|
|
12
|
+
def transform # rubocop:disable Metrics/MethodLength
|
|
13
|
+
ItemData.new(
|
|
14
|
+
id: @entry.key,
|
|
15
|
+
docidentifier: fetch_docid,
|
|
16
|
+
fetched: fetch_fetched,
|
|
17
|
+
type: fetch_type,
|
|
18
|
+
title: fetch_title,
|
|
19
|
+
contributor: fetch_contributor,
|
|
20
|
+
date: fetch_date,
|
|
21
|
+
place: fetch_place,
|
|
22
|
+
note: fetch_note,
|
|
23
|
+
relation: fetch_relation,
|
|
24
|
+
extent: fetch_extent,
|
|
25
|
+
edition: fetch_edition,
|
|
26
|
+
series: fetch_series,
|
|
27
|
+
source: fetch_link,
|
|
28
|
+
language: fetch_language,
|
|
29
|
+
classification: fetch_classification,
|
|
30
|
+
keyword: fetch_keyword,
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
# @return [Array<Relaton::Bib::Docidentifier>]
|
|
37
|
+
def fetch_docid # rubocop:disable Metrics/AbcSize
|
|
38
|
+
docid = [Docidentifier.new(content: @entry.key.to_s, primary: true)]
|
|
39
|
+
docid << Docidentifier.new(content: @entry.isbn.to_s, type: "isbn") if @entry["isbn"]
|
|
40
|
+
docid << Docidentifier.new(content: @entry.lccn.to_s, type: "lccn") if @entry["lccn"]
|
|
41
|
+
docid << Docidentifier.new(content: @entry.issn.to_s, type: "issn") if @entry["issn"]
|
|
42
|
+
docid
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# @return [String, nil]
|
|
46
|
+
def fetch_fetched
|
|
47
|
+
::Date.parse(@entry.timestamp.to_s) if @entry["timestamp"]
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# @return [String]
|
|
51
|
+
def fetch_type
|
|
52
|
+
case @entry.type
|
|
53
|
+
when :mastersthesis, :phdthesis then "thesis"
|
|
54
|
+
when :conference then "inproceedings"
|
|
55
|
+
when :misc then "standard"
|
|
56
|
+
else @entry.type.to_s
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# @return [Array<Relaton::Bib::Place>]
|
|
61
|
+
def fetch_place
|
|
62
|
+
@entry["address"] ? [Place.new(formatted_place: @entry.address.to_s)] : []
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# @return [Array<Relaton::Bib::Title>]
|
|
66
|
+
def fetch_title
|
|
67
|
+
title = []
|
|
68
|
+
title << Title.new(type: "main", content: @entry.convert(:latex).title.to_s) if @entry["title"]
|
|
69
|
+
title << Title.new(type: "main", content: @entry.convert(:latex).subtitle.to_s) if @entry["subtitle"]
|
|
70
|
+
title
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# @return [Array<Relaton::Bib::Contributor>]
|
|
74
|
+
def fetch_contributor # rubocop:disable Metrics/AbcSize
|
|
75
|
+
contribs = []
|
|
76
|
+
fetch_person("author") { |c| contribs << c }
|
|
77
|
+
fetch_person("editor") { |c| contribs << c }
|
|
78
|
+
|
|
79
|
+
fetch_org(@entry["publisher"], "publisher") { |c| contribs << c }
|
|
80
|
+
fetch_org(@entry["institution"], "distributor", "sponsor") { |c| contribs << c }
|
|
81
|
+
fetch_org(@entry["organization"], "distributor", "sponsor") { |c| contribs << c }
|
|
82
|
+
fetch_org(@entry["school"], "distributor", "sponsor") { |c| contribs << c }
|
|
83
|
+
|
|
84
|
+
fetch_howpublished { |c| contribs << c }
|
|
85
|
+
|
|
86
|
+
contribs
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def fetch_howpublished(&_)
|
|
90
|
+
return unless @entry["howpublished"]
|
|
91
|
+
|
|
92
|
+
/\\publisher\{(?<name>.+)\},\\url\{(?<url>.+)\}/ =~ @entry.howpublished.to_s
|
|
93
|
+
return unless name && url
|
|
94
|
+
|
|
95
|
+
name.gsub!(/\{\\?([^\\]+)\}/, '\1')
|
|
96
|
+
org = Organization.new(name: [TypedLocalizedString.new(content: name)], url: url)
|
|
97
|
+
yield Contributor.new(
|
|
98
|
+
organization: org,
|
|
99
|
+
role: [Contributor::Role.new(type: "publisher")],
|
|
100
|
+
)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# @param org [String, nil] organization name
|
|
104
|
+
# @param type [String] role type
|
|
105
|
+
# @param desc [String, nil] role description
|
|
106
|
+
def fetch_org(org, type, desc = nil, &_)
|
|
107
|
+
return unless org
|
|
108
|
+
|
|
109
|
+
role_obj = Contributor::Role.new(type: type)
|
|
110
|
+
role_obj.description = [LocalizedMarkedUpString.new(content: desc)] if desc
|
|
111
|
+
yield Contributor.new(organization: Organization.new(name: [TypedLocalizedString.new(content: org.to_s)]), role: [role_obj])
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# @param role [String] contributor role
|
|
115
|
+
def fetch_person(role, &_) # rubocop:disable Metrics/AbcSize
|
|
116
|
+
@entry[role]&.each do |name|
|
|
117
|
+
parts = name.split ", "
|
|
118
|
+
surname = LocalizedString.new(content: parts.first)
|
|
119
|
+
fname = parts.size > 1 ? parts[1].split : []
|
|
120
|
+
forename = fname.map { |fn| FullNameType::Forename.new(content: fn) }
|
|
121
|
+
name = FullName.new(surname: surname, forename: forename)
|
|
122
|
+
yield Contributor.new(
|
|
123
|
+
person: Person.new(name: name),
|
|
124
|
+
role: [Contributor::Role.new(type: role)],
|
|
125
|
+
)
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# @return [Array<Relaton::Bib::Date>]
|
|
130
|
+
def fetch_date
|
|
131
|
+
date = []
|
|
132
|
+
if @entry["year"]
|
|
133
|
+
on = ::Date.new(@entry.year.to_i, @entry["month_numeric"]&.to_i || 1).to_s
|
|
134
|
+
date << Bib::Date.new(type: "published", at: on)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
if @entry["urldate"]
|
|
138
|
+
date << Bib::Date.new(type: "accessed", at: ::Date.parse(@entry.urldate.to_s).to_s)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
date
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# @return [Array<Relaton::Bib::Note>]
|
|
145
|
+
def fetch_note # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
|
|
146
|
+
@entry.select do |k, _v|
|
|
147
|
+
%i[annote howpublished comment note content].include? k
|
|
148
|
+
end.reduce([]) do |mem, note|
|
|
149
|
+
type = case note[0]
|
|
150
|
+
when :note then nil
|
|
151
|
+
when :content then "tableOfContents"
|
|
152
|
+
else note[0].to_s
|
|
153
|
+
end
|
|
154
|
+
next mem if type == "howpublished" && note[1].to_s.match?(/^\\publisher\{.+\},\\url\{.+\}$/)
|
|
155
|
+
|
|
156
|
+
mem << Note.new(type: type, content: note[1].to_s)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# @return [Array<Relaton::Bib::Relation>]
|
|
161
|
+
def fetch_relation
|
|
162
|
+
return [] unless @entry["booktitle"]
|
|
163
|
+
|
|
164
|
+
ttl = Title.new(type: "main", content: @entry.booktitle.to_s)
|
|
165
|
+
[Relation.new(type: "partOf", bibitem: ItemData.new(title: [ttl]))]
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
# @return [Array<Relaton::Bib::Extent>]
|
|
169
|
+
def fetch_extent # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
|
170
|
+
locs = @entry.select do |k, _v|
|
|
171
|
+
%i[chapter pages volume].include? k
|
|
172
|
+
end.reduce([]) do |mem, loc|
|
|
173
|
+
if loc[0] == :pages
|
|
174
|
+
type = "page"
|
|
175
|
+
from, to = loc[1].to_s.split "-"
|
|
176
|
+
else
|
|
177
|
+
type = loc[0].to_s
|
|
178
|
+
from = loc[1].to_s
|
|
179
|
+
to = nil
|
|
180
|
+
end
|
|
181
|
+
mem << Locality.new(type: type, reference_from: from, reference_to: to)
|
|
182
|
+
end
|
|
183
|
+
[Extent.new(locality: locs)]
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
# @return [Array<Relaton::Bib::Series>]
|
|
187
|
+
def fetch_series # rubocop:disable Metrics/MethodLength
|
|
188
|
+
series = []
|
|
189
|
+
if @entry["journal"]
|
|
190
|
+
series << Series.new(
|
|
191
|
+
type: "journal",
|
|
192
|
+
title: Title.new(content: @entry.journal.to_s),
|
|
193
|
+
number: @entry["number"]&.to_s,
|
|
194
|
+
)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
if @entry["series"]
|
|
198
|
+
title = Title.new content: @entry.series.to_s
|
|
199
|
+
series << Series.new(title: title)
|
|
200
|
+
end
|
|
201
|
+
series
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# @return [Array<Relaton::Bib::Uri>]
|
|
205
|
+
def fetch_link # rubocop:disable Metrics/AbcSize
|
|
206
|
+
link = []
|
|
207
|
+
link << Uri.new(type: "src", content: @entry.url.to_s) if @entry["url"]
|
|
208
|
+
link << Uri.new(type: "doi", content: @entry.doi.to_s) if @entry["doi"]
|
|
209
|
+
link << Uri.new(type: "file", content: @entry.file2.to_s) if @entry["file2"]
|
|
210
|
+
link
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
# @return [Array<String>]
|
|
214
|
+
def fetch_language
|
|
215
|
+
return [] unless @entry["language"]
|
|
216
|
+
|
|
217
|
+
[Iso639[@entry.language.to_s].alpha2]
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# @return [Array<Relaton::Bib::Docidentifier>]
|
|
221
|
+
def fetch_classification
|
|
222
|
+
cls = []
|
|
223
|
+
cls << Docidentifier.new(type: "type", content: @entry["type"].to_s) if @entry["type"]
|
|
224
|
+
if @entry["mendeley-tags"]
|
|
225
|
+
cls << Docidentifier.new(type: "mendeley", content: @entry["mendeley-tags"].to_s)
|
|
226
|
+
end
|
|
227
|
+
cls
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# @return [Array<Relaton::Bib::Keyword>]
|
|
231
|
+
def fetch_keyword
|
|
232
|
+
@entry["keywords"]&.split(/,\s?/)&.map do |kw|
|
|
233
|
+
Keyword.new(vocab: LocalizedString.new(content: kw))
|
|
234
|
+
end || []
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# @return [Relaton::Bib::Edition, nil]
|
|
238
|
+
def fetch_edition
|
|
239
|
+
Edition.new(content: @entry["edition"].to_s) if @entry["edition"]
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
end
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
# Monkey patch to fix the issue with month quotes in BibTeX
|
|
2
|
+
module BibTeX
|
|
3
|
+
class Value
|
|
4
|
+
def to_s(options = {}) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
5
|
+
if options.key?(:filter)
|
|
6
|
+
opts = options.reject { |k,| k == :filter || (k == :quotes && (!atomic? || symbol?)) }
|
|
7
|
+
return convert(options[:filter]).to_s(opts)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
return value.to_s unless options.key?(:quotes) && atomic?
|
|
11
|
+
|
|
12
|
+
q = Array(options[:quotes])
|
|
13
|
+
[q[0], value, q[-1]].compact.join
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
module Relaton # rubocop:disable Style/OneClassPerFile
|
|
19
|
+
module Bib
|
|
20
|
+
module Converter
|
|
21
|
+
module Bibtex
|
|
22
|
+
class ToBibtex
|
|
23
|
+
include Core::ArrayWrapper
|
|
24
|
+
|
|
25
|
+
ATTRS = %i[
|
|
26
|
+
type id title author editor booktitle series number edition contributor
|
|
27
|
+
date address note relation extent classification keyword docidentifier
|
|
28
|
+
timestamp link
|
|
29
|
+
].freeze
|
|
30
|
+
|
|
31
|
+
#
|
|
32
|
+
# Initialize ToBibtex.
|
|
33
|
+
#
|
|
34
|
+
# @param bib [Relaton::Bib::ItemData]
|
|
35
|
+
def initialize(bib)
|
|
36
|
+
@bib = bib
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
#
|
|
40
|
+
# Build BibTeX bibliography.
|
|
41
|
+
#
|
|
42
|
+
# @param bibtex [BibTeX::Bibliography, nil] BibTeX bibliography
|
|
43
|
+
#
|
|
44
|
+
# @return [BibTeX::Bibliography] BibTeX bibliography
|
|
45
|
+
#
|
|
46
|
+
def transform(bibtex = nil)
|
|
47
|
+
@item = BibTeX::Entry.new
|
|
48
|
+
ATTRS.each { |a| send("add_#{a}") }
|
|
49
|
+
bibtex ||= BibTeX::Bibliography.new
|
|
50
|
+
bibtex << @item
|
|
51
|
+
bibtex
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
private
|
|
55
|
+
|
|
56
|
+
#
|
|
57
|
+
# Add type to BibTeX item
|
|
58
|
+
#
|
|
59
|
+
def add_type
|
|
60
|
+
@item.type = bibtex_type
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# @return [String] BibTeX type
|
|
64
|
+
def bibtex_type
|
|
65
|
+
case @bib.type
|
|
66
|
+
when "standard", nil then "misc"
|
|
67
|
+
else @bib.type
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
#
|
|
72
|
+
# Add ID to BibTeX item
|
|
73
|
+
#
|
|
74
|
+
def add_id
|
|
75
|
+
@item.key = @bib.id
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
#
|
|
79
|
+
# Add title to BibTeX item
|
|
80
|
+
#
|
|
81
|
+
def add_title
|
|
82
|
+
return unless @bib.title&.any?
|
|
83
|
+
|
|
84
|
+
title = @bib.title.find { |t| t.type == "main" } || @bib.title.first
|
|
85
|
+
return unless title
|
|
86
|
+
|
|
87
|
+
@item .title = title.content
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
#
|
|
91
|
+
# Add booktitle to BibTeX item
|
|
92
|
+
#
|
|
93
|
+
def add_booktitle # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
|
|
94
|
+
return unless @bib.relation&.any?
|
|
95
|
+
|
|
96
|
+
included_in = @bib.relation.detect { |r| r.type == "includedIn" }
|
|
97
|
+
return unless included_in && included_in.bibitem.title&.any?
|
|
98
|
+
|
|
99
|
+
@item.booktitle = included_in.bibitem.title.first.content
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
#
|
|
103
|
+
# Add author to BibTeX item
|
|
104
|
+
#
|
|
105
|
+
def add_author
|
|
106
|
+
add_author_editor "author"
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
#
|
|
110
|
+
# Add editor to BibTeX item
|
|
111
|
+
#
|
|
112
|
+
def add_editor
|
|
113
|
+
add_author_editor "editor"
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
#
|
|
117
|
+
# Add author or editor to BibTeX item
|
|
118
|
+
#
|
|
119
|
+
# @param [String] type "author" or "editor"
|
|
120
|
+
#
|
|
121
|
+
def add_author_editor(type) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
122
|
+
return unless @bib.contributor&.any?
|
|
123
|
+
|
|
124
|
+
contribs = @bib.contributor.select do |c|
|
|
125
|
+
c.person && c.role.any? { |e| e.type == type }
|
|
126
|
+
end.map &:person
|
|
127
|
+
|
|
128
|
+
return unless contribs.any?
|
|
129
|
+
|
|
130
|
+
@item.send "#{type}=", concat_names(contribs)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
#
|
|
134
|
+
# Concatenate names of contributors
|
|
135
|
+
#
|
|
136
|
+
# @param [Array<Relaton::Bib::Person>] contribs contributors
|
|
137
|
+
#
|
|
138
|
+
# @return [String] concatenated names
|
|
139
|
+
#
|
|
140
|
+
def concat_names(contribs)
|
|
141
|
+
contribs.map do |p|
|
|
142
|
+
if p.name.surname
|
|
143
|
+
"#{p.name.surname.content}, #{p.name.forename.map(&:content).join(' ')}"
|
|
144
|
+
else
|
|
145
|
+
p.name.completename.content
|
|
146
|
+
end
|
|
147
|
+
end.join(" and ")
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
#
|
|
151
|
+
# Add series to BibTeX item
|
|
152
|
+
#
|
|
153
|
+
def add_series # rubocop:disable Metrics/AbcSize
|
|
154
|
+
return unless @bib.series
|
|
155
|
+
|
|
156
|
+
@bib.series.each do |s|
|
|
157
|
+
case s.type
|
|
158
|
+
when "journal"
|
|
159
|
+
@item.journal = s.title.first.content
|
|
160
|
+
@item.number = s.number if s.number
|
|
161
|
+
when nil then @item.series = s.title.first.content
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
#
|
|
167
|
+
# Add number to BibTeX item
|
|
168
|
+
#
|
|
169
|
+
def add_number
|
|
170
|
+
return unless %w[techreport manual].include? @bib.type
|
|
171
|
+
|
|
172
|
+
did = @bib.docidentifier.detect { |i| i.primary == true }
|
|
173
|
+
did ||= @bib.docidentifier.first
|
|
174
|
+
@item.number = did.content if did
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
#
|
|
178
|
+
# Add edition to BibTeX item
|
|
179
|
+
#
|
|
180
|
+
def add_edition
|
|
181
|
+
@item.edition = @bib.edition.content if @bib.edition
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
#
|
|
185
|
+
# Add contributor to BibTeX item
|
|
186
|
+
#
|
|
187
|
+
def add_contributor # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
|
188
|
+
@bib.contributor.each do |c|
|
|
189
|
+
rls = c.role.map(&:type)
|
|
190
|
+
if rls.include?("publisher") then @item.publisher = c.organization.name.first.content
|
|
191
|
+
elsif rls.include?("distributor")
|
|
192
|
+
case @bib.type
|
|
193
|
+
when "techreport" then @item.institution = c.organization.name.first.content
|
|
194
|
+
when "inproceedings", "conference", "manual", "proceedings"
|
|
195
|
+
@item.organization = c.organization.name.first.content
|
|
196
|
+
when "mastersthesis", "phdthesis" then @item.school = c.organization.name.first.content
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
#
|
|
203
|
+
# Add date to BibTeX item
|
|
204
|
+
#
|
|
205
|
+
def add_date
|
|
206
|
+
array(@bib.date).each do |d|
|
|
207
|
+
case d.type
|
|
208
|
+
when "published"
|
|
209
|
+
year, month, = d.at.split("-")
|
|
210
|
+
@item.year = year
|
|
211
|
+
@item.month = month if month
|
|
212
|
+
when "accessed" then @item.urldate = d.at.to_s
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
#
|
|
218
|
+
# Add address to BibTeX item
|
|
219
|
+
#
|
|
220
|
+
def add_address # rubocop:disable Metrics/AbcSize
|
|
221
|
+
return unless @bib.place&.any?
|
|
222
|
+
|
|
223
|
+
reg = @bib.place[0].region[0].content if @bib.place[0].region.any?
|
|
224
|
+
addr = [@bib.place[0].formatted_place, @bib.place[0].city, reg]
|
|
225
|
+
@item.address = addr.compact.join(", ")
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
#
|
|
229
|
+
# Add note to BibTeX item
|
|
230
|
+
#
|
|
231
|
+
def add_note # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
|
232
|
+
array(@bib.note).each do |n|
|
|
233
|
+
case n.type
|
|
234
|
+
when "annote" then @item.annote = n.content
|
|
235
|
+
when "howpublished" then @item.howpublished = n.content
|
|
236
|
+
when "comment" then @item.comment = n.content
|
|
237
|
+
when "tableOfContents" then @item.content = n.content
|
|
238
|
+
when nil then @item.note = n.content
|
|
239
|
+
end
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
#
|
|
244
|
+
# Add relation to BibTeX item
|
|
245
|
+
#
|
|
246
|
+
def add_relation # rubocop:disable Metrics/AbcSize
|
|
247
|
+
rel = array(@bib.relation).detect { |r| r.type == "partOf" }
|
|
248
|
+
if rel && rel.bibitem.title&.any?
|
|
249
|
+
title_main = rel.bibitem.title.detect { |t| t.type == "main" }
|
|
250
|
+
@item.booktitle = title_main.content
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
#
|
|
255
|
+
# Add extent to BibTeX item
|
|
256
|
+
#
|
|
257
|
+
def add_extent # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
258
|
+
@bib.extent&.each do |extent|
|
|
259
|
+
extent.locality&.each { |loc| add_locality loc } ||
|
|
260
|
+
extent.locality_stack&.each { |locs| add_locality_stack locs }
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def add_locality_stack(locs)
|
|
265
|
+
return unless locs
|
|
266
|
+
|
|
267
|
+
locs.locality.each { |loc| add_locality loc }
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
def add_locality(loc)
|
|
271
|
+
case loc.type
|
|
272
|
+
when "chapter" then @item.chapter = loc.reference_from
|
|
273
|
+
when "page"
|
|
274
|
+
value = [loc.reference_from]
|
|
275
|
+
value << loc.reference_to if loc.reference_to
|
|
276
|
+
@item.pages = value.join("--")
|
|
277
|
+
when "volume" then @item.volume = loc.reference_from
|
|
278
|
+
when "issue" then @item.issue = loc.reference_from
|
|
279
|
+
end
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
#
|
|
283
|
+
# Add classification to BibTeX item
|
|
284
|
+
#
|
|
285
|
+
def add_classification
|
|
286
|
+
@bib.classification&.each do |c|
|
|
287
|
+
case c.type
|
|
288
|
+
when "type" then @item["type"] = c.content
|
|
289
|
+
when "mendeley" then @item["mendeley-tags"] = c.content
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
#
|
|
295
|
+
# Add keywords to BibTeX item
|
|
296
|
+
#
|
|
297
|
+
def add_keyword
|
|
298
|
+
if @bib.keyword&.any?
|
|
299
|
+
@item.keywords = @bib.keyword.reduce([]) do |m, kw|
|
|
300
|
+
m + (kw.vocab ? [kw.vocab.content] : kw.taxon.map(&:content))
|
|
301
|
+
end.join(", ")
|
|
302
|
+
end
|
|
303
|
+
end
|
|
304
|
+
|
|
305
|
+
#
|
|
306
|
+
# Add docidentifier to BibTeX item
|
|
307
|
+
#
|
|
308
|
+
def add_docidentifier
|
|
309
|
+
@bib.docidentifier&.each do |i|
|
|
310
|
+
case i.type
|
|
311
|
+
when "isbn" then @item.isbn = i.content
|
|
312
|
+
when "lccn" then @item.lccn = i.content
|
|
313
|
+
when "issn" then @item.issn = i.content
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
#
|
|
319
|
+
# Add identifier to BibTeX item
|
|
320
|
+
#
|
|
321
|
+
def add_timestamp
|
|
322
|
+
@item.timestamp = @bib.fetched.to_s if @bib.fetched
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
#
|
|
326
|
+
# Add link to BibTeX item
|
|
327
|
+
#
|
|
328
|
+
def add_link # rubocop:disable Metrics/CyclomaticComplexity
|
|
329
|
+
@bib.source&.each do |l|
|
|
330
|
+
case l.type&.downcase
|
|
331
|
+
when "doi" then @item.doi = l.content
|
|
332
|
+
when "file" then @item.file2 = l.content
|
|
333
|
+
when "src" then @item.url = l.content
|
|
334
|
+
end
|
|
335
|
+
end
|
|
336
|
+
end
|
|
337
|
+
end
|
|
338
|
+
end
|
|
339
|
+
end
|
|
340
|
+
end
|
|
341
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require_relative "bibtex/from_bibtex"
|
|
2
|
+
require_relative "bibtex/to_bibtex"
|
|
3
|
+
|
|
4
|
+
module Relaton
|
|
5
|
+
module Bib
|
|
6
|
+
module Converter
|
|
7
|
+
module Bibtex
|
|
8
|
+
# ItemData -> BibTeX::Bibliography
|
|
9
|
+
def self.from_item(item, bibtex = nil)
|
|
10
|
+
ToBibtex.new(item).transform(bibtex)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# BibTeX string -> Hash{String=>ItemData}
|
|
14
|
+
def self.to_item(bibtex_str)
|
|
15
|
+
BibTeX.parse(bibtex_str).reduce({}) do |h, bt|
|
|
16
|
+
h[bt.key] = FromBibtex.new(bt).transform
|
|
17
|
+
h
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|