iqvoc_similar_terms 0.8.0 → 2.11.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +67 -0
  3. data/.gitignore +11 -1
  4. data/Gemfile +14 -14
  5. data/Gemfile.lock +526 -146
  6. data/README.md +7 -12
  7. data/app/assets/javascripts/manifest.js +2 -0
  8. data/app/assets/stylesheets/manifest.scss +3 -0
  9. data/app/controllers/similar_terms_controller.rb +45 -12
  10. data/app/models/services/similar_terms_service.rb +141 -0
  11. data/app/views/similar_terms/_form.html.erb +21 -0
  12. data/app/views/similar_terms/new.html.erb +21 -0
  13. data/app/views/similar_terms/show.html.erb +32 -28
  14. data/app/views/similar_terms/show.xml.builder +17 -0
  15. data/bin/bundle +3 -0
  16. data/bin/rails +4 -0
  17. data/bin/rake +4 -0
  18. data/bin/setup +33 -0
  19. data/bin/update +31 -0
  20. data/bin/yarn +17 -0
  21. data/config/application.rb +30 -59
  22. data/config/boot.rb +3 -5
  23. data/config/cable.yml +10 -0
  24. data/config/database.yml.mysql +3 -3
  25. data/config/database.yml.postgresql +26 -0
  26. data/config/engine.rb +1 -1
  27. data/config/environment.rb +4 -4
  28. data/config/environments/development.rb +0 -1
  29. data/config/environments/test.rb +0 -1
  30. data/config/initializers/apipie.rb +5 -0
  31. data/config/initializers/content_security_policy.rb +25 -0
  32. data/config/initializers/filter_parameter_logging.rb +8 -0
  33. data/config/initializers/inflections.rb +16 -0
  34. data/config/initializers/iqvoc.rb +6 -4
  35. data/config/initializers/new_framework_defaults_6_1.rb +67 -0
  36. data/config/initializers/permissions_policy.rb +11 -0
  37. data/config/locales/de.yml +12 -0
  38. data/config/locales/en.yml +12 -0
  39. data/config/routes.rb +4 -7
  40. data/config/secrets.yml +8 -0
  41. data/config/storage.yml +34 -0
  42. data/config.ru +4 -2
  43. data/db/migrate/.gitkeep +0 -0
  44. data/faucet.config.js +46 -0
  45. data/iqvoc_similar_terms.gemspec +1 -2
  46. data/lib/iqvoc/similar_terms/version.rb +1 -1
  47. data/lib/iqvoc/similar_terms.rb +12 -71
  48. data/lib/iqvoc_similar_terms.rb +14 -1
  49. data/package-lock.json +1486 -0
  50. data/package.json +29 -0
  51. data/test/compound_forms.nt +20 -0
  52. data/test/concept_test.nt +25 -0
  53. data/test/concept_test.ttl +33 -0
  54. data/test/controllers/similar_terms_controller_test.rb +167 -0
  55. data/test/models/entity_resolution_test.rb +42 -0
  56. data/test/models/results_test.rb +105 -0
  57. data/test/similar_terms.nt +14 -0
  58. data/test/similar_terms.ttl +19 -0
  59. data/test/test_helper.rb +4 -0
  60. metadata +58 -25
  61. data/.travis.yml +0 -18
  62. data/config/initializers/secret_token.rb.template +0 -16
  63. data/config/initializers/wrap_parameters.rb +0 -14
  64. data/script/ci/travis-before-build +0 -19
  65. data/script/ci/travis-build +0 -11
  66. data/test/functional/api_test.rb +0 -68
  67. data/test/unit/entity_resolution_test.rb +0 -46
  68. data/test/unit/results_test.rb +0 -55
