-
Notifications
You must be signed in to change notification settings - Fork 0
/
kbart_collection_analysis.rb
executable file
·40 lines (30 loc) · 1.32 KB
/
kbart_collection_analysis.rb
1
2
3
4
5
6
7
8
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
require 'bundler/setup'
require 'active_sierra_models'
require 'csv'
require 'fuzzystringmatch'
require_relative 'lib/item'
require_relative 'lib/kbart'
require_relative 'lib/functions'
issn_index
distance = FuzzyStringMatch::JaroWinkler.create( :pure )
kbart = CSV.read(ARGV[0], col_sep: "\t", headers: :first_row)
puts "Overlap?\tTitle from Sierra\tTitle from holdings\tTitle ratio\tItem #\tstatus\tLocation\tCall #\tVolume\tNote\tHoldings collection\tHoldings"
kbart.each do |row|
holding = KBART.new(row, @issn_hash)
next if holding.bib_records.length == 0
holding.bib_records.each do |bib_number|
b = BibView.where("record_num = ?", bib_number).first
next if b.cataloging_date_gmt = nil
next unless b.bcode3 = '-'
bib_title = b.title
title_comparison = distance.getDistance( bib_title, holding.title )
items = b.item_views.collect { |i| Item.new(i) }
items.each do |i|
next unless i.location =~ /^u/
next if i.location == 'uint'
next if i.status == 'w'
next unless i.supression == "-"
puts "#{holding.within_holdings?(i.dates)}\t#{bib_title}\t#{holding.title}\t#{title_comparison}\ti#{i.item_number}a\t#{i.status}\t#{i.location}\t#{i.call_number}\t#{i.volume}\t#{i.note}\t#{holding.collection}\t#{holding.begin_date.year}-#{holding.end_date.year}"
end
end
end