Skip to content

Commit eb9ad1e

Browse files
author
webdev778
committed
Authority JSON output for Interscript.org
1 parent 1ad269b commit eb9ad1e

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

.github/workflows/assets.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,25 @@ jobs:
4141
file_glob: true
4242
tag: ${{ github.ref }}
4343
overwrite: true
44+
- name: Generate authority jsons
45+
run: pushd ruby; bundle exec rake generate_authority_json; popd
46+
- name: Archive json files from the previous step
47+
uses: thedoctor0/zip-release@master
48+
with:
49+
filename: 'auth_json.zip'
50+
path: ./auth_json/*.json
51+
directory: ./ruby/
52+
exclusions: '*.git*'
53+
type: zip
54+
- name: Upload artifacts
55+
id: upload_auth_json
56+
uses: svenstaro/upload-release-action@2.2.1
57+
with:
58+
repo_token: ${{ secrets.GITHUB_TOKEN }}
59+
file: ruby/auth_json.zip
60+
file_glob: true
61+
tag: ${{ github.ref }}
62+
overwrite: true
4463
- name: Generate metadata
4564
run: pushd ruby; bundle exec rake generate_metadata_json; popd
4665
- name: Archive metadata from the previous step

ruby/Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@ end
3232

3333
gem 'pry'
3434

35+
gem 'iso-639-data'
36+
3537
gem 'simplecov', require: false, group: :test

ruby/Rakefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,35 @@ task :generate_visualization_json do
121121
end
122122
end
123123

124+
task :generate_authority_json do
125+
require "interscript"
126+
require "json"
127+
require "iso-639-data"
128+
129+
FileUtils.rm_rf(dir = __dir__+"/auth_json/")
130+
FileUtils.mkdir_p(dir)
131+
132+
%w[iso icao din].each do |auth|
133+
out = Interscript.maps.select do |map_name|
134+
/\A#{auth}-/.match? map_name
135+
end.map do |map_name|
136+
map = Interscript.parse(map_name)
137+
tests = map.tests&.data&.first(2)&.transpose || []
138+
lang = map.metadata.data[:language].split(':').last
139+
140+
{
141+
lang: (Iso639Data.iso_639_2[lang] || Iso639Data.iso_639_3[lang])['eng'],
142+
isoName: map.metadata.data[:name],
143+
systemName: map_name,
144+
samples: tests[0] || [],
145+
english: tests[1] || [],
146+
result: []
147+
}
148+
end
149+
150+
json = JSON.pretty_generate(out)
151+
File.write(dir+auth+".json", json)
152+
end
153+
end
154+
124155
task :default => :spec

0 commit comments

Comments
 (0)