data/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "iqvoc_similar_terms",
3
+ "version": "2.11.3",
4
+ "description": "SimilarTerms extension for iQvoc",
5
+ "scripts": {
6
+ "watch": "faucet --watch",
7
+ "compile": "faucet --compact --fingerprint"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/innoq/iqvoc_similar_terms.git"
12
+ },
13
+ "author": "",
14
+ "license": "Apache License 2.0",
15
+ "bugs": {
16
+ "url": "https://github.com/innoq/iqvoc_similar_terms/issues"
17
+ },
18
+ "homepage": "https://github.com/innoq/iqvoc_similar_terms#readme",
19
+ "devDependencies": {
20
+ "faucet-pipeline-js": "^2.1.7",
21
+ "faucet-pipeline-jsmin": "^2.1.7",
22
+ "faucet-pipeline-sass": "^1.6.0",
23
+ "faucet-pipeline-static": "^1.2.0"
24
+ },
25
+ "dependencies": {
26
+ "es6-promise": "^4.2.8",
27
+ "iqvoc": "github:innoq/iqvoc"
28
+ }
29
+ }
@@ -0,0 +1,20 @@
1
+ <http://hobbies.com/computer_programming> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2004/02/skos/core#Concept> .
2
+ <http://hobbies.com/computer_programming> <http://www.w3.org/2008/05/skos-xl#prefLabel> <http://hobbies.com/computer_programming-en> .
3
+ <http://hobbies.com/computer_programming-en> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos-xl#Label> .
4
+ <http://hobbies.com/computer_programming-en> <http://www.w3.org/2008/05/skos-xl#literalForm> "Computer programming"@en .
5
+ <http://hobbies.com/computer-en> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos-xl#Label> .
6
+ <http://hobbies.com/computer-en> <http://www.w3.org/2008/05/skos-xl#literalForm> "Computer"@en .
7
+ <http://hobbies.com/programming-en> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos-xl#Label> .
8
+ <http://hobbies.com/programming-en> <http://www.w3.org/2008/05/skos-xl#literalForm> "Programming"@en .
9
+ <http://hobbies.com/cool-en> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos-xl#Label> .
10
+ <http://hobbies.com/cool-en> <http://www.w3.org/2008/05/skos-xl#literalForm> "Cool"@en .
11
+ <http://hobbies.com/computer_programming-en> <http://try.iqvoc.net/schema#compoundFrom> _:b3 .
12
+ _:b3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#List> .
13
+ _:b3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://hobbies.com/computer-en> .
14
+ _:b3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:b4 .
15
+ _:b4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#List> .
16
+ _:b4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://hobbies.com/programming-en> .
17
+ _:b4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:b5 .
18
+ _:b5 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#List> .
19
+ _:b5 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://hobbies.com/cool-en> .
20
+ _:b5 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
@@ -0,0 +1,25 @@
1
+ <http://localhost:3000/related_label> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos-xl#Label> .
2
+ <http://localhost:3000/related_label> <http://www.w3.org/2008/05/skos-xl#literalForm> "related"@en .
3
+ <http://localhost:3000/related> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2004/02/skos/core#Concept> .
4
+ <http://localhost:3000/related> <http://www.w3.org/2008/05/skos-xl#prefLabel> <http://localhost:3000/related_label> .
5
+ <http://localhost:3000/water_label> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos-xl#Label> .
6
+ <http://localhost:3000/water_label> <http://www.w3.org/2008/05/skos-xl#literalForm> "water"@en .
7
+ <http://localhost:3000/real_water_label> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos-xl#Label> .
8
+ <http://localhost:3000/real_water_label> <http://www.w3.org/2008/05/skos-xl#literalForm> "real water"@en .
9
+ <http://localhost:3000/water> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2004/02/skos/core#Concept> .
10
+ <http://localhost:3000/water> <http://www.w3.org/2008/05/skos-xl#prefLabel> <http://localhost:3000/water_label> .
11
+ <http://localhost:3000/water> <http://www.w3.org/2008/05/skos-xl#altLabel> <http://localhost:3000/real_water_label> .
12
+ <http://localhost:3000/water> <http://www.w3.org/2004/02/skos/core#related> <http://localhost:3000/related> .
13
+ <http://localhost:3000/used_water_label> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos-xl#Label> .
14
+ <http://localhost:3000/used_water_label> <http://www.w3.org/2008/05/skos-xl#literalForm> "used water"@en .
15
+ <http://localhost:3000/no_water_label> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos-xl#Label> .
16
+ <http://localhost:3000/no_water_label> <http://www.w3.org/2008/05/skos-xl#literalForm> "no water"@en .
17
+ <http://localhost:3000/used_water> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2004/02/skos/core#Concept> .
18
+ <http://localhost:3000/used_water> <http://www.w3.org/2008/05/skos-xl#prefLabel> <http://localhost:3000/used_water_label> .
19
+ <http://localhost:3000/used_water> <http://www.w3.org/2008/05/skos-xl#altLabel> <http://localhost:3000/no_water_label> .
20
+ <http://localhost:3000/used_water> <http://www.w3.org/2004/02/skos/core#broader> <http://localhost:3000/water> .
21
+ <http://localhost:3000/new_water_label> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos-xl#Label> .
22
+ <http://localhost:3000/new_water_label> <http://www.w3.org/2008/05/skos-xl#literalForm> "new water"@en .
23
+ <http://localhost:3000/new_water> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2004/02/skos/core#Concept> .
24
+ <http://localhost:3000/new_water> <http://www.w3.org/2008/05/skos-xl#prefLabel> <http://localhost:3000/new_water_label> .
25
+ <http://localhost:3000/new_water> <http://www.w3.org/2004/02/skos/core#broader> <http://localhost:3000/water> .
@@ -0,0 +1,33 @@
1
+ @prefix : <http://localhost:3000/>.
2
+ @prefix skos: <http://www.w3.org/2004/02/skos/core#>.
3
+ @prefix skosxl: <http://www.w3.org/2008/05/skos-xl#>.
4
+
5
+
6
+ :related_label a skosxl:Label;
7
+ skosxl:literalForm "related"@en.
8
+ :related a skos:Concept;
9
+ skosxl:prefLabel :related_label.
10
+
11
+ :water_label a skosxl:Label;
12
+ skosxl:literalForm "water"@en.
13
+ :real_water_label a skosxl:Label;
14
+ skosxl:literalForm "real water"@en.
15
+ :water a skos:Concept;
16
+ skosxl:prefLabel :water_label;
17
+ skosxl:altLabel :real_water_label;
18
+ skos:related :related.
19
+
20
+ :used_water_label a skosxl:Label;
21
+ skosxl:literalForm "used water"@en.
22
+ :no_water_label a skosxl:Label;
23
+ skosxl:literalForm "no water"@en.
24
+ :used_water a skos:Concept;
25
+ skosxl:prefLabel :used_water_label;
26
+ skosxl:altLabel :no_water_label;
27
+ skos:broader :water.
28
+
29
+ :new_water_label a skosxl:Label;
30
+ skosxl:literalForm "new water"@en.
31
+ :new_water a skos:Concept;
32
+ skosxl:prefLabel :new_water_label;
33
+ skos:broader :water.
@@ -0,0 +1,167 @@
1
+ # encoding: UTF-8
2
+
3
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../test_helper')
4
+
5
+ class SimilarTermsControllerTest < ActionController::TestCase
6
+
7
+ setup do
8
+ load_test_data
9
+ end
10
+
11
+ test "routing" do
12
+ get :create, params: {
13
+ lang: 'en',
14
+ format: 'ttl'
15
+ }
16
+ assert_response 400
17
+
18
+ get :create, params: {
19
+ lang: 'en',
20
+ format: 'ttl',
21
+ terms: 'foo'
22
+ }
23
+ assert_response 200
24
+ assert !@response.body.include?("skosxl:altLabel")
25
+ end
26
+
27
+ test "single RDF representation" do
28
+ get :create, params: {
29
+ lang: 'en',
30
+ format: 'ttl',
31
+ terms: 'forest'
32
+ }
33
+ assert_response :success
34
+ assert @response.body.include?(<<-EOS)
35
+ @prefix skos: <http://www.w3.org/2004/02/skos/core#>.
36
+ EOS
37
+ assert @response.body.include?(<<-EOS)
38
+ @prefix skosxl: <http://www.w3.org/2008/05/skos-xl#>.
39
+ EOS
40
+ assert @response.body.include?(<<-EOS)
41
+ @prefix query: <http://test.host/en/similar.ttl?terms=forest#>.
42
+ EOS
43
+ assert @response.body.include?(<<-EOS.strip)
44
+ query:top skos:altLabel "forest"@en;
45
+ skos:altLabel "woods"@en.
46
+ EOS
47
+ end
48
+
49
+ test "multipe RDF representations" do
50
+ get :create, params: {
51
+ lang: 'en',
52
+ format: 'ttl',
53
+ terms: 'forest,automobile'
54
+ }
55
+ assert_response :success
56
+ assert @response.body.include?(<<-EOS)
57
+ @prefix skos: <http://www.w3.org/2004/02/skos/core#>.
58
+ EOS
59
+ assert @response.body.include?(<<-EOS)
60
+ @prefix skosxl: <http://www.w3.org/2008/05/skos-xl#>.
61
+ EOS
62
+ assert @response.body.include?(<<-EOS)
63
+ @prefix query: <http://test.host/en/similar.ttl?terms=forest%2Cautomobile#>.
64
+ EOS
65
+ assert @response.body.include?(<<-EOS.strip)
66
+ query:top skos:altLabel "automobile"@en;
67
+ skos:altLabel "car"@en;
68
+ skos:altLabel "forest"@en;
69
+ skos:altLabel "woods"@en.
70
+ EOS
71
+ end
72
+
73
+ test "XML representation without results" do
74
+ get :create, params: {
75
+ lang: 'en',
76
+ format: 'xml',
77
+ terms: 'foo'
78
+ }
79
+ assert_response 200
80
+ assert @response.body.starts_with?(<<-EOS.strip)
81
+ <?xml version="1.0" encoding="UTF-8"?>
82
+ <OneBoxResults xmlns:xlink="http://www.w3.org/1999/xlink">
83
+ <resultCode>success</resultCode>
84
+ <totalResults>0</totalResults>
85
+ <urlText>Similar Terms</urlText>
86
+ <urlLink>http://test.host/en/similar.xml?terms=foo#</urlLink>
87
+ EOS
88
+ assert !@response.body.include?("<MODULE_RESULT>")
89
+ end
90
+
91
+ test "XML representation with results" do
92
+ get :create, params: {
93
+ lang: 'en',
94
+ format: 'xml',
95
+ terms: 'forest'
96
+ }
97
+ assert_response 200
98
+ assert @response.body.include?("<totalResults>2</totalResults>")
99
+ assert @response.body.include?(<<-EOS.strip)
100
+ <MODULE_RESULT>
101
+ <title>similar terms for 'forest'</title>
102
+ EOS
103
+ assert @response.body.include? '<Field name="forest">forest</Field>'
104
+ assert @response.body.include? '<Field name="woods">woods</Field>'
105
+ end
106
+
107
+ test "RDF representation with pref labels of narrower and related concepts" do
108
+ SkosImporter.new('test/concept_test.nt', 'http://localhost:3000/').run
109
+ get :create, params: {
110
+ lang: 'en',
111
+ format: 'ttl',
112
+ terms: 'water'
113
+ }
114
+ assert_response :success
115
+ assert @response.body.include?(<<-EOS.strip)
116
+ query:top skos:altLabel "new water"@en;
117
+ skos:altLabel "real water"@en;
118
+ skos:altLabel "related"@en;
119
+ skos:altLabel "used water"@en;
120
+ skos:altLabel "water"@en.
121
+ EOS
122
+ end
123
+
124
+ test "RDF representation with pref labels of narrower and related concepts - case insensitive" do
125
+ SkosImporter.new('test/concept_test.nt', 'http://localhost:3000/').run
126
+ get :create, params: {
127
+ lang: 'en',
128
+ format: 'ttl',
129
+ :terms => 'Water'
130
+ }
131
+ assert_response :success
132
+ assert @response.body.include?(<<-EOS.strip)
133
+ query:top skos:altLabel "new water"@en;
134
+ skos:altLabel "real water"@en;
135
+ skos:altLabel "related"@en;
136
+ skos:altLabel "used water"@en;
137
+ skos:altLabel "water"@en.
138
+ EOS
139
+ end
140
+
141
+ test "Compound Forms in RDF representation" do
142
+ SkosImporter.new('test/compound_forms.nt', 'http://hobbies.com/').run
143
+ get :create, params: {
144
+ lang: 'en',
145
+ format: 'ttl',
146
+ terms: 'Computer'
147
+ }
148
+ assert_response :success
149
+ assert @response.body.include?(<<-EOS.strip)
150
+ query:top skos:altLabel "Computer programming"@en.
151
+ EOS
152
+ end
153
+
154
+ test "Compound Forms in RDF representation - case insensitive" do
155
+ SkosImporter.new('test/compound_forms.nt', 'http://hobbies.com/').run
156
+ get :create, params: {
157
+ lang: 'en',
158
+ format: 'ttl',
159
+ terms: 'computer'
160
+ }
161
+ assert_response :success
162
+ assert @response.body.include?(<<-EOS.strip)
163
+ query:top skos:altLabel "Computer programming"@en.
164
+ EOS
165
+ end
166
+
167
+ end
@@ -0,0 +1,42 @@
1
+ # encoding: UTF-8
2
+
3
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../test_helper')
4
+
5
+ class EntityResolutionTest < ActiveSupport::TestCase
6
+
7
+ setup do
8
+ load_test_data
9
+ end
10
+
11
+ test "concept resolution" do
12
+ concepts = Services::SimilarTermsService.terms_to_concepts("en", "forest")
13
+ assert_equal 1, concepts.length
14
+ assert_equal Iqvoc::Concept.base_class, concepts[0].class
15
+
16
+ concepts = Services::SimilarTermsService.terms_to_concepts("de", "forest")
17
+ assert_equal 0, concepts.count
18
+
19
+ concepts = Services::SimilarTermsService.terms_to_concepts("en", "foo")
20
+ assert_equal 0, concepts.count
21
+ end
22
+
23
+ test "label resolution" do
24
+ labels = Services::SimilarTermsService.terms_to_labels("en", "forest")
25
+ # assert_equal ActiveRecord::Relation, labels.class
26
+ labels = labels.all
27
+
28
+ assert_equal 1, labels.length
29
+ assert_equal Iqvoc::XLLabel.base_class, labels[0].class
30
+ assert_equal "forest", labels[0].value
31
+ assert_equal "en", labels[0].language
32
+
33
+ labels = Services::SimilarTermsService.terms_to_labels("de", "forest")
34
+ assert_equal 0, labels.count
35
+
36
+ labels = Services::SimilarTermsService.terms_to_labels("en", "foo")
37
+ assert_equal 0, labels.count
38
+
39
+ # TODO: test XLLabel and Inflectional variants
40
+ end
41
+
42
+ end
@@ -0,0 +1,105 @@
1
+ # encoding: UTF-8
2
+
3
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../test_helper')
4
+
5
+ class ResultsTest < ActiveSupport::TestCase
6
+
7
+ setup do
8
+ load_test_data
9
+ SkosImporter.new('test/concept_test.nt', 'http://localhost:3000/').run
10
+ end
11
+
12
+ test "ranked results" do
13
+ results = Services::SimilarTermsService.ranked("en", {}, "forest")
14
+ assert_equal 2, results.length
15
+ assert_equal Iqvoc::XLLabel.base_class, results[0][0].class
16
+ assert_equal "forest", results[0][0].value
17
+ assert_equal "forest", results[0][1].origin
18
+ assert_equal "woods", results[1][0].value
19
+ assert_equal "forest", results[1][1].origin
20
+
21
+ results = Services::SimilarTermsService.ranked("en", {}, "woods", "car")
22
+ assert_equal 4, results.length
23
+ assert_equal "forest", results[0][0].value
24
+ assert_equal "forest", results[0][1].origin
25
+ assert_equal "car", results[1][0].value
26
+ assert_equal "car", results[1][1].origin
27
+ assert_equal "woods", results[2][0].value
28
+ assert_equal "forest", results[2][1].origin
29
+ assert_equal "automobile", results[3][0].value
30
+ assert_equal "car", results[3][1].origin
31
+ assert_equal results[0].length, results[0].uniq.length
32
+ end
33
+
34
+ test "weighted results" do
35
+ results = Services::SimilarTermsService.weighted("en", {}, "forest")
36
+ assert_equal 2, results.keys.length
37
+ expected = { "forest" => 5, "woods" => 2 }
38
+ results.each do |label, data|
39
+ assert_equal Iqvoc::XLLabel.base_class, label.class
40
+ assert_equal 2, data.length
41
+ assert_equal expected[label.value], data[0]
42
+ assert_equal Iqvoc::Concept.base_class, data[1].class
43
+ end
44
+ end
45
+
46
+ #TODO: add a related concept relation and also test it
47
+ test "inclusion of pref labels of narrower and related concepts" do
48
+ results = Services::SimilarTermsService.weighted("en", {}, "water")
49
+ assert_equal 5, results.length
50
+ assert_equal "water", results.keys.first.value
51
+ assert_equal 5, results[results.keys.first][0]
52
+ assert_equal "real water", results.keys.second.value
53
+ assert_equal 2, results[results.keys.second][0]
54
+ assert_equal "related", results.keys.third.value
55
+ assert_equal 1, results[results.keys.third][0]
56
+ assert_equal "used water", results.keys.fourth.value
57
+ assert_equal 1, results[results.keys.fourth][0]
58
+ assert_equal "new water", results.keys.fifth.value
59
+ assert_equal 1, results[results.keys.fifth][0]
60
+ end
61
+
62
+ test "inclusion of pref labels of narrower and related concepts - case insensitive" do
63
+ results = Services::SimilarTermsService.weighted("en", {}, "Water")
64
+ assert_equal 5, results.length
65
+ assert_equal "water", results.keys.first.value
66
+ assert_equal 5, results[results.keys.first][0]
67
+ assert_equal "real water", results.keys.second.value
68
+ assert_equal 2, results[results.keys.second][0]
69
+ assert_equal "related", results.keys.third.value
70
+ assert_equal 1, results[results.keys.third][0]
71
+ assert_equal "used water", results.keys.fourth.value
72
+ assert_equal 1, results[results.keys.fourth][0]
73
+ assert_equal "new water", results.keys.fifth.value
74
+ assert_equal 1, results[results.keys.fifth][0]
75
+ end
76
+
77
+ test "no results" do
78
+ results = Services::SimilarTermsService.weighted("de", {}, "water")
79
+ assert_equal 0, results.length
80
+ end
81
+
82
+ test "compound returns - case insensitive" do
83
+ SkosImporter.new('test/compound_forms.nt', 'http://hobbies.com/').run
84
+ results = Services::SimilarTermsService.weighted("de", {}, "computer")
85
+ assert_equal 1, results.length
86
+ assert_equal "Computer programming", results.keys.first.value
87
+ assert_equal 1, results[results.keys.first][0]
88
+ end
89
+
90
+ test "compound returns" do
91
+ SkosImporter.new('test/compound_forms.nt', 'http://hobbies.com/').run
92
+ results = Services::SimilarTermsService.weighted("de", {}, "Computer")
93
+ assert_equal 1, results.length
94
+ assert_equal "Computer programming", results.keys.first.value
95
+ assert_equal 1, results[results.keys.first][0]
96
+ end
97
+
98
+ test "nothing unpublished" do
99
+ concept = Iqvoc::XLLabel.base_class.where(value: "forest").first.concepts.first
100
+ concept.update(published_at: nil)
101
+ results = Services::SimilarTermsService.weighted("en", {}, "forest")
102
+ assert_equal 0, results.length
103
+ end
104
+
105
+ end
@@ -0,0 +1,14 @@
1
+ <http://localhost:3000/forest_label> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos-xl#Label> .
2
+ <http://localhost:3000/forest_label> <http://www.w3.org/2008/05/skos-xl#literalForm> "forest"@en .
3
+ <http://localhost:3000/woods_label> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos-xl#Label> .
4
+ <http://localhost:3000/woods_label> <http://www.w3.org/2008/05/skos-xl#literalForm> "woods"@en .
5
+ <http://localhost:3000/forest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2004/02/skos/core#Concept> .
6
+ <http://localhost:3000/forest> <http://www.w3.org/2008/05/skos-xl#prefLabel> <http://localhost:3000/forest_label> .
7
+ <http://localhost:3000/forest> <http://www.w3.org/2008/05/skos-xl#altLabel> <http://localhost:3000/woods_label> .
8
+ <http://localhost:3000/car_label> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos-xl#Label> .
9
+ <http://localhost:3000/car_label> <http://www.w3.org/2008/05/skos-xl#literalForm> "car"@en .
10
+ <http://localhost:3000/auto_label> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2008/05/skos-xl#Label> .
11
+ <http://localhost:3000/auto_label> <http://www.w3.org/2008/05/skos-xl#literalForm> "automobile"@en .
12
+ <http://localhost:3000/car> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2004/02/skos/core#Concept> .
13
+ <http://localhost:3000/car> <http://www.w3.org/2008/05/skos-xl#prefLabel> <http://localhost:3000/car_label> .
14
+ <http://localhost:3000/car> <http://www.w3.org/2008/05/skos-xl#altLabel> <http://localhost:3000/auto_label> .
@@ -0,0 +1,19 @@
1
+ @prefix : <http://localhost:3000/>.
2
+ @prefix skos: <http://www.w3.org/2004/02/skos/core#>.
3
+ @prefix skosxl: <http://www.w3.org/2008/05/skos-xl#>.
4
+
5
+ :forest_label a skosxl:Label;
6
+ skosxl:literalForm "forest"@en.
7
+ :woods_label a skosxl:Label;
8
+ skosxl:literalForm "woods"@en.
9
+ :forest a skos:Concept;
10
+ skosxl:prefLabel :forest_label;
11
+ skosxl:altLabel :woods_label.
12
+
13
+ :car_label a skosxl:Label;
14
+ skosxl:literalForm "car"@en.
15
+ :auto_label a skosxl:Label;
16
+ skosxl:literalForm "automobile"@en.
17
+ :car a skos:Concept;
18
+ skosxl:prefLabel :car_label;
19
+ skosxl:altLabel :auto_label.
data/test/test_helper.rb CHANGED
@@ -1,3 +1,7 @@
1
1
  ENV["RAILS_ENV"] = "test"
