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