class AnyStyle::Normalizer::Type
Public Instance Methods
classify(item)
click to toggle source
# File lib/anystyle/normalizer/type.rb 9 def classify(item) 10 keys = item.keys 11 12 case 13 when keys.include?(:'container-title') 14 case 15 when keys.include?(:issue) 16 'article-journal' 17 when item[:'container-title'].to_s =~ /proceedings|proc\.|conference|meeting|symposi(on|um)/i 18 'paper-conference' 19 when item[:'container-title'].to_s =~ /journal|zeitschrift|quarterly|review|revue/i 20 'article-journal' 21 else 22 'chapter' 23 end 24 when keys.include?(:genre), keys.include?(:note) 25 case item.values_at(:genre, :note).flatten.join(' ') 26 when /ph(\.\s*)?d|diss(\.|ertation)|thesis/i 27 'thesis' 28 when /rep(\.|ort)/i 29 'report' 30 when /unpublished|manuscript/i 31 'manuscript' 32 when /patent/i 33 'patent' 34 when /personal communication/i 35 'personal_communication' 36 when /interview/i 37 'interview' 38 when /web|online|en ligne/ 39 'webpage' 40 end 41 when keys.include?(:medium) 42 case item[:medium].to_s 43 when /dvd|video|vhs|motion/i 44 'motion_picture' 45 when /television/i 46 'broadcast' 47 end 48 when keys.include?(:publisher) 49 'book' 50 end 51 end
normalize(item, **opts)
click to toggle source
# File lib/anystyle/normalizer/type.rb 4 def normalize(item, **opts) 5 item[:type] = classify item unless item.key?(:type) 6 item 7 end