glossarist / iev-data

1 stars 1 forks source link

Add specs for other source extraction patterns #198

Open ronaldtse opened 3 years ago

ronaldtse commented 3 years ago
  describe ".extract_source_ref" do

    it "parses 'SI Brochure'" do
      phrases = [
        'SI Brochure, 9th edition, 2019, 2.3.1',
        'SI Brochure, 9th edition, 2019, Appendix 1',
        'Brochure sur le SI, 9<sup>e</sup> édition, 2019, Annexe 1'
      ]

      results = phrases.map do |p|
        builder.extract_source_ref(p)
      end

      expect(results.all? { |r| r == 'BBIPM SI Brochure TEMP DISABLED DUE TO RELATON' })
    end

    it "parses 'VIM'" do
      phrases = [
        '≠ VIM 3.1',
        '≈ VIM 3.1',
        'VIM 3.1',
        'VIM 3.1 MOD',
        '≠ VIM 3.10 + NOTE 2'
      ]

      results = phrases.map do |p|
        builder.extract_source_ref(p)
      end

      expect(results.all? { |r| r == 'JCGM VIM' })
    end

    # TODO
    # # IEC 60050-121, 151-12-05
    # when /IEC 60050-(\d+), (\d{2,3}-\d{2,3}-\d{2,3})/
    #   "IEC 60050-#{$LAST_MATCH_INFO[1]}"
    # when /IEC 60050-(\d+):(\d+), (\d{2,3}-\d{2,3}-\d{2,3})/
    #   "IEC 60050-#{$LAST_MATCH_INFO[1]}:#{$LAST_MATCH_INFO[2]}"
    # when /(AIEA|IAEA) (\d+)/
    #   "IAEA #{$LAST_MATCH_INFO[2]}"
    # when /IEC\sIEEE ([\d\:\-]+)/
    #   "IEC/IEEE #{$LAST_MATCH_INFO[1]}".sub(/:\Z/, "")
    # when /CISPR ([\d\:\-]+)/
    #   "IEC CISPR #{$LAST_MATCH_INFO[1]}"
    # when /RR (\d+)/
    #   "ITU RR"
    # # IEC 50(845)
    # when /IEC (\d+)\((\d+)\)/
    #   "IEC 600#{$LAST_MATCH_INFO[1]}-#{$LAST_MATCH_INFO[1]}"
    # when /(ISO|IEC)[\/\ ](PAS|TR|TS) ([\d\:\-]+)/
    #   "#{$LAST_MATCH_INFO[1]}/#{$LAST_MATCH_INFO[2]} #{$LAST_MATCH_INFO[3]}".sub(/:\Z/, "")
    # when /ISO\/IEC ([\d\:\-]+)/
    #   "ISO/IEC #{$LAST_MATCH_INFO[1]}".sub(/:\Z/, "")
    # when /ISO\/IEC\/IEEE ([\d\:\-]+)/
    #   "ISO/IEC/IEEE #{$LAST_MATCH_INFO[1]}".sub(/:\Z/, "")
    #
    # # ISO 140/4
    # when /ISO (\d+)\/(\d+)/
    #   "ISO #{$LAST_MATCH_INFO[1]}-#{$LAST_MATCH_INFO[2]}"
    # when /Norme ISO (\d+)-(\d+)/
    #   "ISO #{$LAST_MATCH_INFO[1]}:#{$LAST_MATCH_INFO[2]}"
    # when /ISO\/IEC Guide ([\d\:\-]+)/i
    #   "ISO/IEC Guide #{$LAST_MATCH_INFO[1]}".sub(/:\Z/, "")
    # when /(ISO|IEC) Guide ([\d\:\-]+)/i
    #   "#{$LAST_MATCH_INFO[1]} Guide #{$LAST_MATCH_INFO[2]}".sub(/:\Z/, "")
    #
    # # ITU-T Recommendation F.791 (11/2015)
    # when /ITU-T Recommendation (\w.\d+) \((\d+\/\d+)\)/i
    #   "ITU-T Recommendation #{$LAST_MATCH_INFO[1]} (#{$LAST_MATCH_INFO[2]})"
    #
    # # ITU-T Recommendation F.791:2015
    # when /ITU-T Recommendation (\w.\d+):(\d+)/i
    #   "ITU-T Recommendation #{$LAST_MATCH_INFO[1]} (#{$LAST_MATCH_INFO[2]})"
    #
    # when /ITU-T Recommendation (\w\.\d+)/i
    #   "ITU-T Recommendation #{$LAST_MATCH_INFO[1]}"
    #
    # # ITU-R Recommendation 592 MOD
    # when /ITU-R Recommendation (\d+)/i
    #   "ITU-R Recommendation #{$LAST_MATCH_INFO[1]}"
    # # ISO 669: 2000 3.1.16
    # when /ISO ([\d\-]+:\s?\d{4})/
    #   "ISO #{$LAST_MATCH_INFO[1]}".sub(/:\Z/, "")
    # when /ISO ([\d\:\-]+)/
    #   "ISO #{$LAST_MATCH_INFO[1]}".sub(/:\Z/, "")
    # when /IEC ([\d\:\-]+)/
    #   "IEC #{$LAST_MATCH_INFO[1]}".sub(/:\Z/, "")
    # when /definition (\d\.[\d\.]+) of ([\d\-])/
    #   "IEC #{$LAST_MATCH_INFO[2]}".sub(/:\Z/, "")
    # when /définition (\d\.[\d\.]+) de la ([\d\-])/
    #   "IEC #{$LAST_MATCH_INFO[2]}".sub(/:\Z/, "")
    #
    # when /IEV (\d{2,3}-\d{2,3}-\d{2,3})/, /(\d{2,3}-\d{2,3}-\d{2,3})/
    #   "IEV"
    # when /IEV part\s+(\d+)/, /partie\s+(\d+)\s+de l'IEV/
    #   "IEC 60050-#{$LAST_MATCH_INFO[1]}"
    #
    # when /International Telecommunication Union (ITU) Constitution/,
    #   /Constitution de l’Union internationale des télécommunications (UIT)/
    #   "International Telecommunication Union (ITU) Constitution (Ed. 2015)"