2
2
  require File.expand_path('../../config/environment', __FILE__)
3
3
  require 'rails/test_help'
4
+
5
+ def load_test_data
6
+ SkosImporter.new('test/similar_terms.nt', 'http://localhost:3000/').run
7
+ end
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iqvoc_similar_terms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 2.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frederik Dohr
8
8
  - Robert Glaser
9
9
  - Till Schulte-Coerne
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-05-02 00:00:00.000000000 Z
13
+ date: 2024-02-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: iqvoc
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ~>
19
+ - - "~>"
20
20
  - !ruby/object:Gem::Version
21
- version: 4.1.0
21
+ version: 4.14.4
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
- - - ~>
26
+ - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: 4.1.0
28
+ version: 4.14.4
29
29
  description: ''
30
30
  email:
31
31
  - robert.glaser@innoq.com
@@ -33,68 +33,101 @@ executables: []
33
33
  extensions: []
34
34
  extra_rdoc_files: []
35
35
  files:
36
- - .gitignore
37
- - .travis.yml
36
+ - ".github/workflows/ci.yml"
37
+ - ".gitignore"
38
38
  - Gemfile
39
39
  - Gemfile.lock
40
40
  - README.md
41
41
  - Rakefile
42
+ - app/assets/javascripts/manifest.js
43
+ - app/assets/stylesheets/manifest.scss
42
44
  - app/controllers/similar_terms_controller.rb
