@@ -13,7 +13,7 @@ class MapLogicError < StandardError; end
1313
1414 class << self
1515 def load_path
16- @load_path ||= [ '.' , *Interscript . map_locations ]
16+ @load_path ||= [ "." , *Interscript . map_locations ]
1717 end
1818
1919 def locate map_name
@@ -33,26 +33,26 @@ def parse(map_name)
3333 Interscript ::DSL . parse ( map_name )
3434 end
3535
36- def load ( system_code , maps = { } , compiler : Interscript ::Interpreter )
37- maps [ [ system_code , compiler . name ] ] ||= compiler . ( system_code )
36+ def load ( system_code , maps = { } , compiler : Interscript ::Interpreter )
37+ maps [ [ system_code , compiler . name ] ] ||= compiler . call ( system_code )
3838 end
3939
4040 # Transliterates the string.
41- def transliterate ( system_code , string , maps = { } , compiler : Interscript ::Interpreter )
41+ def transliterate ( system_code , string , maps = { } , compiler : Interscript ::Interpreter )
4242 # The current best implementation is Interpreter
43- load ( system_code , maps , compiler : compiler ) . ( string )
43+ load ( system_code , maps , compiler : compiler ) . call ( string )
4444 end
4545
4646 # Gives each possible value of the transliteration.
47- def transliterate_each ( system_code , string , maps = { } , &block )
48- load ( system_code , maps ) . ( string , each : true , &block )
47+ def transliterate_each ( system_code , string , maps = { } , &block )
48+ load ( system_code , maps ) . call ( string , each : true , &block )
4949 end
5050
51- def transliterate_file ( system_code , input_file , output_file , maps = { } , compiler : Interscript ::Interpreter )
51+ def transliterate_file ( system_code , input_file , output_file , maps = { } , compiler : Interscript ::Interpreter )
5252 input = File . read ( input_file )
5353 output = transliterate ( system_code , input , maps , compiler : compiler )
5454
55- File . open ( output_file , 'w' ) do |f |
55+ File . open ( output_file , "w" ) do |f |
5656 f . puts ( output )
5757 end
5858
@@ -67,17 +67,17 @@ def transliterate_file(system_code, input_file, output_file, maps={}, compiler:
6767 def detect ( source , destination , **kwargs )
6868 detector = Detector . new
6969 detector . set_from_kwargs ( **kwargs )
70- detector . ( source , destination )
70+ detector . call ( source , destination )
7171 end
7272
7373 def map_gems
74- @map_gems ||= Gem . find_latest_files ( ' interscript-maps.yaml' ) . map do |i |
74+ @map_gems ||= Gem . find_latest_files ( " interscript-maps.yaml" ) . map do |i |
7575 [ i , YAML . load_file ( i ) ]
7676 end . to_h
7777 end
7878
7979 def map_locations
80- @map_locations ||= map_gems . map do |i , v |
80+ @map_locations ||= map_gems . map do |i , v |
8181 paths = v [ "paths" ] . dup
8282 paths += v [ "staging" ] if ENV [ "INTERSCRIPT_STAGING" ] && v [ "staging" ]
8383
@@ -88,24 +88,24 @@ def map_locations
8888 end
8989
9090 def secryst_index_locations
91- @secryst_index_locations ||= map_gems . map do |i , v |
91+ @secryst_index_locations ||= map_gems . map do |i , v |
9292 v [ "secryst-models" ]
9393 end . compact . flatten
9494 end
9595
9696 def rababa_configs
97- @rababa_configs ||= map_gems . map do |i , v |
97+ @rababa_configs ||= map_gems . map do |i , v |
9898 v [ "rababa-configs" ]
99- end . compact . inject ( { } ) do |a , b |
99+ end . compact . inject ( { } ) do |a , b |
100100 a . merge ( b )
101101 end
102102 end
103103
104104 # This code is borrowed from Secryst and should end up in Rababa, but for now,
105105 # let's keep it here.
106106 def rababa_provision ( model_name , model_uri )
107- require ' fileutils'
108- require ' open-uri'
107+ require " fileutils"
108+ require " open-uri"
109109
110110 # We provision the environment in the following way:
111111 # First, we try the RABABA_DATA environment variable. If that's available,
@@ -129,26 +129,26 @@ def rababa_provision(model_name, model_uri)
129129 break
130130 rescue
131131 end
132-
132+
133133 raise ExternalUtilError , "Can't find a writable path for Rababa. Consider setting a RABABA_DATA environment variable" unless write_path
134134
135135 model_path = "#{ write_path } /model-#{ model_name } .onnx"
136136
137137 # Redownload every hour
138138 if File . exist? ( model_path ) && File . mtime ( model_path ) + 3600 >= Time . now
139- return model_path
139+ model_path
140140 else
141141 data = URI . open ( model_uri , encoding : "BINARY" ) . read
142142 File . binwrite ( model_path , data )
143- return model_path
143+ model_path
144144 end
145145 end
146146
147147 def map_aliases
148148 return @map_aliases if @map_aliases
149149
150150 @map_aliases = { }
151- map_gems . each do |i , v |
151+ map_gems . each do |i , v |
152152 ( v [ "aliases" ] || { } ) . each do |code , value |
153153 value . each do |al , map |
154154 @map_aliases [ al ] = map [ "alias_to" ]
@@ -172,9 +172,9 @@ def maps(basename: true, load_path: false, select: "*", libraries: false)
172172 # To be used by tests
173173 # and builders. It uses the `skip` directive in interscript-maps.yaml
174174 def exclude_maps ( maps , compiler :, platform : true )
175- map_gems . each do |i , v |
175+ map_gems . each do |i , v |
176176 [ compiler . name , ( Gem ::Platform . local . os if platform ) ] . compact . each do |name |
177- skips = v . dig ( ' skip' , name ) || [ ]
177+ skips = v . dig ( " skip" , name ) || [ ]
178178 skips . each do |skip |
179179 skip_re = /#{ Regexp . escape ( skip ) . gsub ( "\\ *" , ".*?" ) } /
180180 maps = maps . grep_v ( skip_re )
@@ -186,12 +186,12 @@ def exclude_maps(maps, compiler:, platform: true)
186186 end
187187end
188188
189- require ' interscript/stdlib'
189+ require " interscript/stdlib"
190190
191191require "interscript/compiler"
192192require "interscript/interpreter"
193193
194- require ' interscript/dsl'
195- require ' interscript/node'
194+ require " interscript/dsl"
195+ require " interscript/node"
196196
197- require ' interscript/detector'
197+ require " interscript/detector"
0 commit comments