dictionaries 0.2.177

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of dictionaries might be problematic. Click here for more details.

Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +103 -0
  3. data/bin/dictionaries +7 -0
  4. data/dictionaries.gemspec +85 -0
  5. data/doc/README.gen +86 -0
  6. data/lib/dictionaries.rb +1 -0
  7. data/lib/dictionaries/ask_english_word.rb +135 -0
  8. data/lib/dictionaries/ask_italian_word.rb +84 -0
  9. data/lib/dictionaries/class/ask_word_from_dictionary.rb +672 -0
  10. data/lib/dictionaries/class/colours.rb +55 -0
  11. data/lib/dictionaries/class/set_search_for_this_word.rb +143 -0
  12. data/lib/dictionaries/commandline/parse_commandline.rb +60 -0
  13. data/lib/dictionaries/constants.rb +133 -0
  14. data/lib/dictionaries/gui/gtk/dictionary.rb +216 -0
  15. data/lib/dictionaries/gui/tk/README.md +2 -0
  16. data/lib/dictionaries/gui/tk/dictionary.rb +85 -0
  17. data/lib/dictionaries/project/project_base_directory.rb +22 -0
  18. data/lib/dictionaries/project/project_yaml_directory.rb +23 -0
  19. data/lib/dictionaries/require_project/require_project.rb +10 -0
  20. data/lib/dictionaries/sinatra/app.rb +93 -0
  21. data/lib/dictionaries/sinatra/english_to_german.rb +81 -0
  22. data/lib/dictionaries/toplevel_methods/e.rb +16 -0
  23. data/lib/dictionaries/toplevel_methods/english_to_german.rb +31 -0
  24. data/lib/dictionaries/toplevel_methods/has_key.rb +32 -0
  25. data/lib/dictionaries/toplevel_methods/is_on_roebe.rb +16 -0
  26. data/lib/dictionaries/toplevel_methods/main_file.rb +88 -0
  27. data/lib/dictionaries/toplevel_methods/misc.rb +42 -0
  28. data/lib/dictionaries/toplevel_methods/module_methods.rb +9 -0
  29. data/lib/dictionaries/toplevel_methods/show_help.rb +30 -0
  30. data/lib/dictionaries/version/version.rb +17 -0
  31. data/lib/dictionaries/yaml/chinese.yml +19 -0
  32. data/lib/dictionaries/yaml/danish.yml +4 -0
  33. data/lib/dictionaries/yaml/deutsche_fremdwoerter.yml +1 -0
  34. data/lib/dictionaries/yaml/dutch.yml +3 -0
  35. data/lib/dictionaries/yaml/english.yml +2247 -0
  36. data/lib/dictionaries/yaml/farsi.yml +8 -0
  37. data/lib/dictionaries/yaml/finnish.yml +2 -0
  38. data/lib/dictionaries/yaml/italian.yml +499 -0
  39. data/lib/dictionaries/yaml/japanese.yml +15 -0
  40. data/lib/dictionaries/yaml/portugese.yml +42 -0
  41. data/lib/dictionaries/yaml/russian.yml +10 -0
  42. data/lib/dictionaries/yaml/spanish.yml +126 -0
  43. data/lib/dictionaries/yaml/swedish.yml +113 -0
  44. metadata +204 -0