45
+ - app/models/services/similar_terms_service.rb
46
+ - app/views/similar_terms/_form.html.erb
47
+ - app/views/similar_terms/new.html.erb
43
48
  - app/views/similar_terms/show.html.erb
44
49
  - app/views/similar_terms/show.iqrdf
50
+ - app/views/similar_terms/show.xml.builder
51
+ - bin/bundle
52
+ - bin/rails
53
+ - bin/rake
54
+ - bin/setup
55
+ - bin/update
56
+ - bin/yarn
45
57
  - config.ru
46
58
  - config/application.rb
47
59
  - config/boot.rb
60
+ - config/cable.yml
48
61
  - config/database.yml.mysql
62
+ - config/database.yml.postgresql
49
63
  - config/database.yml.sqlite
50
64
  - config/engine.rb
51
65
  - config/environment.rb
52
66
  - config/environments/development.rb
53
67
  - config/environments/production.rb
54
68
  - config/environments/test.rb
69
+ - config/initializers/apipie.rb
70
+ - config/initializers/content_security_policy.rb
71
+ - config/initializers/filter_parameter_logging.rb
72
+ - config/initializers/inflections.rb
55
73
  - config/initializers/iqvoc.rb
56
- - config/initializers/secret_token.rb.template
74
+ - config/initializers/new_framework_defaults_6_1.rb
75
+ - config/initializers/permissions_policy.rb
57
76
  - config/initializers/session_store.rb
