osgeo-termbase 0.0.1
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 +7 -0
- data/.gitignore +2 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +94 -0
- data/README.adoc +86 -0
- data/Rakefile +6 -0
- data/exe/osgeo-termbase-csv2yaml +56 -0
- data/exe/osgeo-termbase-fetchcsv +27 -0
- data/lib/osgeo/termbase.rb +11 -0
- data/lib/osgeo/termbase/concept.rb +58 -0
- data/lib/osgeo/termbase/concept_collection.rb +32 -0
- data/lib/osgeo/termbase/csv.rb +45 -0
- data/lib/osgeo/termbase/term.rb +275 -0
- data/lib/osgeo/termbase/version.rb +5 -0
- data/osgeo-termbase.gemspec +32 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: db12b312efde02595ac7f15528c801a3a8214b81ecbabb182f9703fa124f7499
|
4
|
+
data.tar.gz: e8796a7029e7a1dd935e430a1b458361ed645c2ebbb340ae8cbe9cf2febcf9c9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7cb3dfb165e1c8d9480a2ac478046a3be51f9d55165f3502288df3b7d7b716e5bf192b13a9ce6b280323eed5467efcd98fad656eb3a65ad7497c418670b5ec67
|
7
|
+
data.tar.gz: ce2b45928f43c767fc0a895f8aeabf8e73a5d9b356ea183ee065183da208801d5d81bbd6bbfdd13814397ba2f77ad45a7afbac99f719ea39dd6a9aeb37b179e0
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
osgeo-termbase (0.1.12)
|
5
|
+
relaton (~> 0.5)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.7.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
|
+
cnccs (0.1.5)
|
13
|
+
debase (0.2.4.1)
|
14
|
+
debase-ruby_core_source (>= 0.10.2)
|
15
|
+
debase-ruby_core_source (0.10.6)
|
16
|
+
diff-lcs (1.3)
|
17
|
+
faraday (0.17.0)
|
18
|
+
multipart-post (>= 1.2, < 3)
|
19
|
+
gb-agencies (0.0.6)
|
20
|
+
isoics (0.1.8)
|
21
|
+
mini_portile2 (2.4.0)
|
22
|
+
multipart-post (2.1.1)
|
23
|
+
nokogiri (1.10.4)
|
24
|
+
mini_portile2 (~> 2.4.0)
|
25
|
+
public_suffix (4.0.1)
|
26
|
+
rake (10.5.0)
|
27
|
+
relaton (0.5.9)
|
28
|
+
relaton-gb (~> 0.6.0)
|
29
|
+
relaton-iec (~> 0.4.0)
|
30
|
+
relaton-ietf (~> 0.6.0)
|
31
|
+
relaton-iso (~> 0.6.0)
|
32
|
+
relaton-itu (~> 0.3.0)
|
33
|
+
relaton-nist (~> 0.3.0)
|
34
|
+
relaton-ogc (~> 0.1.0)
|
35
|
+
relaton-bib (0.3.11)
|
36
|
+
addressable
|
37
|
+
nokogiri
|
38
|
+
relaton-gb (0.6.6)
|
39
|
+
cnccs (~> 0.1.1)
|
40
|
+
gb-agencies (~> 0.0.1)
|
41
|
+
relaton-iso-bib (~> 0.3.0)
|
42
|
+
relaton-iec (0.4.9)
|
43
|
+
addressable
|
44
|
+
relaton-iso-bib (~> 0.3.0)
|
45
|
+
relaton-ietf (0.6.7)
|
46
|
+
relaton-bib (~> 0.3.0)
|
47
|
+
relaton-iso (0.6.8)
|
48
|
+
relaton-iec (~> 0.4.0)
|
49
|
+
relaton-iso-bib (~> 0.3.0)
|
50
|
+
relaton-iso-bib (0.3.11)
|
51
|
+
isoics (~> 0.1.6)
|
52
|
+
relaton-bib (~> 0.3.0)
|
53
|
+
ruby_deep_clone (~> 0.8.0)
|
54
|
+
relaton-itu (0.3.6)
|
55
|
+
relaton-iso-bib (~> 0.3.0)
|
56
|
+
relaton-nist (0.3.7)
|
57
|
+
relaton-bib (~> 0.3.0)
|
58
|
+
rubyzip
|
59
|
+
relaton-ogc (0.1.3)
|
60
|
+
faraday
|
61
|
+
relaton-iso-bib (~> 0.3.0)
|
62
|
+
rspec (3.9.0)
|
63
|
+
rspec-core (~> 3.9.0)
|
64
|
+
rspec-expectations (~> 3.9.0)
|
65
|
+
rspec-mocks (~> 3.9.0)
|
66
|
+
rspec-core (3.9.0)
|
67
|
+
rspec-support (~> 3.9.0)
|
68
|
+
rspec-expectations (3.9.0)
|
69
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
70
|
+
rspec-support (~> 3.9.0)
|
71
|
+
rspec-mocks (3.9.0)
|
72
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
73
|
+
rspec-support (~> 3.9.0)
|
74
|
+
rspec-support (3.9.0)
|
75
|
+
ruby-debug-ide (0.7.0)
|
76
|
+
rake (>= 0.8.1)
|
77
|
+
ruby_deep_clone (0.8.0)
|
78
|
+
rubyzip (2.0.0)
|
79
|
+
tsv (1.0.0)
|
80
|
+
|
81
|
+
PLATFORMS
|
82
|
+
ruby
|
83
|
+
|
84
|
+
DEPENDENCIES
|
85
|
+
bundler (~> 2.0.1)
|
86
|
+
debase
|
87
|
+
osgeo-termbase!
|
88
|
+
rake (~> 10.0)
|
89
|
+
rspec (~> 3.0)
|
90
|
+
ruby-debug-ide
|
91
|
+
tsv
|
92
|
+
|
93
|
+
BUNDLED WITH
|
94
|
+
2.0.2
|
data/README.adoc
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
= OSGeo Termbase programs
|
2
|
+
|
3
|
+
== Purpose
|
4
|
+
|
5
|
+
This gem is used for the creation and deployment of OSGeo Geolexica,
|
6
|
+
the OSGeo Glossary,
|
7
|
+
located at https://osgeo.geolexica.org.
|
8
|
+
|
9
|
+
The repository for the site is located at:
|
10
|
+
|
11
|
+
* https://github.com/geolexica/osgeo.geolexica.org
|
12
|
+
|
13
|
+
|
14
|
+
== Install
|
15
|
+
|
16
|
+
Add this line to your Gemfile:
|
17
|
+
|
18
|
+
[source,ruby]
|
19
|
+
----
|
20
|
+
gem 'osgeo-termbase'
|
21
|
+
----
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
[source,sh]
|
26
|
+
----
|
27
|
+
$ bundle
|
28
|
+
----
|
29
|
+
|
30
|
+
Or install it yourself as:
|
31
|
+
|
32
|
+
[source,sh]
|
33
|
+
----
|
34
|
+
$ gem install osgeo-termbase
|
35
|
+
----
|
36
|
+
|
37
|
+
|
38
|
+
== Usage
|
39
|
+
|
40
|
+
The gem comes with the following executable:
|
41
|
+
|
42
|
+
* `osgeo-termbase-csv2yaml`: used to extract terms from the official
|
43
|
+
OSGeo glossary table, into ConceptYAML and TermYAML files.
|
44
|
+
|
45
|
+
* `osgeo-termbase-fetchcsv`: used to fetch the latest OSGeo glossary
|
46
|
+
in CSV format.
|
47
|
+
|
48
|
+
|
49
|
+
=== Using `osgeo-termbase-csv2yaml`
|
50
|
+
|
51
|
+
Run the following command:
|
52
|
+
|
53
|
+
[source,sh]
|
54
|
+
----
|
55
|
+
$ osgeo-termbase-csv2yaml [termbase.csv]
|
56
|
+
----
|
57
|
+
|
58
|
+
Where,
|
59
|
+
|
60
|
+
* the ConceptCollection YAML will be created at `[termbase.yaml]` at
|
61
|
+
the current working directory;
|
62
|
+
|
63
|
+
* ConceptYAML files for each concept (each concept identified by a unique "`Term-ID`")
|
64
|
+
are created under the `concepts/` directory (based on the current working directory).
|
65
|
+
i.e. `concepts/concept-338.yaml`.
|
66
|
+
|
67
|
+
|
68
|
+
=== Using `osgeo-termbase-fetchcsv`
|
69
|
+
|
70
|
+
Run the following command:
|
71
|
+
|
72
|
+
[source,sh]
|
73
|
+
----
|
74
|
+
$ osgeo-termbase-fetchcsv [termbase.csv]
|
75
|
+
----
|
76
|
+
|
77
|
+
Where,
|
78
|
+
|
79
|
+
* the OSGeo glossary CSV file will be created at `[termbase.yaml]` in
|
80
|
+
the current working directory.
|
81
|
+
|
82
|
+
|
83
|
+
== Credits
|
84
|
+
|
85
|
+
This program is created and maintained by Ribose / Geolexica
|
86
|
+
for the OSGeo Lexicon Committee (OSGeo LC).
|
data/Rakefile
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'pp'
|
4
|
+
require 'pathname'
|
5
|
+
require 'fileutils'
|
6
|
+
require_relative '../lib/osgeo/termbase.rb'
|
7
|
+
# require 'pry'
|
8
|
+
|
9
|
+
filepath = ARGV[0]
|
10
|
+
#'./osgeo-termbase.xlsx'
|
11
|
+
|
12
|
+
if filepath.nil?
|
13
|
+
puts 'Error: no filepath given as first argument.'
|
14
|
+
exit 1
|
15
|
+
end
|
16
|
+
|
17
|
+
if Pathname.new(filepath).extname != ".csv"
|
18
|
+
puts 'Error: filepath given must have extension .csv.'
|
19
|
+
exit 1
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
table = Osgeo::Termbase::Csv.new(filepath)
|
24
|
+
|
25
|
+
# registries = {
|
26
|
+
# "eng" => {
|
27
|
+
# metadata: {},
|
28
|
+
# terms: table.concept_collection
|
29
|
+
# }
|
30
|
+
# }
|
31
|
+
|
32
|
+
output_dir = Dir.pwd
|
33
|
+
|
34
|
+
# metadata = {
|
35
|
+
# 'header' => workbook.glossary_info.metadata_section.to_hash["metadata"]
|
36
|
+
# }
|
37
|
+
# # Write registry metadata
|
38
|
+
# metadata['languages'] = registries.inject({}) do |acc, (lang, data)|
|
39
|
+
# acc.merge({lang => data[:metadata]})
|
40
|
+
# end
|
41
|
+
|
42
|
+
# File.open(File.join(output_dir, Pathname.new(filepath).basename.sub_ext(".meta.yaml")),"w") do |file|
|
43
|
+
# file.write(metadata.to_yaml)
|
44
|
+
# end
|
45
|
+
|
46
|
+
collection = table.concept_collection
|
47
|
+
|
48
|
+
collection.to_file(File.join(output_dir, Pathname.new(filepath).basename.sub_ext(".yaml")))
|
49
|
+
|
50
|
+
collection_output_dir = File.join(output_dir, "concepts")
|
51
|
+
|
52
|
+
FileUtils.mkdir_p(collection_output_dir)
|
53
|
+
|
54
|
+
collection.keys.each do |id|
|
55
|
+
collection[id].to_file(File.join(collection_output_dir, "concept-#{id}.yaml"))
|
56
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
require 'uri'
|
5
|
+
|
6
|
+
filepath = ARGV[0]
|
7
|
+
#'./osgeo-termbase.xlsx'
|
8
|
+
|
9
|
+
if filepath.nil?
|
10
|
+
puts 'Error: no filepath given as first argument.'
|
11
|
+
exit 1
|
12
|
+
end
|
13
|
+
|
14
|
+
if Pathname.new(filepath).extname != ".csv"
|
15
|
+
puts 'Error: filepath given must have extension .csv.'
|
16
|
+
exit 1
|
17
|
+
end
|
18
|
+
|
19
|
+
uri = URI.parse("https://docs.google.com/spreadsheets/d/e/2PACX-1vRiH36W8s6WfxFCdb_FfHSqMebxRXgq-bIbTgzYyRGzELHvLrhESiasPO6hqEWLsELlXtRcXhxcSIbQ/pub?gid=222410614&single=true&output=csv")
|
20
|
+
response = Net::HTTP.get_response(uri)
|
21
|
+
|
22
|
+
# response.code
|
23
|
+
# response.body
|
24
|
+
|
25
|
+
File.open(filepath, "w") do |f|
|
26
|
+
f.puts response.body
|
27
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require_relative "term"
|
2
|
+
|
3
|
+
module Osgeo::Termbase
|
4
|
+
|
5
|
+
class Concept < Hash
|
6
|
+
attr_accessor :id
|
7
|
+
attr_accessor :terms
|
8
|
+
DEFAULT_LANGUAGE = "eng"
|
9
|
+
|
10
|
+
def initialize(options={})
|
11
|
+
terms = options.delete(:terms) || []
|
12
|
+
terms.each do |term|
|
13
|
+
add_term(term)
|
14
|
+
end
|
15
|
+
|
16
|
+
options.each_pair do |k,v|
|
17
|
+
self.send("#{k}=", v)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# The concept id should ALWAYS be an integer.
|
22
|
+
# https://github.com/riboseinc/osgeo-termbase/issues/1
|
23
|
+
def id=(newid)
|
24
|
+
@id = Integer(newid)
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_term(term)
|
28
|
+
self[term.language_code] = term
|
29
|
+
end
|
30
|
+
|
31
|
+
def default_term
|
32
|
+
if self[DEFAULT_LANGUAGE]
|
33
|
+
self[DEFAULT_LANGUAGE]
|
34
|
+
else
|
35
|
+
puts "[osgeo-termbase] term (lang: #{keys.first}, ID: #{id}) is missing a corresponding English term, probably needs updating."
|
36
|
+
self[keys.first]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_hash
|
41
|
+
default_hash = {
|
42
|
+
"term" => default_term.term,
|
43
|
+
"termid" => id
|
44
|
+
}
|
45
|
+
|
46
|
+
self.inject(default_hash) do |acc, (lang, term)|
|
47
|
+
acc.merge!(lang => term.to_hash)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_file(filename)
|
52
|
+
File.open(filename,"w") do |file|
|
53
|
+
file.write(to_hash.to_yaml)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative "concept"
|
2
|
+
|
3
|
+
module Osgeo::Termbase
|
4
|
+
|
5
|
+
class ConceptCollection < Hash
|
6
|
+
|
7
|
+
def add_term(term)
|
8
|
+
if self[term.id]
|
9
|
+
self[term.id].add_term(term)
|
10
|
+
else
|
11
|
+
self[term.id] = Concept.new(
|
12
|
+
id: term.id,
|
13
|
+
terms: [term]
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def to_hash
|
19
|
+
self.inject({}) do |acc, (id, concept)|
|
20
|
+
acc.merge!(id => concept.to_hash)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_file(filename)
|
25
|
+
File.open(filename,"w") do |file|
|
26
|
+
file.write(to_hash.to_yaml)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
require "csv"
|
3
|
+
require "yaml"
|
4
|
+
require "pathname"
|
5
|
+
|
6
|
+
module Osgeo::Termbase
|
7
|
+
|
8
|
+
class Csv
|
9
|
+
attr_accessor :filename
|
10
|
+
|
11
|
+
def initialize(filepath)
|
12
|
+
@filename = filepath
|
13
|
+
@languages = languages_supported
|
14
|
+
self
|
15
|
+
end
|
16
|
+
|
17
|
+
def languages_supported
|
18
|
+
"eng"
|
19
|
+
end
|
20
|
+
|
21
|
+
def concept_collection
|
22
|
+
collection = ConceptCollection.new
|
23
|
+
|
24
|
+
CSV.foreach(@filename).each_with_index do |row, i|
|
25
|
+
next if i < 3
|
26
|
+
term = Term.new(
|
27
|
+
id: i - 2,
|
28
|
+
term: row[0],
|
29
|
+
type: row[1],
|
30
|
+
domain: row[2],
|
31
|
+
comments: row[3] && [row[3]],
|
32
|
+
definition: row[4],
|
33
|
+
authoritative_source: row[5],
|
34
|
+
entry_status: row[6],
|
35
|
+
language_code: "eng"
|
36
|
+
)
|
37
|
+
|
38
|
+
collection.add_term(term)
|
39
|
+
end
|
40
|
+
|
41
|
+
collection
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,275 @@
|
|
1
|
+
module Osgeo::Termbase
|
2
|
+
|
3
|
+
class Term
|
4
|
+
|
5
|
+
ATTRIBS = %i(
|
6
|
+
id
|
7
|
+
term
|
8
|
+
abbrev
|
9
|
+
synonyms
|
10
|
+
alt
|
11
|
+
domain
|
12
|
+
definition
|
13
|
+
country_code
|
14
|
+
language_code
|
15
|
+
notes
|
16
|
+
examples
|
17
|
+
entry_status
|
18
|
+
type
|
19
|
+
comments
|
20
|
+
classification
|
21
|
+
review_indicator
|
22
|
+
authoritative_source
|
23
|
+
authoritative_source_similarity
|
24
|
+
lineage_source
|
25
|
+
lineage_source_similarity
|
26
|
+
date_accepted
|
27
|
+
date_amended
|
28
|
+
review_date
|
29
|
+
review_status
|
30
|
+
review_type
|
31
|
+
review_decision
|
32
|
+
review_decision_date
|
33
|
+
review_decision_event
|
34
|
+
review_decision_notes
|
35
|
+
release
|
36
|
+
)
|
37
|
+
|
38
|
+
attr_accessor *ATTRIBS
|
39
|
+
|
40
|
+
def initialize(options={})
|
41
|
+
@examples = []
|
42
|
+
@notes = []
|
43
|
+
|
44
|
+
# puts "options #{options.inspect}"
|
45
|
+
|
46
|
+
options.each_pair do |k, v|
|
47
|
+
key = k.to_s
|
48
|
+
v = v.strip if v.is_a?(String)
|
49
|
+
next unless v
|
50
|
+
case key
|
51
|
+
when /^example/
|
52
|
+
add_example(v)
|
53
|
+
when /^note/
|
54
|
+
add_note(v)
|
55
|
+
else
|
56
|
+
# puts"Key #{k}"
|
57
|
+
key = key.gsub("-", "_")
|
58
|
+
self.send("#{key}=", v)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
self
|
62
|
+
end
|
63
|
+
|
64
|
+
STRIP_PUNCTUATION = [
|
65
|
+
":",
|
66
|
+
":",
|
67
|
+
".",
|
68
|
+
"–",
|
69
|
+
"\-"
|
70
|
+
]
|
71
|
+
|
72
|
+
# WARNING
|
73
|
+
# Always put the longer Regexp match in front!
|
74
|
+
EXAMPLE_PREFIXES = {
|
75
|
+
# TODO: fix this, we should not have "EXAMPLES"
|
76
|
+
eng: ["EXAMPLES", "EXAMPLE"],
|
77
|
+
ara: "مثال",
|
78
|
+
chi: "示例",
|
79
|
+
dan: "EKSEMPEL",
|
80
|
+
dut: ["VOORBEELD", "VOORBEELDEN"],
|
81
|
+
fin: "ESIM",
|
82
|
+
fre: "Exemple",
|
83
|
+
# ger: "",
|
84
|
+
jpn: "例",
|
85
|
+
kor: "보기",
|
86
|
+
pol: "PRZYKŁAD",
|
87
|
+
may: "Contoh",
|
88
|
+
rus: "Пример",
|
89
|
+
spa: "Ejemplo",
|
90
|
+
swe: "Exempel"
|
91
|
+
}
|
92
|
+
|
93
|
+
# WARNING
|
94
|
+
# Always put the longer Regexp match in front!
|
95
|
+
NOTE_PREFIXES = {
|
96
|
+
eng: ["Note \\d to entry", "NOTE"],
|
97
|
+
ara: "ملاحظة",
|
98
|
+
chi: "注",
|
99
|
+
dan: "Note",
|
100
|
+
dut: "OPMERKING",
|
101
|
+
fin: "HUOM\\.?", # Matches "HUOM", "HUOM.", "HUOM 1." and "HUOM. 1." (numeral added by the method)
|
102
|
+
fre: "A noter",
|
103
|
+
# ger: "",
|
104
|
+
jpn: "備考",
|
105
|
+
kor: "비고",
|
106
|
+
pol: "UWAGA",
|
107
|
+
may: "catatan",
|
108
|
+
rus: "нота",
|
109
|
+
spa: "Nota",
|
110
|
+
swe: ["Anm. \\d till termpost", "Anm. \\d till terpost", "Anm."]
|
111
|
+
}
|
112
|
+
|
113
|
+
# To match Chinese and Japanese numerals
|
114
|
+
ALL_FULL_HALF_WIDTH_NUMBERS = "[0-90-9]"
|
115
|
+
|
116
|
+
def add_example(example)
|
117
|
+
c = clean_prefixed_string(example, EXAMPLE_PREFIXES)
|
118
|
+
@examples << c unless c.empty?
|
119
|
+
end
|
120
|
+
|
121
|
+
def add_note(note)
|
122
|
+
c = clean_prefixed_string(note, NOTE_PREFIXES)
|
123
|
+
@notes << c unless c.empty?
|
124
|
+
end
|
125
|
+
|
126
|
+
def clean_prefixed_string(string, criterion_map)
|
127
|
+
carry = string.strip
|
128
|
+
criterion_map.values.flatten.each do |mat|
|
129
|
+
# puts "example string: #{carry}, mat: #{mat}"
|
130
|
+
|
131
|
+
# puts "note string: #{carry}, mat: #{mat}"
|
132
|
+
# if @id == 318 and mat == "Nota" and string == "NOTA 1 Una operación tiene un nombre y una lista de parámetros."
|
133
|
+
# require "pry"
|
134
|
+
# binding.pry
|
135
|
+
# end
|
136
|
+
|
137
|
+
# Arabic notes/examples sometimes use parantheses around numbers
|
138
|
+
carry = carry.sub(
|
139
|
+
Regexp.new(
|
140
|
+
"^#{mat}\s*[#{STRIP_PUNCTUATION.join('')}]?" +
|
141
|
+
"\s*\\(?#{ALL_FULL_HALF_WIDTH_NUMBERS}*\\)?\s*"+
|
142
|
+
"[#{STRIP_PUNCTUATION.join('')}]?\s*",
|
143
|
+
Regexp::IGNORECASE
|
144
|
+
),
|
145
|
+
'')
|
146
|
+
end
|
147
|
+
|
148
|
+
carry
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
# The termid should ALWAYS be an integer.
|
153
|
+
# https://github.com/riboseinc/osgeo-termbase/issues/1
|
154
|
+
def id=(newid)
|
155
|
+
@id = Integer(newid)
|
156
|
+
end
|
157
|
+
|
158
|
+
def to_hash
|
159
|
+
ATTRIBS.inject({}) do |acc, attrib|
|
160
|
+
value = self.send(attrib)
|
161
|
+
unless value.nil?
|
162
|
+
acc.merge(attrib.to_s => value)
|
163
|
+
else
|
164
|
+
acc
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
# OSGEO SPECIFIC
|
170
|
+
# type
|
171
|
+
## Must be one of term, abbrev, soft, other, check
|
172
|
+
def type=(value)
|
173
|
+
@type = case value.to_s
|
174
|
+
when "term", "abbrev", "soft", "other", "check"
|
175
|
+
value.to_s
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
# OSGEO SPECIFIC
|
180
|
+
# domain
|
181
|
+
## Must be one of term, abbrev, soft, other, check
|
182
|
+
def domain=(value)
|
183
|
+
@domain = case value.to_s
|
184
|
+
when "concept", "org_acedemic", "org_indus", "org_intl", "org_govt"
|
185
|
+
value.to_s
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
# entry-status
|
190
|
+
## Must be one of notValid valid superseded retired
|
191
|
+
def entry_status=(value)
|
192
|
+
case value
|
193
|
+
when "有效的", "käytössä", "действующий", "válido"
|
194
|
+
value = "valid"
|
195
|
+
when "korvattu", "reemplazado"
|
196
|
+
value = "superseded"
|
197
|
+
when "информация отсутствует" # "information absent"!?
|
198
|
+
value = "retired"
|
199
|
+
when %w(notValid valid superseded retired)
|
200
|
+
# do nothing
|
201
|
+
end
|
202
|
+
@entry_status = value
|
203
|
+
end
|
204
|
+
|
205
|
+
# classification
|
206
|
+
## Must be one of the following: preferred admitted deprecated
|
207
|
+
def classification=(value)
|
208
|
+
case value
|
209
|
+
when ""
|
210
|
+
value = "admitted"
|
211
|
+
when "认可的", "допустимый", "admitido"
|
212
|
+
value = "admitted"
|
213
|
+
when "首选的", "suositettava", "suositeltava", "рекомендуемый", "preferente"
|
214
|
+
value = "preferred"
|
215
|
+
when %w(preferred admitted deprecated)
|
216
|
+
# do nothing
|
217
|
+
end
|
218
|
+
@classification = value
|
219
|
+
end
|
220
|
+
|
221
|
+
# review-indicator
|
222
|
+
## Must be one of the following <empty field> Under Review in Source Document",
|
223
|
+
def review_indicator=(value)
|
224
|
+
unless ["", "Under Review in Source Document"].include?(value)
|
225
|
+
value = ""
|
226
|
+
end
|
227
|
+
@review_indicator = value
|
228
|
+
end
|
229
|
+
|
230
|
+
# authoritative-source-similarity
|
231
|
+
# ## Must be one of the following codes: identical = 1 restyled = 2 context added = 3 generalisation = 4 specialisation = 5 unspecified = 6",
|
232
|
+
def authoritative_source_similarity=(value)
|
233
|
+
unless (1..6).include?(value)
|
234
|
+
value = 6
|
235
|
+
end
|
236
|
+
@authoritative_source_similarity = value
|
237
|
+
end
|
238
|
+
|
239
|
+
# lineage-source-similarity
|
240
|
+
# ## Must be one of the following codes: identical = 1 restyled = 2 context added = 3 generalisation = 4 specialisation = 5 unspecified = 6",
|
241
|
+
def authoritative_source_similarity=(value)
|
242
|
+
unless (1..6).include?(value)
|
243
|
+
value = 6
|
244
|
+
end
|
245
|
+
@authoritative_source_similarity
|
246
|
+
end
|
247
|
+
|
248
|
+
def review_status=(value) ## Must be one of pending tentative final
|
249
|
+
unless ["", "pending", "tentative", "final"].include?(value)
|
250
|
+
value = ""
|
251
|
+
end
|
252
|
+
@review_status = value
|
253
|
+
end
|
254
|
+
|
255
|
+
def review_type=(value) ## Must be one of supersession, retirement
|
256
|
+
unless ["", "supersession", "retirement"].include?(value)
|
257
|
+
value = ""
|
258
|
+
end
|
259
|
+
@review_type = value
|
260
|
+
end
|
261
|
+
|
262
|
+
def review_decision=(value) ## Must be one of withdrawn, accepted notAccepted
|
263
|
+
unless ["", "withdrawn", "accepted", "notAccepted"].include?(value)
|
264
|
+
value = ""
|
265
|
+
end
|
266
|
+
@review_decision = value
|
267
|
+
end
|
268
|
+
|
269
|
+
def retired?
|
270
|
+
release >= 0
|
271
|
+
end
|
272
|
+
|
273
|
+
end
|
274
|
+
|
275
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "osgeo/termbase/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "osgeo-termbase"
|
8
|
+
spec.version = Osgeo::Termbase::VERSION
|
9
|
+
spec.authors = ["Ribose"]
|
10
|
+
spec.email = ["open.source@ribose.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Build scripts for the OSGeo Termbase}
|
13
|
+
spec.description = %q{Build scripts for the OSGeo Termbase}
|
14
|
+
spec.homepage = "https://open.ribose.com"
|
15
|
+
|
16
|
+
# Specify which files should be added to the gem when it is released.
|
17
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
18
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
end
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_runtime_dependency "relaton", "~> 0.5"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 2.0.1"
|
28
|
+
spec.add_development_dependency "debase"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
31
|
+
spec.add_development_dependency "ruby-debug-ide"
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: osgeo-termbase
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ribose
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-10-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: relaton
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.0.1
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.0.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: debase
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: ruby-debug-ide
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Build scripts for the OSGeo Termbase
|
98
|
+
email:
|
99
|
+
- open.source@ribose.com
|
100
|
+
executables:
|
101
|
+
- osgeo-termbase-csv2yaml
|
102
|
+
- osgeo-termbase-fetchcsv
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- Gemfile
|
108
|
+
- Gemfile.lock
|
109
|
+
- README.adoc
|
110
|
+
- Rakefile
|
111
|
+
- exe/osgeo-termbase-csv2yaml
|
112
|
+
- exe/osgeo-termbase-fetchcsv
|
113
|
+
- lib/osgeo/termbase.rb
|
114
|
+
- lib/osgeo/termbase/concept.rb
|
115
|
+
- lib/osgeo/termbase/concept_collection.rb
|
116
|
+
- lib/osgeo/termbase/csv.rb
|
117
|
+
- lib/osgeo/termbase/term.rb
|
118
|
+
- lib/osgeo/termbase/version.rb
|
119
|
+
- osgeo-termbase.gemspec
|
120
|
+
homepage: https://open.ribose.com
|
121
|
+
licenses: []
|
122
|
+
metadata: {}
|
123
|
+
post_install_message:
|
124
|
+
rdoc_options: []
|
125
|
+
require_paths:
|
126
|
+
- lib
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
requirements: []
|
138
|
+
rubygems_version: 3.0.3
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: Build scripts for the OSGeo Termbase
|
142
|
+
test_files: []
|