uc3-dmp-id 0.1.26 → 0.1.28

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f692820577dff088fec1d1df2e4975a00a6b30952fa66979b1fa8449523d092e
4
- data.tar.gz: 8bf2326f3a6fddf9454e915c596eb40231c939337e517de73f6ea998f04a9d6f
3
+ metadata.gz: f984b52821821510b5be7f91887b366b67f2dfd9e85f29bfaa2a988b34dff2f3
4
+ data.tar.gz: 5e6d1ced0429757d65c61b5007e325e6ebe9ad8cd94b5fe67d4366289ed12c11
5
5
  SHA512:
6
- metadata.gz: fcc0689438e54715882ed7c30aa7d608e9c3abaa1e61fec7589a213c7665f257be933f93a482dc4d589756517c94a7f9b4803930f0a2a1bd51d877cd890b8a90
7
- data.tar.gz: df18ed7a17053c9527e6a111150b81c2a6d285bda1263b854b0cc3fae5b703e3ef9dd3213b62230431c898c948cf80f6e821da3515089e6cfc156622223bdf7e
6
+ metadata.gz: d23256d8ef17d0644351ddb1087ce918f6e6868fbcb0a81e13e8322d9fe39451854f19924040cb9f43fcc2163d7dc1efad53d538b0fdbbf871f1a728e625043b
7
+ data.tar.gz: c054f89e7c9347a61e5ea6a8d7246c6739410995a10f4d433fd0837c0d64097b9b70e51710d275fb4f0c0ef051e9cb60e579c40ee258bfdd45235c3889e5410e
@@ -53,35 +53,39 @@ module Uc3DmpId
53
53
  # }
54
54
  # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
55
55
  def compare(hash:)
56
- return [] unless hash.is_a?(Hash) && !hash['title'].nil?
56
+ scoring = []
57
+ return scoring unless hash.is_a?(Hash) && !hash['title'].nil?
57
58
 
58
- # Compare the grant ids. If we have a match return the response immediately since that is
59
- # a very positive match!
60
- scoring = @dmps.map do |entry|
59
+ @dmps.each do |entry|
61
60
  dmp = entry.fetch('_source', {})
62
- response = { dmp_id: dmp['_id'], confidence: 'None', score: 0, notes: [] }
61
+
62
+ # Compare the grant ids. If we have a match return the response immediately since that is
63
+ # a very positive match!
64
+ response = { confidence: 'None', score: 0, notes: [] }
63
65
  response = _grants_match?(array: hash.fetch('grant_ids', []), dmp:, response:)
64
- return response if response[:confidence] != 'None'
66
+ scoring << respoonse if response[:confidence] != 'None'
67
+ next if response[:confidence] != 'None'
65
68
 
69
+ # Compare the people involved, their affiliations and any funding opportunity numbers
66
70
  response = _opportunities_match?(array: hash.fetch('funder_opportunity_ids', []), dmp:, response:)
67
71
  response = _orcids_match?(array: hash.fetch('people_ids', []), dmp:, response:)
68
72
  response = _last_name_and_affiliation_match?(hash:, dmp:, response:)
69
73
 
70
- # Only process the following if we had some matching contributors, affiliations or opportuniy nbrs
74
+ # Only process the following if we had some matching people, affiliations or opportunity nbrs
71
75
  response = _repository_match?(hash:, dmp:, response:) if response[:score].positive?
72
- # response = _keyword_match?(array: hash['keywords'], response:) if response[:score].positive?
73
76
  response = _text_match?(type: 'title', text: hash['title'], dmp:, response:) if response[:score].positive?
74
77
  response = _text_match?(type: 'abstract', text: hash['description'], dmp:, response:) if response[:score].positive?
75
78
  # If the score is less than 3 then we have no confidence that it is a match
76
- return nil if response[:score] <= 2
79
+ next if response[:score] <= 2
77
80
 
78
81
  # Set the confidence level based on the score
82
+ response[:dmp_id] = dmp['_id']
79
83
  response[:confidence] = if response[:score] > 10
80
84
  'High'
81
85
  else
82
86
  (response[:score] > 5 ? 'Medium' : 'Low')
83
87
  end
84
- response
88
+ scoring << response
85
89
  end
86
90
 
87
91
  # TODO: introduce a tie-breaker here (maybe the closes to the project_end date)
@@ -171,7 +175,7 @@ module Uc3DmpId
171
175
  # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
172
176
  def _last_name_and_affiliation_match?(hash:, dmp:, response:)
173
177
  return response unless hash.is_a?(Hash) && dmp.is_a?(Hash) && response.is_a?(Hash)
174
- return response unless hash['people'].is_a?(Array) && !dmp['people'].empty?
178
+ return response unless hash['people'].is_a?(Array)
175
179
 
176
180
  # Check the person last names and affiliation name and RORs
177
181
  last_names_matched = _compare_arrays(array_a: dmp['people'], array_b: hash['people'])
@@ -193,7 +197,7 @@ module Uc3DmpId
193
197
  # rubocop:disable Metrics/AbcSize
194
198
  def _repository_match?(hash:, dmp:, response:)
195
199
  return response unless hash.is_a?(Hash) && dmp.is_a?(Hash) && response.is_a?(Hash)
196
- return response unless hash['repo_ids'].is_a?(Array) && !dmp['repo_ids'].empty?
200
+ return response unless hash['repo_ids'].is_a?(Array)
197
201
 
198
202
  matched = _compare_arrays(array_a: dmp['repo_ids'], array_b: hash['repo_ids'])
199
203
  return response if matched <= 0
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.1.26'
4
+ VERSION = '0.1.28'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.26
4
+ version: 0.1.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-10 00:00:00.000000000 Z
11
+ date: 2024-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json