58
- - config/initializers/wrap_parameters.rb
77
+ - config/locales/de.yml
78
+ - config/locales/en.yml
59
79
  - config/routes.rb
80
+ - config/secrets.yml
81
+ - config/storage.yml
60
82
  - db/.gitkeep
83
+ - db/migrate/.gitkeep
84
+ - faucet.config.js
61
85
  - iqvoc_similar_terms.gemspec
62
86
  - lib/iqvoc/similar_terms.rb
63
87
  - lib/iqvoc/similar_terms/version.rb
64
88
  - lib/iqvoc_similar_terms.rb
89
+ - package-lock.json
90
+ - package.json
65
91
  - public/.gitkeep
66
- - script/ci/travis-before-build
67
- - script/ci/travis-build
68
92
  - script/rails
69
- - test/functional/api_test.rb
93
+ - test/compound_forms.nt
94
+ - test/concept_test.nt
95
+ - test/concept_test.ttl
96
+ - test/controllers/similar_terms_controller_test.rb
97
+ - test/models/entity_resolution_test.rb
98
+ - test/models/results_test.rb
99
+ - test/similar_terms.nt
100
+ - test/similar_terms.ttl
70
101
  - test/test_helper.rb
71
- - test/unit/entity_resolution_test.rb
72
- - test/unit/results_test.rb
73
102
  homepage: ''
