uc3-dmp-id 0.1.37 → 0.1.38

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: 4b8c0ff9aa6add1fc2da937d9f76872ae6bb287adf5df008d9c0d434f25fd717
4
- data.tar.gz: a0479d353eb1d64cfab1bdb718f3efcf6a1d66cec8ea444ab735e74708f88984
3
+ metadata.gz: cec9b27f000aa3543c1a53c70c2ac6e6734ad1e0c70a98b7f583db986941ba43
4
+ data.tar.gz: da94a81c40adc7d9c4bea9767ec90bbdeab18f4445a27853fe1ae2e5d51b3c97
5
5
  SHA512:
6
- metadata.gz: a578c6b89bb5d94172d5e2c24255f81326871616767039a4aa4de6d1c00da4a9d16fcf20f26a4479d8d1d5017e90dfcb27ca9c6c4bb5b1ed5421928bfb518eeb
7
- data.tar.gz: 3dc8d1999fb6f26cdf8fc465d160513982ac7607bfb7c5e4c5f719b4f43d3b5d82261c5c4ce87cdd10be1d1631276b212b54cfd60b3f5523b389b3f4da25dbe5
6
+ metadata.gz: e89112bbaae3d06adb736c4b0d846c82b27dbfdf90db8d73079a5b83740f04b1f771f8214121884275fd907a8150ad640e9b85689320d23e628d466c8f0d0a65
7
+ data.tar.gz: a2a27c70445f104015bbe15cd5e19e2fffb0de82eae908ee1d335438d18cc29809ad334bdcb92280066541a22a5cb040b4ce1f3ab1d54cd0d9a217b8d6aeff92
@@ -70,14 +70,15 @@ module Uc3DmpId
70
70
  # Compare the people involved, their affiliations and any funding opportunity numbers
71
71
  response = _opportunities_match?(array: hash.fetch('funder_opportunity_ids', []), dmp:, response:)
72
72
  response = _orcids_match?(array: hash.fetch('people_ids', []), dmp:, response:)
73
- response = _last_name_and_affiliation_match?(hash:, dmp:, response:)
73
+ response = _last_name_match?(hash:, dmp:, response:)
74
+ response = _affiliation_match?(hash:, dmp:, response:)
74
75
 
75
76
  # Only process the following if we had some matching people, affiliations or opportunity nbrs
76
77
  response = _repository_match?(hash:, dmp:, response:) if response[:score].positive?
77
78
  response = _text_match?(type: 'title', text: hash['title'], dmp:, response:) if response[:score].positive?
78
79
  response = _text_match?(type: 'abstract', text: hash['description'], dmp:, response:) if response[:score].positive?
79
- # If the score is less than 4 then we have no confidence that it is a match
80
- next if response[:score] <= 3
80
+ # If the score is less than 3 then we have no confidence that it is a match
81
+ next if response[:score] <= 2
81
82
 
82
83
  # Set the confidence level based on the score
83
84
  response[:dmp_id] = "DMP##{dmp['dmp_id']}"
@@ -178,29 +179,46 @@ module Uc3DmpId
178
179
  # affiliation_ids: ["https://ror.org/blah"]
179
180
  # }
180
181
  # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
181
- def _last_name_and_affiliation_match?(hash:, dmp:, response:)
182
+ def _last_name_match?(hash:, dmp:, response:)
182
183
  return response unless hash.is_a?(Hash) && dmp.is_a?(Hash) && response.is_a?(Hash)
183
184
  return response unless hash['people'].is_a?(Array)
184
185
 
185
186
  # Check the person last names and affiliation name and RORs
186
187
  last_names_matched = _compare_arrays(array_a: dmp['people'], array_b: hash['people'])
188
+ return response if last_names_matched <= 0
189
+
190
+ @logger&.debug(
191
+ message: 'Contributor name match',
192
+ details: {
193
+ people: { dmp: dmp['people'], work: hash['people'] }
194
+ }
195
+ )
196
+ response[:score] += last_names_matched * 2
197
+ response[:notes] << 'contributor names matched'
198
+ response
199
+ end
200
+ # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
201
+
202
+ def _affiliation_match?(hash:, dmp:, response:)
203
+ return response unless hash.is_a?(Hash) && dmp.is_a?(Hash) && response.is_a?(Hash)
204
+ return response unless hash['affiliations'].is_a?(Array) || hash['affiliation_ids'].is_a?(Array)
205
+
206
+ # Check the affiliation names and RORs
187
207
  rors_matched = _compare_arrays(array_a: dmp.fetch('affiliation_ids', []), array_b: hash['affiliation_ids'])
188
208
  affil_names_matched = _compare_arrays(array_a: dmp.fetch('affiliations', []), array_b: hash['affiliations'])
189
- return response if last_names_matched <= 0 && rors_matched <= 0 && affil_names_matched <= 0
209
+ return response if rors_matched <= 0 && affil_names_matched <= 0
190
210
 
191
211
  @logger&.debug(
192
- message: 'Contributor name match',
212
+ message: 'Affiliation name match',
193
213
  details: {
194
- people: { dmp: dmp['people'], work: hash['people'] },
195
214
  rors: { dmp: dmp['affiliation_ids'], work: hash['affiliation_ids'] },
196
215
  places: { dmp: dmp['affiliations'], work: hash['affiliations'] }
197
216
  }
198
217
  )
199
- response[:score] += last_names_matched + rors_matched + affil_names_matched
200
- response[:notes] << 'contributor names and/or affiliations matched'
218
+ response[:score] += rors_matched + affil_names_matched
219
+ response[:notes] << 'affiliations matched'
201
220
  response
202
221
  end
203
- # rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
204
222
 
205
223
  # Returns whether or not the incoming list of repositories match those defined in the DMP. Expecting:
206
224
  # {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpId
4
- VERSION = '0.1.37'
4
+ VERSION = '0.1.38'
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.37
4
+ version: 0.1.38
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-05-02 00:00:00.000000000 Z
11
+ date: 2024-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json