qa 5.10.0 → 5.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/qa/authorities/getty/aat2.rb +62 -0
- data/lib/qa/data/TGN_LANGUAGES.xml +1 -1
- data/lib/qa/engine.rb +13 -0
- data/lib/qa/version.rb +1 -1
- data/spec/lib/services/rdf_authority_parser_spec.rb +1 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b356b770cbc77b1d67024f2a73be01b579943e75d9bda64e7f7dad04f66342b
|
4
|
+
data.tar.gz: a3f6a66764724811209c8616e00f260cab0d371f340117f335d384c1f84d1bd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 798c03132eac1750d15b0db93e2c6009925b1ebd3773619df77cd11f3f0cd661b6645d5e54122842efdc3e86d221356fb38aca6705943c35a5dc03d0a7010d2d
|
7
|
+
data.tar.gz: f1a3e23f4f3eb3197c3f8e39e2a9663ae7329a7e1e46e100f60d91f3b01b55e46a19ded39ac4b88520ec29189adc1e3d948bbfca7422044a92dc2c26d6eb3367
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Qa::Authorities
|
2
|
+
class Getty::AAT2 < Base
|
3
|
+
include WebServiceBase
|
4
|
+
|
5
|
+
def search(q)
|
6
|
+
parse_authority_response(json(build_query_url(q)))
|
7
|
+
end
|
8
|
+
|
9
|
+
def build_query_url(q)
|
10
|
+
"http://vocab.getty.edu/sparql.json?query=#{ERB::Util.url_encode(sparql(q))}&_implicit=false&implicit=true&_equivalent=false&_form=%2Fsparql"
|
11
|
+
end
|
12
|
+
|
13
|
+
def sparql(q) # rubocop:disable Metrics/MethodLength
|
14
|
+
search = untaint(q)
|
15
|
+
if search.include?(' ')
|
16
|
+
clauses = search.split(' ').collect do |i|
|
17
|
+
%((regex(?name, "#{i}", "i")))
|
18
|
+
end
|
19
|
+
ex = "(#{clauses.join(' && ')})"
|
20
|
+
else
|
21
|
+
ex = %(regex(?name, "#{search}", "i"))
|
22
|
+
end
|
23
|
+
# The full text index matches on fields besides the term, so we filter to ensure the match is in the term.
|
24
|
+
%(SELECT ?s ?name {
|
25
|
+
?s a skos:Concept; luc:term "#{search}";
|
26
|
+
skos:inScheme <http://vocab.getty.edu/aat/> ;
|
27
|
+
gvp:prefLabelGVP [skosxl:literalForm ?name].
|
28
|
+
FILTER #{ex} .
|
29
|
+
} ORDER BY ?name).gsub(/[\s\n]+/, " ")
|
30
|
+
end
|
31
|
+
|
32
|
+
def untaint(q)
|
33
|
+
q.gsub(/[^\w\s-]/, '')
|
34
|
+
end
|
35
|
+
|
36
|
+
def find(id)
|
37
|
+
json(find_url(id))
|
38
|
+
end
|
39
|
+
|
40
|
+
def find_url(id)
|
41
|
+
"http://vocab.getty.edu/download/json?uri=http://vocab.getty.edu/aat/#{id}.json"
|
42
|
+
end
|
43
|
+
|
44
|
+
def request_options
|
45
|
+
{ accept: 'application/sparql-results+json' }
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
# Reformats the data received from the Getty service
|
51
|
+
def parse_authority_response(response)
|
52
|
+
response['results']['bindings'].map do |result|
|
53
|
+
{ 'id' => result['s']['value'], 'label' => result['name']['value'] }
|
54
|
+
end
|
55
|
+
rescue StandardError => e
|
56
|
+
cause = response.fetch('error', {}).fetch('cause', 'UNKNOWN')
|
57
|
+
cause = cause.present? ? cause : 'UNKNOWN'
|
58
|
+
Rails.logger.warn " ERROR fetching Getty response: #{e.message}; cause: #{cause}"
|
59
|
+
{}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<?xml version="1.0" encoding="
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
2
|
<Vocabulary xmlns="http://localhost/namespace" xmlns:vp="http://localhost/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://localhost/namespace Getty_Vocab_Export_Languages.xsd" Title="Thesaurus of Geographic Names" Part="Languages" Date="2011-04-11">
|
3
3
|
<Language>
|
4
4
|
<Language_Code>70115</Language_Code>
|
data/lib/qa/engine.rb
CHANGED
@@ -4,5 +4,18 @@ require 'qa/linked_data/authority_service'
|
|
4
4
|
module Qa
|
5
5
|
class Engine < ::Rails::Engine
|
6
6
|
isolate_namespace Qa
|
7
|
+
|
8
|
+
config.before_configuration do
|
9
|
+
# rubocop:disable Style/IfUnlessModifier
|
10
|
+
|
11
|
+
# see https://github.com/fxn/zeitwerk#for_gem
|
12
|
+
# Blacklight puts a generator into LOCAL APP lib/generators, so tell
|
13
|
+
# zeitwerk to ignore the whole directory? If we're using zeitwerk
|
14
|
+
#
|
15
|
+
# See: https://github.com/cbeer/engine_cart/issues/117
|
16
|
+
if Rails.try(:autoloaders).try(:main).respond_to?(:ignore)
|
17
|
+
Rails.autoloaders.main.ignore(Rails.root.join('lib', 'generators'))
|
18
|
+
end
|
19
|
+
end
|
7
20
|
end
|
8
21
|
end
|
data/lib/qa/version.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'spec_helper'
|
3
3
|
|
4
4
|
describe Qa::Services::RDFAuthorityParser do
|
5
|
-
let(:source) { [
|
5
|
+
let(:source) { [Qa::Engine.root.join('spec', 'fixtures', 'lexvo_snippet.rdf.xml')] }
|
6
6
|
let(:format) { 'rdfxml' }
|
7
7
|
let(:predicate) { RDF::URI("http://www.w3.org/2008/05/skos#prefLabel") }
|
8
8
|
let(:name) { 'language' }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Anderson
|
@@ -16,7 +16,7 @@ authors:
|
|
16
16
|
autorequire:
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
|
-
date:
|
19
|
+
date: 2023-11-09 00:00:00.000000000 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: activerecord-import
|
@@ -117,7 +117,7 @@ dependencies:
|
|
117
117
|
version: '5.0'
|
118
118
|
- - "<"
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
version: '7.
|
120
|
+
version: '7.2'
|
121
121
|
type: :runtime
|
122
122
|
prerelease: false
|
123
123
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -127,7 +127,7 @@ dependencies:
|
|
127
127
|
version: '5.0'
|
128
128
|
- - "<"
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: '7.
|
130
|
+
version: '7.2'
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
name: rdf
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -475,6 +475,7 @@ files:
|
|
475
475
|
- lib/qa/authorities/geonames.rb
|
476
476
|
- lib/qa/authorities/getty.rb
|
477
477
|
- lib/qa/authorities/getty/aat.rb
|
478
|
+
- lib/qa/authorities/getty/aat2.rb
|
478
479
|
- lib/qa/authorities/getty/tgn.rb
|
479
480
|
- lib/qa/authorities/getty/ulan.rb
|
480
481
|
- lib/qa/authorities/linked_data.rb
|
@@ -660,7 +661,8 @@ files:
|
|
660
661
|
homepage: https://github.com/projecthydra/questioning_authority
|
661
662
|
licenses:
|
662
663
|
- APACHE-2
|
663
|
-
metadata:
|
664
|
+
metadata:
|
665
|
+
rubygems_mfa_required: 'true'
|
664
666
|
post_install_message:
|
665
667
|
rdoc_options: []
|
666
668
|
require_paths:
|
@@ -676,7 +678,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
676
678
|
- !ruby/object:Gem::Version
|
677
679
|
version: '0'
|
678
680
|
requirements: []
|
679
|
-
rubygems_version: 3.
|
681
|
+
rubygems_version: 3.4.21
|
680
682
|
signing_key:
|
681
683
|
specification_version: 4
|
682
684
|
summary: You should question your authorities.
|