dictionaries 0.2.191

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 (48) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +151 -0
  3. data/bin/dictionaries +7 -0
  4. data/bin/unique_words_in_this_file +7 -0
  5. data/dictionaries.gemspec +85 -0
  6. data/doc/README.gen +123 -0
  7. data/lib/dictionaries/ask_english_word.rb +141 -0
  8. data/lib/dictionaries/ask_italian_word.rb +84 -0
  9. data/lib/dictionaries/class/ask_word_from_dictionary.rb +693 -0
  10. data/lib/dictionaries/class/colours.rb +55 -0
  11. data/lib/dictionaries/class/constants.rb +16 -0
  12. data/lib/dictionaries/class/set_search_for_this_word.rb +163 -0
  13. data/lib/dictionaries/commandline/parse_commandline.rb +60 -0
  14. data/lib/dictionaries/constants.rb +133 -0
  15. data/lib/dictionaries/gui/gtk2/dictionary.rb +36 -0
  16. data/lib/dictionaries/gui/gtk3/dictionary/dictionary.rb +34 -0
  17. data/lib/dictionaries/gui/shared_code/dictionaries/dictionary_module.rb +362 -0
  18. data/lib/dictionaries/gui/tk/README.md +2 -0
  19. data/lib/dictionaries/gui/tk/dictionary.rb +85 -0
  20. data/lib/dictionaries/project/project_base_directory.rb +22 -0
  21. data/lib/dictionaries/project/project_yaml_directory.rb +25 -0
  22. data/lib/dictionaries/require_project/require_project.rb +11 -0
  23. data/lib/dictionaries/sinatra/app.rb +105 -0
  24. data/lib/dictionaries/sinatra/english_to_german.rb +82 -0
  25. data/lib/dictionaries/toplevel_methods/e.rb +16 -0
  26. data/lib/dictionaries/toplevel_methods/english_to_german.rb +31 -0
  27. data/lib/dictionaries/toplevel_methods/has_key.rb +32 -0
  28. data/lib/dictionaries/toplevel_methods/is_on_roebe.rb +16 -0
  29. data/lib/dictionaries/toplevel_methods/main_file.rb +88 -0
  30. data/lib/dictionaries/toplevel_methods/misc.rb +129 -0
  31. data/lib/dictionaries/toplevel_methods/module_methods.rb +9 -0
  32. data/lib/dictionaries/toplevel_methods/show_help.rb +30 -0
  33. data/lib/dictionaries/version/version.rb +17 -0
  34. data/lib/dictionaries/yaml/chinese.yml +21 -0
  35. data/lib/dictionaries/yaml/danish.yml +4 -0
  36. data/lib/dictionaries/yaml/deutsche_fremdwoerter.yml +1 -0
  37. data/lib/dictionaries/yaml/dutch.yml +3 -0
  38. data/lib/dictionaries/yaml/english.yml +2419 -0
  39. data/lib/dictionaries/yaml/farsi.yml +8 -0
  40. data/lib/dictionaries/yaml/finnish.yml +2 -0
  41. data/lib/dictionaries/yaml/italian.yml +499 -0
  42. data/lib/dictionaries/yaml/japanese.yml +15 -0
  43. data/lib/dictionaries/yaml/portugese.yml +42 -0
  44. data/lib/dictionaries/yaml/russian.yml +10 -0
  45. data/lib/dictionaries/yaml/spanish.yml +130 -0
  46. data/lib/dictionaries/yaml/swedish.yml +101 -0
  47. data/lib/dictionaries.rb +1 -0
  48. metadata +208 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b86ebe2edf8b4b940e385873303e51038b2d67c70d1434f06e49574e1eca8958