@@ -0,0 +1,672 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # This is the base class for the various dictionaries.
6
+ #
7
+ # That way, we can ask specific words from a specific dictionary,
8
+ # such as english words or italian words and so forth.
9
+ # =========================================================================== #
10
+ # require 'dictionaries/class/ask_word_from_dictionary.rb'
11
+ # =========================================================================== #
12
+ begin
13
+ require 'colours'
14
+ rescue LoadError; end
15
+ require 'yaml'
16
+ require 'opn'
17
+ require 'open_in_browser'
18
+ require 'xorg_buffer/module'
19
+ require 'save_file/module'
20
+ # =========================================================================== #
21
+ # Require module-methods of this project next.
22
+ # =========================================================================== #
23
+ require 'dictionaries/toplevel_methods/main_file.rb'
24
+ # =========================================================================== #
25
+ # Next, load up dictionaries-related ruby code.
26
+ # =========================================================================== #
27
+ require 'dictionaries/constants.rb'
28
+ require 'dictionaries/class/colours.rb'
29
+ require 'dictionaries/class/set_search_for_this_word.rb'
30
+
31
+ module Dictionaries
32
+
33
+ class AskWordFromDictionary # === Dictionaries::AskWordFromDictionary
34
+
35
+ begin
36
+ require 'generate_shell_completion'
37
+ rescue LoadError; end
38
+
39
+ include XorgBuffer
40
+ include Colours::E
41
+
42
+ # ========================================================================= #
43
+ # === NAMESPACE
44
+ # ========================================================================= #
45
+ NAMESPACE = inspect
46
+
47
+ # ========================================================================= #
48
+ # === initialize
49
+ # ========================================================================= #
50
+ def initialize(
51
+ optional_search_for_this_word = nil,
52
+ use_this_file_for_the_dataset = :default_file,
53
+ run_already = true
54
+ )
55
+ register_sigint
56
+ reset
57
+ case optional_search_for_this_word
58
+ when :do_not_run_yet
59
+ run_already = :do_not_run_yet
60
+ optional_search_for_this_word = nil
61
+ end
62
+ # ======================================================================= #
63
+ # === Next, set the main file to use
64
+ # ======================================================================= #
65
+ if use_this_file_for_the_dataset
66
+ set_use_this_file(use_this_file_for_the_dataset)
67
+ load_main_dataset
68
+ end
69
+ set_search_for_this_word(optional_search_for_this_word)
70
+ if run_already.is_a? Hash
71
+ if run_already.has_key? :delay
72
+ set_delay(run_already.delete(:delay))
73
+ end
74
+ run_already = true
75
+ end
76
+ case run_already
77
+ when :dont_run_yet, :do_not_run_yet
78
+ run_already = false
79
+ end
80
+ run if run_already
81
+ end
82
+
83
+ # ========================================================================= #
84
+ # === reset
85
+ # ========================================================================= #
86
+ def reset
87
+ @original_words = {} # A Hash.
88
+ @words = nil
89
+ @be_verbose = true
90
+ @store_line_number_where = STORE_LINE_NUMBER_HERE
91
+ @ask_the_question = true # Whether to ask the question or not.
92
+ set_use_this_file # Set to nil initially.
93
+ set_delay
94
+ end
95
+
96
+ # ========================================================================= #
97
+ # === set_delay (delay tag)
98
+ # ========================================================================= #
99
+ def set_delay(i = DEFAULT_DELAY)
100
+ @delay = i
101
+ end
102
+
103
+ # ========================================================================= #
104
+ # === find_all_matches_for
105
+ # ========================================================================= #
106
+ def find_all_matches_for(i) # Must return an Array.
107
+ selection = @words.select {|key,value| key.start_with? i }.keys
108
+ return selection
109
+ end
110
+
111
+ # ========================================================================= #
112
+ # === available_keys?
113
+ # ========================================================================= #
114
+ def available_keys?
115
+ @words.keys if @words
116
+ end; alias array available_keys? # === array
117
+
118
+ # ========================================================================= #
119
+ # === find_this_word_in_yaml_file
120
+ #
121
+ # This method will give us the correct line number.
122
+ # ========================================================================= #
123
+ def find_this_word_in_yaml_file(this_word)
124
+ _ = File.readlines(
125
+ @use_this_file, :encoding => USE_THIS_ENCODING
126
+ )
127
+ _ = _.index() {|x| x =~ /^#{this_word}/ }
128
+ line_number = _.to_i + 1
129
+ save_line_number(line_number)
130
+ save_last_question_asked(this_word)
131
+ end
132
+
133
+ # ========================================================================= #
134
+ # === show_every_word
135
+ #
136
+ # This will simply show every word.
137
+ # ========================================================================= #
138
+ def show_every_word
139
+ @original_words.each_pair {|key, value|
140
+ e "#{key.to_s.ljust(20)} -> #{value}"
141
+ }
142
+ end
143
+
144
+ # ========================================================================= #
145
+ # === return_random_word
146
+ # ========================================================================= #
147
+ def return_random_word
148
+ available_keys?.sample
149
+ end
150
+
151
+ # ========================================================================= #
152
+ # === generate_tab_completion (tab tag)
153
+ #
154
+ # The first argument should be the name of the dictionary in question,
155
+ # such as 'english' or 'italian'.
156
+ #
157
+ # To generate the tab completion, do this:
158
+ #
159
+ # askeng TAB
160
+ #
161
+ # ========================================================================= #
162
+ def generate_tab_completion(
163
+ this_language = 'english'
164
+ )
165
+ require 'generate_shell_completion'
166
+ dataset = @original_words.keys # cat $SCI/YAML/DICTIONARIES/english.yml
167
+ # Next, determine where to store the completion stuff.
168
+ generate_where =
169
+ ENV['MY_OS'].to_s+'/LINUX/SHELL/SCRIPTS/'+this_language+'_completion.sh'
170
+ _ = GenerateShellCompletion::GenerateShellCompletion.new(:do_not_run_yet)
171
+ _.add_data(dataset)
172
+ _.set_file(generate_where)
173
+ _.set_name_of_function(this_language.to_sym)
174
+ _.add_aliases %w( askeng ask_eng )
175
+ _.generate
176
+ end
177
+
178
+ # ========================================================================= #
179
+ # === reveal_the_answer
180
+ #
181
+ # Show the answer here.
182
+ # ========================================================================= #
183
+ def reveal_the_answer
184
+ @result = @original_words[@search_for_this_word].to_s
185
+ _ = @result
186
+ begin
187
+ _[0,1] = _[0,1].upcase
188
+ rescue Exception => error
189
+ opnn; e 'An exception happened at line '+simp(__LINE__.to_s)+' when '\
190
+ 'we tried to use .upcase.'
191
+ opnn; e 'The file was '+sfile(__FILE__)
192
+ opnn; e 'The difficult word in question was `'+simp(_)+'`.'
193
+ opnn; e 'The encoding in use was '+simp(_.encoding.to_s)+'.'
194
+ pp error
195
+ begin
196
+ _ = _.encode(USE_THIS_ENCODING)
197
+ _[0,1] = _[0,1].upcase
198
+ rescue Exception => error
199
+ pp error
200
+ end
201
+ end
202
+ _ = sanitize_answer(_)
203
+ if _.include? '[]' # Chop off [] token, if it is part of the String.
204
+ _ = _.force_encoding(USE_THIS_ENCODING) if _.encoding.to_s.include? 'UTF'
205
+ _ = _.delete('[').delete(']').strip
206
+ end
207
+ e N+simportant(_)+'.'+N+N
208
+ end; alias reveal_answer reveal_the_answer # === reveal_answer
209
+
210
+ # ========================================================================= #
211
+ # === register_sigint
212
+ # ========================================================================= #
213
+ def register_sigint
214
+ Signal.trap('SIGINT') { exit }
215
+ end
216
+
217
+ # ========================================================================= #
218
+ # === is_included?
219
+ # ========================================================================= #
220
+ def is_included?(i)
221
+ @original_words.has_key?(i)
222
+ end
223
+
224
+ # ========================================================================= #
225
+ # === feedback_help_options
226
+ #
227
+ # If you wish to trigger this, do:
228
+ #
229
+ # askeng --help
230
+ #
231
+ # ========================================================================= #
232
+ def feedback_help_options # help tag
233
+ e
234
+ e LPAD+sfancy('TOTAL')+' # Feedback how many keys are registered, '+
235
+ 'also aliased to '+sfancy('STATS')+'.'
236
+ e LPAD+sfancy('OPEN')+' # Open '+sfile(File.basename(main_file?))+
237
+ ' and '+sfile('ask_english_word.rb')+' in the main editor.'
238
+ e LPAD+sfancy('SOLVED')+' # Set the last word as solved.'
239
+ e LPAD+sfancy('URL')+' # Show the URL for the dictionary.'
240
+ e LPAD+sfancy('REPEAT')+' # Repeat the last question asked.'
241
+ e LPAD+sfancy('DELAY?')+' # Feedback the delay we use.'
242
+ e LPAD+sfancy('STATS')+' # To show some statistics, especially '\
243
+ 'the amount of registered words.'
244
+ e LPAD+sfancy('FILE?')+' # Show the main .yml file in question.'
245
+ e
246
+ exit
247
+ end
248
+
249
+ # ========================================================================= #
250
+ # === search_for?
251
+ # ========================================================================= #
252
+ def search_for?
253
+ @search_for_this_word
254
+ end
255
+
256
+ # ========================================================================= #
257
+ # === words?
258
+ # ========================================================================= #
259
+ def words?
260
+ @words
261
+ end; alias dataset? words? # === dataset?
262
+
263
+ # ========================================================================= #
264
+ # === be_verbose?
265
+ # ========================================================================= #
266
+ def be_verbose?
267
+ @be_verbose
268
+ end
269
+
270
+ # ========================================================================= #
271
+ # === result?
272
+ # ========================================================================= #
273
+ def result?
274
+ @result
275
+ end; alias result result? # === result
276
+
277
+ # ========================================================================= #
278
+ # === words?
279
+ # ========================================================================= #
280
+ def words?
281
+ @words
282
+ end
283
+
284
+ # ========================================================================= #
285
+ # === sanitize_dataset
286
+ # ========================================================================= #
287
+ def sanitize_dataset # We have to ignore all entries that contain []. We do this only for @words.
288
+ words?.reject! {|key, value|
289
+ value.include? '[]'
290
+ }
291
+ end
292
+
293
+ # ========================================================================= #
294
+ # === on_roebe?
295
+ # ========================================================================= #
296
+ def on_roebe?
297
+ ENV['IS_ROEBE'].to_s == '1'
298
+ end
299
+
300
+ # ========================================================================= #
301
+ # === do_ask_the_question
302
+ # ========================================================================= #
303
+ def do_ask_the_question # This method will ask the english question.
304
+ if search_for?.empty?
305
+ set_search_for_this_word 'RANDOM'
306
+ end
307
+ _ = search_for?
308
+ if _ == 'rand'
309
+ _ = (@search_for_this_word = return_random_word)
310
+ end
311
+ unless is_included? _
312
+ set_xorg_buffer _
313
+ opnn; e 'Sorry, the word `'+sfancy(_)+'` is not included.'
314
+ opnn; e 'We will thus try to open our english dictionary in our editor'
315
+ opnn; e 'and lookup the word in our browser.'
316
+ open_main_yaml_file_in_main_editor # Added ~ 22.02.2013
317
+ consider_opening_browser_page(_)
318
+ else # Ok, we now know that it is included. Thus, continue.
319
+ if be_verbose?
320
+ e "#{rev}What does the word `#{sfancy(_)}` mean? #{show_delay_string}"
321
+ find_this_word_in_yaml_file(_)
322
+ new_buffer = build_url_www_string(_)
323
+ set_xorg_buffer(new_buffer)
324
+ sleep delay?
325
+ reveal_the_answer
326
+ end
327
+ end
328
+ end
329
+
330
+ # ========================================================================= #
331
+ # === rev
332
+ # ========================================================================= #
333
+ def rev
334
+ Colours.rev
335
+ end
336
+
337
+ # ========================================================================= #
338
+ # === set_xorg_buffer
339
+ # ========================================================================= #
340
+ def set_xorg_buffer(i)
341
+ XorgBuffer[i] if Object.const_defined? :XorgBuffer
342
+ end
343
+
344
+ # ========================================================================= #
345
+ # === store_last_question_asked_where?
346
+ #
347
+ # This method will try to automatically find out where we will store
348
+ # the last question asked.
349
+ # ========================================================================= #
350
+ def store_last_question_asked_where?
351
+ name = Dictionaries.return_name_from_compound(main_file?)
352
+ path = DEPOT_INFORMATION_DIR+'last_'+name+'_question_asked'
353
+ return path
354
+ end
355
+
356
+ # ========================================================================= #
357
+ # === consider_opening_browser_page
358
+ # ========================================================================= #
359
+ def consider_opening_browser_page(i = '')
360
+ url = build_url_www_string(i)
361
+ opnn; e 'Consider visiting '+brown(url)+' if you need a translation.'
362
+ open_in_browser url
363
+ end
364
+
365
+ # ========================================================================= #
366
+ # === build_url_www_string
367
+ # ========================================================================= #
368
+ def build_url_www_string(i)
369
+ _ = ''.dup
370
+ # ======================================================================= #
371
+ # We need to differ between the english dictionary and the italian
372
+ # dictionary.
373
+ # ======================================================================= #
374
+ language = Dictionaries.return_name_from_compound(main_file?)
375
+ if language == 'english'
376
+ _ << '"' unless _.end_with? '"'
377
+ end
378
+ case language # case tag
379
+ when 'italian'
380
+ _ << URL_FOR_ITALIAN_DICTIONARY
381
+ when 'english' # This is the default.
382
+ _ << URL_FOR_DICT_LEO+'ende/?lp=ende&lang=de&searchLoc=0&cmpType=relaxed&sectHdr=on&spellToler=&search='
383
+ end
384
+ _ << i.to_s
385
+ if language == 'english'
386
+ _ << '"' unless _.end_with? '"' # Append '"' here.
387
+ end
388
+ _
389
+ end
390
+
391
+ # ========================================================================= #
392
+ # === show_help
393
+ #
394
+ # Show the help options.
395
+ # ========================================================================= #
396
+ def show_help
397
+ end
398
+
399
+ # ========================================================================= #
400
+ # === load_dataset
401
+ #
402
+ # Here we will define the important instance variable @original_words.
403
+ # ========================================================================= #
404
+ def load_dataset(
405
+ of_this_file = @use_this_file
406
+ ) # called via reset()
407
+ of_this_file = of_this_file.to_s # We must work with a String.
408
+ if File.exist? of_this_file
409
+ dataset = YAML.load_file(of_this_file)
410
+ @original_words = dataset
411
+ # ^^^ This is the file english.yml
412
+ else
413
+ e 'Did not find a file at '+of_this_file+'.'
414
+ e 'Thus, the @original_words will be empty.'
415
+ e 'If you wish to change this, modify the constant ENGLISH_WORDS'
416
+ e 'to point at a yaml-dataset (we require a hash, thus key: value pairs)'
417
+ @original_words = {}
418
+ end
419
+ @words = @original_words.dup
420
+ sanitize_dataset # Get rid of lines that have [] as entry.
421
+ end; alias load_main_dataset load_dataset # === load_main_dataset
422
+
423
+ # ========================================================================= #
424
+ # === set_use_this_file
425
+ #
426
+ # This sets the main dictionary-file to use, the file path to it.
427
+ # ========================================================================= #
428
+ def set_use_this_file(i = :default)
429
+ case i
430
+ when :english
431
+ i = ENGLISH_WORDS
432
+ when :default_file, :default
433
+ i = main_file?
434
+ end
435
+ @use_this_file = i
436
+ end
437
+
438
+ # ========================================================================= #
439
+ # === load_the_english_file
440
+ # ========================================================================= #
441
+ def load_the_english_file
442
+ set_use_this_file(:english)
443
+ load_main_dataset
444
+ end
445
+
446
+ # ========================================================================= #
447
+ # === use_this_file?
448
+ # ========================================================================= #
449
+ def use_this_file?
450
+ @use_this_file
451
+ end
452
+
453
+ # ========================================================================= #
454
+ # === opnn
455
+ # ========================================================================= #
456
+ def opnn
457
+ Opn.opn(namespace: NAMESPACE)
458
+ end
459
+
460
+ # ========================================================================= #
461
+ # === main_file?
462
+ # ========================================================================= #
463
+ def main_file?
464
+ Dictionaries.main_file?
465
+ end
466
+
467
+ # ========================================================================= #
468
+ # === feedback_yaml_file
469
+ # ========================================================================= #
470
+ def feedback_yaml_file
471
+ efile main_file?
472
+ end
473
+
474
+ # ========================================================================= #
475
+ # === feedback_statistics
476
+ #
477
+ # Feedback the amount of questions registered. In the future, perhaps
478
+ # we may want to have more statistic-options, so this may be expanded
479
+ # at a later time.
480
+ #
481
+ # To trigger this, do:
482
+ # askeng --stats?
483
+ # ========================================================================= #
484
+ def feedback_statistics
485
+ feedback_total_amount_of_keys(:do_not_exit)
486
+ end
487
+
488
+ # ========================================================================= #
489
+ # === feedback_url
490
+ # ========================================================================= #
491
+ def feedback_url
492
+ opnn; e " -> #{URL_FOR_DICT_LEO}"
493
+ exit
494
+ end
495
+
496
+ # ========================================================================= #
497
+ # === open_yaml_file_in_main_editor
498
+ # ========================================================================= #
499
+ def open_yaml_file_in_main_editor(
500
+ this_file = main_file?
501
+ )
502
+ if on_roebe? # Rewrite for my own system at home.
503
+ this_file = File.basename(this_file)
504
+ this_file = MY_DICTIONARIES+this_file
505
+ end
506
+ _= this_file
507
+ notify_the_user_that_we_will_next_open_this_file(_)
508
+ system 'bluefish '+_
509
+ end; alias open_main_yaml_file_in_main_editor open_yaml_file_in_main_editor # === open_main_yaml_file_in_main_editor
510
+
511
+ # ========================================================================= #
512
+ # === notify_the_user_that_we_will_next_open_this_file
513
+ # ========================================================================= #
514
+ def notify_the_user_that_we_will_next_open_this_file(this_file)
515
+ opnn; e 'Opening file `'+sfile(this_file)+'` next.'
516
+ end
517
+
518
+ # ========================================================================= #
519
+ # === feedback_total_amount_of_keys
520
+ # ========================================================================= #
521
+ def feedback_total_amount_of_keys(shall_we_exit = true) # KEYS
522
+ case shall_we_exit
523
+ when :do_not_exit
524
+ shall_we_exit = false
525
+ end
526
+ _ = @original_words.size - @words.size
527
+ opnn; e swarn(@original_words.size.to_s)+' english words in total.'
528
+ rounded = sprintf('%0.2f', 100.0 - (@words.size * 100.0 / @original_words.size) )
529
+ opnn; e swarn(@words.size.to_s)+' unanswered english words, '\
530
+ 'thus '+sfancy(_.to_s)+' are already answered. ('+
531
+ simp(rounded.to_s+'%')+')'
532
+ opnn; e 'The yaml file that we we will use is:'
533
+ opnn; e ' '+sfile(main_file?)
534
+ exit if shall_we_exit
535
+ end
536
+
537
+ # ========================================================================= #
538
+ # === open_this_file_here
539
+ # ========================================================================= #
540
+ def open_this_file_here(be_verbose = false)
541
+ _= Dictionaries.main_file?
542
+ if be_verbose
543
+ opnn; notify_the_user_that_we_will_next_open_this_file(_)
544
+ end
545
+ system 'bluefish '+_
546
+ end
547
+
548
+ # ========================================================================= #
549
+ # === sanitize_answer
550
+ #
551
+ # This may also re-encode the given String object.
552
+ # ========================================================================= #
553
+ def sanitize_answer(i)
554
+ begin
555
+ unless i.encoding.to_s.include? USE_THIS_ENCODING
556
+ i = i.force_encoding(USE_THIS_ENCODING)
557
+ end
558
+ i.gsub!(/ \[\]/,'') if i.include? '[]'
559
+ rescue Exception => error
560
+ opnn; pp error # Propagate the error here to the user.
561
+ end
562
+ return i
563
+ end
564
+
565
+ # ========================================================================= #
566
+ # === save_line_number
567
+ # ========================================================================= #
568
+ def save_line_number(what) # save tag
569
+ begin
570
+ save_file(what, @store_line_number_where)
571
+ rescue => error
572
+ pp error
573
+ pp error.class
574
+ end
575
+ end
576
+
577
+ # ========================================================================= #
578
+ # === set_last_word_solved
579
+ # ========================================================================= #
580
+ def set_last_word_solved # Call this only when you want to solve an english word.
581
+ begin
582
+ require 'roebe/classes/append_to_line.rb'
583
+ _ = Roebe::AppendToLine.new(:english, false) # bl $RUBY_TOOLS/append_to_line.rb
584
+ _.set_line File.read(STORE_LINE_NUMBER_HERE)
585
+ _.run
586
+ rescue LoadError; end
587
+ exit
588
+ end
589
+
590
+ # ========================================================================= #
591
+ # === save_last_question_asked
592
+ # ========================================================================= #
593
+ def save_last_question_asked(what) # Save the last question asked.
594
+ into = store_last_question_asked_where?
595
+ begin
596
+ save_file(what, into)
597
+ rescue Errno::ENOENT
598
+ opnn; e "Can not store into `#{sfile(into)}`."
599
+ end
600
+ end
601
+
602
+ # ========================================================================= #
603
+ # === save_file
604
+ # ========================================================================= #
605
+ def save_file(what, into)
606
+ SaveFile.write_what_into(what, into)
607
+ end
608
+
609
+ # ========================================================================= #
610
+ # === delay?
611
+ # ========================================================================= #
612
+ def delay?
613
+ @delay
614
+ end
615
+
616
+ # ========================================================================= #
617
+ # === feedback_delay
618
+ # ========================================================================= #
619
+ def feedback_delay
620
+ opnn; e "The delay we use is set to: #{sfancy(@delay.to_s)}"
621
+ exit
622
+ end
623
+
624
+ # ========================================================================= #
625
+ # === run (run tag)
626
+ # ========================================================================= #
627
+ def run
628
+ load_dataset
629
+ do_ask_the_question if @ask_the_question
630
+ end
631
+
632
+ # ========================================================================= #
633
+ # === translate
634
+ # ========================================================================= #
635
+ def translate(i)
636
+ return @original_words[i].to_s
637
+ end
638
+
639
+ # ========================================================================= #
640
+ # === show_delay_string
641
+ # ========================================================================= #
642
+ def show_delay_string
643
+ result = '(Delay is at '+simp(@delay.to_s)+' seconds)'
644
+ result = '' if @delay.to_i == 0
645
+ return result
646
+ end
647
+
648
+ end
649
+
650
+ # =========================================================================== #
651
+ # === Dictionaries.translate
652
+ # =========================================================================== #
653
+ def self.translate(this_word = nil)
654
+ _ = Dictionaries::AskWordFromDictionary.new(this_word, :default_file, :dont_run_yet)
655
+ _.translate(this_word)
656
+ end
657
+
658
+ # =========================================================================== #
659
+ # === Dictionaries.new
660
+ # =========================================================================== #
661
+ def self.new(i = nil)
662
+ Dictionaries::AskWordFromDictionary.new(i)
663
+ end
664
+
665
+ end
666
+
667
+ if __FILE__ == $PROGRAM_NAME
668
+ pp Dictionaries::AskWordFromDictionary.new
669
+ pp Dictionaries::AskWordFromDictionary.class
670
+ pp Dictionaries::DICTIONARIES_DIR
671
+ pp Dictionaries::ENGLISH_WORDS
672
+ end