metanorma / pubid-iso

Implementation of ISO pubid
BSD 2-Clause "Simplified" License
1 stars 0 forks source link

Supplement PubIDs are the main, not a part of the base PubID #130

Closed ronaldtse closed 2 years ago

ronaldtse commented 2 years ago

Now that the gem is getting in use there is a major issue that we need to fix. The behavior right now with how the library implements supplements is not quite correct.

Case 1:

Pubid::Iso::Identifier.parse("ISO 17301-1:2030/CD Amd 1").typed_stage_abbrev
# is returning nil
# should return "CD Amd"

Notice that this case is due to different expectations:

Case 2:

Pubid::Iso::Identifier.parse("ISO FDIS 17301-1:2030/CD Amd 1").baseid.typed_stage_abbrev
# should return "FDIS"

In this case, we query the baseid of the Amendment PubID and obtain "FDIS".

This ticket will have ramifications on the creation of PubIDs. Instead of adding "amendment" or "corrigendum" to a PubID, we should switch the parameters.

> baseid = Pubid::Iso::Identifier.new(publisher: :iso, number: 1234, part: 1, year: 2019)
> pubid = Pubid::Iso::Identifier.new(type: :amd, number: 1, stage: :wd, year: 2021, base: baseid)
> pubid.to_s
=> "ISO 1234-1:2019/WD Amd 1:2021"

# was:
# > pubid = Pubid::Iso::Identifier.new(publisher: "ISO", number: 123, part: 1, year: 2019, amendments: [{ number: "1", year: "2021", stage: :WD }])

> pubid = Pubid::Iso::Identifier.new(type: :amd, number: 1, stage: :wd, year: 2021, base: {publisher: :iso, number: 1234, part: 1, year: 2019})
> pubid.to_s
=> "ISO 1234-1:2019/WD Amd 1:2021"

# NOTE: we can also drop `publisher: :iso` because it is the default publisher.
> pubid = Pubid::Iso::Identifier.new(type: :amd, number: 1, stage: :wd, year: 2021, base: {number: 1234, part: 1, year: 2019})
> pubid.to_s
=> "ISO 1234-1:2019/WD Amd 1:2021"

# The publisher must be set at the base PubID, because if the base document was ISO/IEC, the Amd cannot be from another publisher. The supplement must inherit the publisher from the base PubID. As long as the publishers match, the following is also possible.
> pubid = Pubid::Iso::Identifier.new(publisher: :iso, type: :amd, number: 1, stage: :wd, year: 2021, base: {publisher: :iso, number: 1234, part: 1, year: 2019})
> pubid.to_s
=> "ISO 1234-1:2019/WD Amd 1:2021"

# Some users may want to set the publisher at the outermost layer and omit it in the base (this only works if the base is specified using a hash, if the base is a pubid, it would already have the publisher).
> pubid = Pubid::Iso::Identifier.new(publisher: :iso, type: :amd, number: 1, stage: :wd, year: 2021, base: {number: 1234, part: 1, year: 2019})
> pubid.to_s
=> "ISO 1234-1:2019/WD Amd 1:2021"

Originally posted by @ronaldtse in https://github.com/metanorma/pubid-iso/issues/125#issuecomment-1267085567

mico commented 2 years ago
> baseid = Pubid::Iso::Identifier.new(publisher: :iso, number: 1234, part: 1, year: 2019)
> pubid = Pubid::Iso::Identifier.new(type: :amd, number: 1, stage: :wd, year: 2021, base: baseid)
> pubid.to_s
=> "ISO 1234-1:2019/WD Amd 1:2021"

Maybe it should be something like:

baseid = Pubid::Iso::Identifier.new(publisher: :iso, number: 1234, part: 1, year: 2019) amendment = Pubid::Iso::Amendment.new(number: 1, stage: :wd, year: 2021, base: baseid) amendment.to_s ?

Also for pubid-iec there are several supplements could be applied to the document. (CISPR TR 16-4-4:2007+AMD1:2017+AMD2:2020 CSV) How could it work for the identifiers with several supplements?

ronaldtse commented 2 years ago

@mico we want to stay with the same Identifier class, as Amendment identifiers are also Identifiers.

Also for pubid-iec there are several supplements could be applied to the document. (CISPR TR 16-4-4:2007+AMD1:2017+AMD2:2020 CSV)

These are different in nature:

In the case of "CISPR TR 16-4-4:2007+AMD1:2017+AMD2:2020 CSV", the previous approach would actually be very appropriate, i.e.

# CISPR TR 16-4-4:2007+AMD1:2017+AMD2:2020 CSV
Pubid::Iec::Identifier.new(
  publisher: :visor,
  type: :tr,
  number: 16,
  part: 4,
  subpart: 4,
  year: 2007,
  amendments: [{
    number: 1,
    year: 2017
  },
  {
    number: 2,
    year: 2020
  }]
  # is "CSV" specified as an "added value"?
)
mico commented 2 years ago

In the case of "CISPR TR 16-4-4:2007+AMD1:2017+AMD2:2020 CSV", the previous approach would actually be very appropriate, i.e.

Is it the same for identiier "ISO/IEC 13818-1:2015/Amd 3:2016/Cor 1:2017"? Amendment and Corrigendum as add-on to the base identifier?

ronaldtse commented 2 years ago

@mico No, this is yet another case.

This is a Technical Corrigendum "Cor 1:2017" that applies to a base identifier of "ISO/IEC 13818-1:2015/Amd 3:2016". And this is a single document of the Technical Corrigendum (not a combined document because it uses / not +).

I.e. there are 3 levels here:

Pubid.new(
  base: Pubid.new(
    base: (Pubid.new("ISO/IEC 13818-1:2015"), type: :amd, number: 3, year: 2016)
  ),
  type: cor,
  number: 1,
  year: 2017
)
opoudjis commented 2 years ago

This issue remains a blocker for https://github.com/metanorma/metanorma-iso/issues/657