4
+ data.tar.gz: b039379b5fa48802171178d766cf9966ca9a54d68c4c527df04128f5c4c29cc9
5
+ SHA512:
6
+ metadata.gz: 852f9e8b967882908dbeff5b7ca9400eb29a1db690f0a39267cb1ee6d32bb51a5a46eb38a9acca79a042082a9db52f14c8c6544b2f2bdd12de1e3b60a6c7e9b4
7
+ data.tar.gz: 9ca37cb31b7518110d5b3e4b4aafa7f843bba14e1c59e5caec5feccf0a52eeab6a4fba95de49c4bb8eec1a9cc27b45a3e5af1f0c280f0da6868da292d0536cf1
data/README.md ADDED
@@ -0,0 +1,151 @@
1
+ [![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](https://www.gobolinux.org/)
2
+ [![forthebadge](http://forthebadge.com/images/badges/made-with-ruby.svg)](https://www.ruby-lang.org/en/)
3
+ [![Gem Version](https://badge.fury.io/rb/dictionaries.svg)](https://badge.fury.io/rb/dictionaries)
4
+
5
+ This gem was <b>last updated</b> on the <span style="color: darkblue; font-weight: bold">05.09.2021</span> (dd.mm.yyyy notation), at <span style="color: steelblue; font-weight: bold">05:08:37</span> o'clock.
6
+
7
+ ## GUI component
8
+
9
+ The **GUI component** of the dictionaries gem defaults to
10
+ **GTK3** finally. It is not a very advanced GUI, though.
11
+
12
+ First, install the gtk3 gem:
13
+
14
+ gem install gtk3
15
+
16
+ Then install the gtk_paradise project:
17
+
18
+ gem install gtk_paradise
19
+
20
+ Now you should be able to start the GUI component if the above
21
+ has worked:
22
+
23
+ dictionaries --gui
24
+
25
+ See also the help options.
26
+
27
+ dictionaries --help
28
+
29
+ You may need to install some .h files if you use a specific
30
+ Linux distribution; look at the relevant -dev packages for
31
+ this. Or just compile from source. :)
32
+
33
+ ## Environment variable to use a specific yaml file
34
+
35
+ You can use an <b>environment variable</b> to denote the default
36
+ yaml file in use. This allows you to use your own yaml file
37
+ format, rather than the yaml files that are distributed with
38
+ this gem.
39
+
40
+ The name of that environment variable must be <b>DICTIONARIES_FILE</b>.
41
+ It shall point to your yaml file that holds the key-value pairs.
42
+
43
+ For example, if your file is at /opt/czech.yml, then
44
+ DICTIONARIES_FILE should point at that location.
45
+
46
+ In bash, this may be equivalent to:
47
+
48
+ export DICTIONARIES_FILE=/opt/czech.yml
49
+
50
+ Note that in the long run, the dictionaries gem could be extended
51
+ with these yaml files - or allow means to download these files
52
+ over the www. But before we can do so, let's aim for at the least
53
+ 100 words in such a file before we would consider distributing
54
+ it or offering means to distribute said file.
55
+
56
+ ## sinatra
57
+
58
+ To start the sinatra interface of the dictionaries gem, do:
59
+
60
+ dictionaries --sinatra
61
+
62
+ ## Difficult english sentences
63
+
64
+ English is not the most difficult language in the world, but when it
65
+ comes to proper pronounciation of words, english can be surprisingly
66
+ difficult.
67
+
68
+ This subsection may keep a listing of sentences that, for one reason
69
+ or the other, can be somewhat difficult to **read out aloud** without
70
+ mistake, on a first try. It is just a fun-subsection, not meant to be
71
+ taken too seriously; and it is quite subjective.
72
+
73
+ Without any further ado, here comes a listing of sentences that may
74
+ be difficult to pronounce properly so:
75
+
76
+ I would like to distribute something.
77
+
78
+ ## Obtaining all translations into german for a given english word
79
+
80
+ Since as of **November 2020** the following API exists:
81
+
82
+ Dictionaries.return_array_of_translated_words_from_online_leo('cat')
83
+ Dictionaries.return_array_of_translated_words_from_online_leo('dog')
84
+ Dictionaries.return_array_of_translated_words_from_online_leo('human')
85
+
86
+ This will return an Array of german names. It does not work 100% perfectly
87
+ as it is based on a regex; and using a regex to parse HTML is never a
88
+ trivial way. But if you just want to get the first entry, just call
89
+ .first on it, and in most cases this is the best, most likely
90
+ translation available.
91
+
92
+ The regex has to find matches to entries such as the following one:
93
+
94
+ </repr><words><word>der Jazzfan</word></words>
95
+
96
+ Anyone to come up with a more accurate regex is welcome to share it. :)
97
+
98
+ This functionality was specifically necessary because I needed to
99
+ use this in the ruby-gtk bindings for this project.
100
+
101
+ ## Dictionaries.return_unique_words_from_this_file
102
+
103
+ This method will return all words that are presently not registered
104
+ in the english dictionary.
105
+
106
+ The idea here is for me to slowly add more english words into the
107
+ yaml file. I won't add every english word that exists, but I will
108
+ try to aim for a seizable number in the long run, such as
109
+ 5000 english words - already halfway there. \o/
110
+
111
+ ## Licence
112
+
113
+ Until the 17th of October 2019, this project was using the GPLv2
114
+ licence (no later clause).
115
+
116
+ However had, I believe that the GPLv2 licence is not great for
117
+ a project that focuses on existing words in real languages, aka
118
+ dictionaries. Thus, I have decided to change the licence into
119
+ the MIT licence on that day (17.11.2019, in dd.mm.yyyy notation).
120
+
121
+ So the gem is now MIT licenced. \o/
122
+
123
+ For a description of that licence, see
124
+ https://opensource.org/licenses/MIT.
125
+
126
+
127
+ ## Contact information
128
+
129
+ If your creative mind has ideas and specific suggestions to make this
130
+ gem more useful in general, feel free to drop me an email at any
131
+ time, via:
132
+
133
+ shevy@inbox.lt
134
+
135
+ Before that email I used an email account at Google gmail, but in **2021** I
136
+ decided to slowly abandon gmail for various reasons. In part this is because
137
+ the UI annoys me (on non-chrome browser loading takes too long), but also
138
+ because of Google's attempt to establish mass surveillance via its
139
+ federated cohorts sniffing (FLoC). I do not know what happened at Google,
140
+ but enough is enough - there is only so much you can take while supporting
141
+ greed. When it comes to data mining done by private groups, ultimately
142
+ the user became the product.
143
+
144
+ Do keep in mind that responding to emails may take some time,
145
+ depending on the amount of work I may have at that moment, due
146
+ to reallife time constraints. I will, however had, read feedback
147
+ eventually. Patches and code changes are welcome too, of course,
148
+ as long as they are in the spirit of the project at hand, e. g.
149
+ fitting to the general theme. For this I may make use of github
150
+ as a discussion site, but this has a low priority right now.
151
+
data/bin/dictionaries ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'dictionaries'
6
+
7
+ Dictionaries.parse_commandline(ARGV)
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ require 'dictionaries'
6
+
7
+ pp Dictionaries.return_unique_words_from_this_file(ARGV)
@@ -0,0 +1,85 @@
1
+ # =========================================================================== #
2
+ # Gemspec for Project Dictionaries.
3
+ # =========================================================================== #
4
+ require 'dictionaries'
5
+ require 'roebe'
6
+
7
+ Gem::Specification.new { |s|
8
+
9
+ s.name = 'dictionaries'
10
+ s.version = Dictionaries::VERSION
11
+ s.date = Time.now.strftime('%Y-%m-%d')
12
+
13
+ DESCRIPTION = <<-EOF
14
+
15
+ This project is called dictionaries.
16
+
17
+ It used to be called ask_english_words but the name was changed towards
18
+ "dictionaries", when the focus became on dictionaries in general rather
19
+ than merely translations from and to the english language.
20
+
21
+ There are a total of #{Dictionaries.n_entries?} english words
22
+ registered, with the associated german translation. (It is
23
+ german primarily because that is my native language, but in
24
+ principle this project could be extended to include other
25
+ languages as well. You only need to add a yaml file containing
26
+ the key-value pairs.)
27
+
28
+ If you need a more comprehensive dictionary, I can recommend
29
+ the file de-en.txt that is part of the tu-chemnitz
30
+ distribution ( https://www-user.tu-chemnitz.de/~fri/ding/ ). That
31
+ file is really huge - about 20 MB.
32
+
33
+ In principle, the dictionaries project could be extended to
34
+ make use of that massive file instead. I will be thinking
35
+ about this for the time being (starting at July 2018).
36
+
37
+ EOF
38
+
39
+ s.summary = DESCRIPTION
40
+ s.description = DESCRIPTION
41
+
42
+ # ========================================================================= #
43
+ # Show this message when a user installs this project.
44
+ # ========================================================================= #
45
+ s.post_install_message = <<-EOF
46
+
47
+ This project can ask or translate english or italian words (or words
48
+ from any other language, as long as a .yml file is supplied that
49
+ contains these key-value pair entries).
50
+
51
+ This project is probably not very useful for other people, but it helps
52
+ me to improve my knowledge about the english or italian language or
53
+ any other language.
54
+
55
+ For more information, have a look at the main README.md file, which
56
+ can also be found on the hompage of this gem at rubygems.org, on
57
+ the bottom right side (see https://www.rubydoc.info/gems/dictionaries/ ).
58
+
59
+ EOF
60
+
61
+ s.extra_rdoc_files = %w()
62
+
63
+ s.authors = ['Robert A. Heiler']
64
+ s.email = Roebe.email?
65
+ s.files = Dir['**/*']
66
+ # s.files << 'README.md'
67
+ # s.files << 'USAGE.md'
68
+ s.license = 'MIT'
69
+ s.homepage = 'https://www.rubydoc.info/gems/dictionaries/'
70
+
71
+ s.required_ruby_version = '>= '+Roebe.third_most_stable_version_of_ruby
72
+ s.required_rubygems_version = '>= '+Gem::VERSION
73
+ s.rubygems_version = '>= '+Gem::VERSION
74
+
75
+ # ========================================================================= #
76
+ # External dependencies for the project:
77
+ # ========================================================================= #
78
+ s.add_dependency 'colours'
79
+ s.add_dependency 'generate_shell_completion'
80
+ s.add_dependency 'opn'
81
+ s.add_dependency 'open'
82
+ s.add_dependency 'save_file'
83
+ s.add_dependency 'xorg_buffer'
84
+
85
+ }
data/doc/README.gen ADDED
@@ -0,0 +1,123 @@
1
+ ADD_RUBY_BADGE
2
+ ADD_TIME_STAMP
3
+
4
+ ## GUI component
5
+
6
+ The **GUI component** of the dictionaries gem defaults to
7
+ **GTK3** finally. It is not a very advanced GUI, though.
8
+
9
+ First, install the gtk3 gem:
10
+
11
+ gem install gtk3
12
+
13
+ Then install the gtk_paradise project:
14
+
15
+ gem install gtk_paradise
16
+
17
+ Now you should be able to start the GUI component if the above
18
+ has worked:
19
+
20
+ dictionaries --gui
21
+
22
+ See also the help options.
23
+
24
+ dictionaries --help
25
+
26
+ You may need to install some .h files if you use a specific
27
+ Linux distribution; look at the relevant -dev packages for
28
+ this. Or just compile from source. :)
29
+
30
+ ## Environment variable to use a specific yaml file
31
+
32
+ You can use an <b>environment variable</b> to denote the default
33
+ yaml file in use. This allows you to use your own yaml file
34
+ format, rather than the yaml files that are distributed with
35
+ this gem.
36
+
37
+ The name of that environment variable must be <b>DICTIONARIES_FILE</b>.
38
+ It shall point to your yaml file that holds the key-value pairs.
39
+
40
+ For example, if your file is at /opt/czech.yml, then
41
+ DICTIONARIES_FILE should point at that location.
42
+
43
+ In bash, this may be equivalent to:
44
+
45
+ export DICTIONARIES_FILE=/opt/czech.yml
46
+
47
+ Note that in the long run, the dictionaries gem could be extended
48
+ with these yaml files - or allow means to download these files
49
+ over the www. But before we can do so, let's aim for at the least
50
+ 100 words in such a file before we would consider distributing
51
+ it or offering means to distribute said file.
52
+
53
+ ## sinatra
54
+
55
+ To start the sinatra interface of the dictionaries gem, do:
56
+
57
+ dictionaries --sinatra
58
+
59
+ ## Difficult english sentences
60
+
61
+ English is not the most difficult language in the world, but when it
62
+ comes to proper pronounciation of words, english can be surprisingly
63
+ difficult.
64
+
65
+ This subsection may keep a listing of sentences that, for one reason
66
+ or the other, can be somewhat difficult to **read out aloud** without
67
+ mistake, on a first try. It is just a fun-subsection, not meant to be
68
+ taken too seriously; and it is quite subjective.
69
+
70
+ Without any further ado, here comes a listing of sentences that may
71
+ be difficult to pronounce properly so:
72
+
73
+ I would like to distribute something.
74
+
75
+ ## Obtaining all translations into german for a given english word
76
+
77
+ Since as of **November 2020** the following API exists:
78
+
79
+ Dictionaries.return_array_of_translated_words_from_online_leo('cat')
80
+ Dictionaries.return_array_of_translated_words_from_online_leo('dog')
81
+ Dictionaries.return_array_of_translated_words_from_online_leo('human')
82
+
83
+ This will return an Array of german names. It does not work 100% perfectly
84
+ as it is based on a regex; and using a regex to parse HTML is never a
85
+ trivial way. But if you just want to get the first entry, just call
86
+ .first on it, and in most cases this is the best, most likely
87
+ translation available.
88
+
89
+ The regex has to find matches to entries such as the following one:
90
+
91
+ </repr><words><word>der Jazzfan</word></words>
92
+
93
+ Anyone to come up with a more accurate regex is welcome to share it. :)
94
+
95
+ This functionality was specifically necessary because I needed to
96
+ use this in the ruby-gtk bindings for this project.
97
+
98
+ ## Dictionaries.return_unique_words_from_this_file
99
+
100
+ This method will return all words that are presently not registered
101
+ in the english dictionary.
102
+
103
+ The idea here is for me to slowly add more english words into the
104
+ yaml file. I won't add every english word that exists, but I will
105
+ try to aim for a seizable number in the long run, such as
106
+ 5000 english words - already halfway there. \o/
107
+
108
+ ## Licence
109
+
110
+ Until the 17th of October 2019, this project was using the GPLv2
111
+ licence (no later clause).
112
+
113
+ However had, I believe that the GPLv2 licence is not great for
114
+ a project that focuses on existing words in real languages, aka
115
+ dictionaries. Thus, I have decided to change the licence into
116
+ the MIT licence on that day (17.11.2019, in dd.mm.yyyy notation).
117
+
118
+ So the gem is now MIT licenced. \o/
119
+
120
+ For a description of that licence, see
121
+ https://opensource.org/licenses/MIT.
122
+
123
+ ADD_CONTACT_INFORMATION
@@ -0,0 +1,141 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === Dictionaries::AskEnglishWord
6
+ #
7
+ # Use this class to ask a random english word.
8
+ #
9
+ # There are two ways to use this class:
10
+ #
11
+ # - Pass in an optional argument to it, which we will use to query this
12
+ # word from the database.
13
+ #
14
+ # - Pass nothing to it, in which case we load a random entry.
15
+ #
16
+ # Specific usage examples:
17
+ #
18
+ # require 'dictionaries'
19
+ # Dictionaries::AskEnglishWord.new
20
+ # Dictionaries.ask_english_word
21
+ #
22
+ # =========================================================================== #
23
+ # require 'dictionaries/ask_english_word.rb'
24
+ # Dictionaries.path_to_the_english_file?
25
+ # =========================================================================== #
26
+ require 'dictionaries/class/ask_word_from_dictionary.rb'
27
+
28
+ module Dictionaries
29
+
30
+ class AskEnglishWord < AskWordFromDictionary
31
+
32
+ # ========================================================================= #
33
+ # === DATA
34
+ # ========================================================================= #
35
+ if defined?(DATA) == 'constant'
36
+ if DATA.respond_to? :read
37
+ _ = DATA.read
38
+ else
39
+ e 'DATA does not respond to :read'
40
+ end
41
+ else
42
+ _ = ''
43
+ end
44
+
45
+ # ========================================================================= #
46
+ # === DEFAULT_DELAY
47
+ # ========================================================================= #
48
+ if _.to_s.empty? # Next, define the default delay.
49
+ DEFAULT_DELAY = 2.2 # How long to wait before asking a question.
50
+ else
51
+ _ = _.first if _.is_a? Array
52
+ DEFAULT_DELAY = _.strip.to_f
53
+ end
54
+
55
+ # ========================================================================= #
56
+ # === AskEnglishWord::THIS_FILE
57
+ # ========================================================================= #
58
+ THIS_FILE = THIS_FILE_HERE = __FILE__.to_s
59
+
60
+ unless ENV['DICTIONARIES_FILE'] and File.exist?(ENV['DICTIONARIES_FILE'])
61
+ Dictionaries.set_main_file(THIS_FILE) # Assign it at once.
62
+ end
63
+
64
+ # ========================================================================= #
65
+ # === initialize
66
+ # ========================================================================= #
67
+ def initialize(
68
+ commandline_arguments = ARGV
69
+ )
70
+ super(commandline_arguments, self.class.main_file?)
71
+ end
72
+
73
+ # ========================================================================= #
74
+ # === Dictionaries::AskEnglishWord.main_file?
75
+ # ========================================================================= #
76
+ def self.main_file?
77
+ Dictionaries.main_file?
78
+ end
79
+
80
+ # ========================================================================= #
81
+ # === Dictionaries::AskEnglishWord.dataset?
82
+ #
83
+ # Note that this method will load the dataset from the main file anew
84
+ # whenever you invoke it.
85
+ # ========================================================================= #
86
+ def self.dataset?
87
+ YAML.load_file(self.main_file?)
88
+ end
89
+
90
+ # ========================================================================= #
91
+ # === Dictionaries::AskEnglishWord.n_entries?
92
+ #
93
+ # Feedback how many entries are registered.
94
+ # ========================================================================= #
95
+ def self.n_entries?
96
+ _ = dataset?
97
+ n_entries = _.size
98
+ return n_entries
99
+ end; self.instance_eval { alias n_questions? n_entries? } # === AskEnglishWord.n_questions?
100
+
101
+ # ========================================================================= #
102
+ # === Dictionaries::AskEnglishWord[]
103
+ # ========================================================================= #
104
+ def self.[](i)
105
+ self.new(i)
106
+ end
107
+
108
+ end
109
+
110
+ # =========================================================================== #
111
+ # === Dictionaries.ask_english_word
112
+ # =========================================================================== #
113
+ def self.ask_english_word
114
+ AskEnglishWord.new
115
+ end
116
+
117
+ # =========================================================================== #
118
+ # === Dictionaries.path_to_the_english_file?
119
+ #
120
+ # This method may return a String, as a file path, such as
121
+ # "/home/Programs/Ruby/2.7.2/lib/ruby/site_ruby/2.7.0/dictionaries/yaml/english.yml".
122
+ # =========================================================================== #
123
+ def self.path_to_the_english_file?
124
+ Dictionaries.main_file?
125
+ end
126
+
127
+ # =========================================================================== #
128
+ # === Dictionaries.n_entries?
129
+ # =========================================================================== #
130
+ def self.n_entries?
131
+ ::Dictionaries::AskEnglishWord.n_entries?
132
+ end
133
+
134
+ end
135
+
136
+ if __FILE__ == $PROGRAM_NAME
137
+ Dictionaries::AskEnglishWord.new(ARGV)
138
+ end # askeng
139
+ # This is the delay to use for this class.
140
+ __END__
141
+ 1.8
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # =========================================================================== #
4
+ # === Dictionaries::AskItalianWord
5
+ # =========================================================================== #
6
+ require 'dictionaries/class/ask_word_from_dictionary.rb'
7
+
8
+ module Dictionaries
9
+
10
+ class AskItalianWord < AskWordFromDictionary
11
+
12
+ # ========================================================================= #
13
+ # === DATA
14
+ # ========================================================================= #
15
+ if defined?(DATA) == 'constant'
16
+ if DATA.respond_to? :read
17
+ _ = DATA.read
18
+ else
19
+ e 'DATA does not respond to :read'
20
+ end
21
+ else
22
+ _ = ''
23
+ end
24
+ if _.to_s.empty? # Next, define the default delay.
25
+ DEFAULT_DELAY = 2.6 # How long to wait before asking a question.
26
+ else
27
+ _ = _.first if _.is_a? Array
28
+ DEFAULT_DELAY = _.strip.to_f
29
+ end
30
+
31
+ # ========================================================================= #
32
+ # === THIS_FILE
33
+ # ========================================================================= #
34
+ THIS_FILE = THIS_FILE_HERE = __FILE__.to_s
35
+
36
+ unless ENV['DICTIONARIES_FILE'] and File.exist?(ENV['DICTIONARIES_FILE'])
37
+ Dictionaries.set_main_file(THIS_FILE)
38
+ end
39
+
40
+ # ========================================================================= #
41
+ # === AskItalianWord.main_file?
42
+ # ========================================================================= #
43
+ def self.main_file?
44
+ Dictionaries.main_file?
45
+ end
46
+
47
+ # ========================================================================= #
48
+ # === AskItalianWord.dataset?
49
+ # ========================================================================= #
50
+ def self.dataset?
51
+ YAML.load_file(self.main_file?)
52
+ end
53
+
54
+ # ========================================================================= #
55
+ # === initialize
56
+ # ========================================================================= #
57
+ def initialize(commandline_arguments = ARGV)
58
+ super(commandline_arguments, self.class.main_file?)
59
+ end
60
+
61
+ # ========================================================================= #
62
+ # === AskItalianWord[]
63
+ # ========================================================================= #
64
+ def self.[](i)
65
+ self.new(i)
66
+ end
67
+
68
+ end
69
+
70
+ # =========================================================================== #
71
+ # === Dictionaries.ask_italian_word
72
+ # =========================================================================== #
73
+ def self.ask_italian_word
74
+ AskItalianWord.new
75
+ end
76
+
77
+ end
78
+
79
+ if __FILE__ == $PROGRAM_NAME
80
+ Dictionaries::AskItalianWord.new(ARGV)
81
+ end # askita
82
+ # This is the delay to use for this class.
83
+ __END__
84
+ 2.2