dictionaries 0.3.24

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 (49) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +250 -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 +210 -0
  7. data/doc/todo/todo.md +5 -0
  8. data/lib/dictionaries/ask_english_word.rb +141 -0
  9. data/lib/dictionaries/ask_italian_word.rb +84 -0
  10. data/lib/dictionaries/class/ask_word_from_dictionary.rb +693 -0
  11. data/lib/dictionaries/class/colours.rb +55 -0
  12. data/lib/dictionaries/class/constants.rb +16 -0
  13. data/lib/dictionaries/class/set_search_for_this_word.rb +163 -0
  14. data/lib/dictionaries/commandline/parse_commandline.rb +75 -0
  15. data/lib/dictionaries/constants.rb +133 -0
  16. data/lib/dictionaries/gui/gtk3/dictionary/dictionary.rb +457 -0
  17. data/lib/dictionaries/gui/tk/README.md +2 -0
  18. data/lib/dictionaries/gui/tk/dictionary.rb +85 -0
  19. data/lib/dictionaries/helper_module/helper_module.rb +60 -0
  20. data/lib/dictionaries/project/project.rb +36 -0
  21. data/lib/dictionaries/require_project/require_project.rb +14 -0
  22. data/lib/dictionaries/sinatra/app.rb +118 -0
  23. data/lib/dictionaries/sinatra/english_to_german.rb +84 -0
  24. data/lib/dictionaries/statistics/statistics.rb +58 -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 +185 -0
  31. data/lib/dictionaries/toplevel_methods/module_methods.rb +9 -0
  32. data/lib/dictionaries/toplevel_methods/show_help.rb +31 -0
  33. data/lib/dictionaries/version/version.rb +19 -0
  34. data/lib/dictionaries/yaml/chinese.yml +25 -0
  35. data/lib/dictionaries/yaml/danish.yml +4 -0
  36. data/lib/dictionaries/yaml/deutsche_fremdw/303/266rter.yml +1 -0
  37. data/lib/dictionaries/yaml/dutch.yml +3 -0
  38. data/lib/dictionaries/yaml/english.yml +2661 -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 +532 -0
  42. data/lib/dictionaries/yaml/japanese.yml +15 -0
  43. data/lib/dictionaries/yaml/norwegian.yml +26 -0
  44. data/lib/dictionaries/yaml/portugese.yml +41 -0
  45. data/lib/dictionaries/yaml/russian.yml +10 -0
  46. data/lib/dictionaries/yaml/spanish.yml +133 -0
  47. data/lib/dictionaries/yaml/swedish.yml +104 -0
  48. data/lib/dictionaries.rb +1 -0
  49. metadata +209 -0
@@ -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