74
103
  licenses: []
75
104
  metadata: {}
76
- post_install_message:
105
+ post_install_message:
77
106
  rdoc_options: []
78
107
  require_paths:
79
108
  - lib
80
109
  required_ruby_version: !ruby/object:Gem::Requirement
81
110
  requirements:
82
- - - '>='
111
+ - - ">="
83
112
  - !ruby/object:Gem::Version
84
113
  version: '0'
85
114
  required_rubygems_version: !ruby/object:Gem::Requirement
86
115
  requirements:
87
- - - '>='
116
+ - - ">="
88
117
  - !ruby/object:Gem::Version
89
118
  version: '0'
90
119
  requirements: []
91
- rubyforge_project: iqvoc_similar_terms
92
- rubygems_version: 2.0.0
93
- signing_key:
120
+ rubygems_version: 3.4.10
121
+ signing_key:
94
122
  specification_version: 4
95
123
  summary: ''
96
124
  test_files:
97
- - test/functional/api_test.rb
125
+ - test/compound_forms.nt
126
+ - test/concept_test.nt
127
+ - test/concept_test.ttl
128
+ - test/controllers/similar_terms_controller_test.rb
129
+ - test/models/entity_resolution_test.rb
130
+ - test/models/results_test.rb
131
+ - test/similar_terms.nt
132
+ - test/similar_terms.ttl
98
133
  - test/test_helper.rb
99
- - test/unit/entity_resolution_test.rb
100
- - test/unit/results_test.rb
data/.travis.yml DELETED
@@ -1,18 +0,0 @@
1
- rvm:
2
- - 1.9.3
3
- - 2.0.0
4
-
5
- env:
6
- - DB=sqlite
7
- - DB=mysql
8
-
9
- script: "./script/ci/travis-build"
10
- before_script: "./script/ci/travis-before-build"
11
-
12
- branches:
13
- only:
14
- - master
15
-
16
- notifications:
17
- recipients:
18
- - iqvoc@innoq.com