dictionaries 0.3.7

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 +219 -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 +176 -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/project/project_base_directory.rb +22 -0
  20. data/lib/dictionaries/project/project_yaml_directory.rb +25 -0
  21. data/lib/dictionaries/require_project/require_project.rb +11 -0
  22. data/lib/dictionaries/sinatra/app.rb +105 -0
  23. data/lib/dictionaries/sinatra/english_to_german.rb +88 -0
  24. data/lib/dictionaries/toplevel_methods/e.rb +16 -0
  25. data/lib/dictionaries/toplevel_methods/english_to_german.rb +31 -0
  26. data/lib/dictionaries/toplevel_methods/has_key.rb +32 -0
  27. data/lib/dictionaries/toplevel_methods/is_on_roebe.rb +16 -0
  28. data/lib/dictionaries/toplevel_methods/main_file.rb +88 -0
  29. data/lib/dictionaries/toplevel_methods/misc.rb +185 -0
  30. data/lib/dictionaries/toplevel_methods/module_methods.rb +9 -0
  31. data/lib/dictionaries/toplevel_methods/show_help.rb +31 -0
  32. data/lib/dictionaries/version/version.rb +17 -0
  33. data/lib/dictionaries/yaml/chinese.yml +21 -0
  34. data/lib/dictionaries/yaml/danish.yml +4 -0
  35. data/lib/dictionaries/yaml/deutsche_fremdwoerter.yml +1 -0
  36. data/lib/dictionaries/yaml/dutch.yml +3 -0
  37. data/lib/dictionaries/yaml/english.yml +2537 -0
  38. data/lib/dictionaries/yaml/farsi.yml +8 -0
  39. data/lib/dictionaries/yaml/finnish.yml +2 -0
  40. data/lib/dictionaries/yaml/italian.yml +504 -0
  41. data/lib/dictionaries/yaml/japanese.yml +15 -0
  42. data/lib/dictionaries/yaml/norwegian.yml +26 -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
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ module Dictionaries
6
+
7
+ class AskWordFromDictionary
8
+
9
+ begin
10
+ require 'colours'
11
+ rescue LoadError; end
12
+
13
+ # ========================================================================= #
14
+ # === green
15
+ # ========================================================================= #
16
+ def green
17
+ Colours::GREEN
18
+ end
19
+
20
+ # ========================================================================= #
21
+ # === brown
22
+ # ========================================================================= #
23
+ def brown(i = '')
24
+ "#{Colours::BROWN}#{i}#{Colours.revert}"
25
+ end
26
+
27
+ # ========================================================================= #
28
+ # === sfancy
29
+ # ========================================================================= #
30
+ def sfancy(i)
31
+ ::Colours.sfancy(i)
32
+ end
33
+
34
+ # ========================================================================= #
35
+ # === simp
36
+ # ========================================================================= #
37
+ def simp(i)
38
+ ::Colours.simp(i)
39
+ end; alias simportant simp # === simportant
40
+
41
+ # ========================================================================= #
42
+ # === sfile
43
+ # ========================================================================= #
44
+ def sfile(i)
45
+ ::Colours.sfile(i)
46
+ end
47
+
48
+ # ========================================================================= #
49
+ # === sdir
50
+ # ========================================================================= #
51
+ def sdir(i)
52
+ ::Colours.sdir(i)
53
+ end
54
+
55
+ end; end
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'dictionaries/class/constants.rb'
6
+ # =========================================================================== #
7
+ module Dictionaries
8
+
9
+ class AskWordFromDictionary
10
+
11
+ # ========================================================================= #
12
+ # === NAMESPACE
13
+ # ========================================================================= #
14
+ NAMESPACE = inspect
15
+
16
+ end; end
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'dictionaries/class/set_search_for_this_word.rb'
6
+ # =========================================================================== #
7
+ module Dictionaries
8
+
9
+ class AskWordFromDictionary
10
+
11
+ # ========================================================================= #
12
+ # === set_search_for_this_word (menu tag)
13
+ #
14
+ # This method will also have the menu-functionality of the class.
15
+ # ========================================================================= #
16
+ def set_search_for_this_word(i = :rand)
17
+ i = i.join(' ').strip if i.is_a? Array # This will also handle empty ARGV passed to us.
18
+ i = :rand if i.nil?
19
+ case i
20
+ when :rand, 'rand' # We want a random word here.
21
+ i = return_random_word if @words
22
+ end
23
+ # ======================================================================= #
24
+ # We want a String past this point.
25
+ # ======================================================================= #
26
+ i = i.to_s.dup
27
+ # ======================================================================= #
28
+ # We can not downcase the input since we also try to have it match
29
+ # towards regular english letters. It is a dictionary after all.
30
+ # ======================================================================= #
31
+ # === Chop off last char if it is a question mark.
32
+ # ======================================================================= #
33
+ i.chop! if i.end_with? '?'
34
+ case i # case tag
35
+ # ======================================================================= #
36
+ # === askeng --delay?
37
+ # ======================================================================= #
38
+ when /^-?-?delay\??$/i
39
+ feedback_delay
40
+ # ======================================================================= #
41
+ # === askeng --openall
42
+ # ======================================================================= #
43
+ when 'OPEN',
44
+ 'OPE',
45
+ 'OP',
46
+ 'O',
47
+ 'EDIT',
48
+ 'OPEN_ALL',
49
+ /open/,
50
+ 'OPENALL',
51
+ '--openall'
52
+ open_this_file_here(true) # true for "be verbose".
53
+ open_yaml_file_in_main_editor
54
+ exit
55
+ # ======================================================================= #
56
+ # === askeng --n-entries
57
+ # ======================================================================= #
58
+ when 'TOTAL',
59
+ 'KEYS',
60
+ 'KEYSTATS',
61
+ '--n-entries',
62
+ '--nentries',
63
+ 'keys?',
64
+ 'nkeys',
65
+ /-?-?nwords\??/
66
+ feedback_total_amount_of_keys
67
+ # ======================================================================= #
68
+ # === askeng --stats
69
+ # ======================================================================= #
70
+ when '--stats','--statistics','STATS','STATISTICS','STATS?','--stats?'
71
+ feedback_statistics; exit
72
+ # ======================================================================= #
73
+ # === askeng --help
74
+ # ======================================================================= #
75
+ when 'HELP','--help','show_help','--HELP'
76
+ feedback_help_options # This will also exit.
77
+ # ======================================================================= #
78
+ # === askeng --every_word
79
+ # ======================================================================= #
80
+ when 'SHOW',
81
+ '--show-every-word',
82
+ '--every_word'
83
+ show_every_word
84
+ exit
85
+ # ======================================================================= #
86
+ # === askeng --generate-tab
87
+ # ======================================================================= #
88
+ when 'GENERATE',
89
+ 'TAB',
90
+ 'GENERATE_COMPLETION',
91
+ 'TABCOMPLETION',
92
+ 'COMPLETION',
93
+ '--generate-tab'
94
+ generate_tab_completion
95
+ exit
96
+ # ======================================================================= #
97
+ # === askeng --open-in-browser
98
+ # ======================================================================= #
99
+ when 'OPEN_BROWSER','--open-in-browser'
100
+ open_in_browser
101
+ # ======================================================================= #
102
+ # === askeng --solved
103
+ # ======================================================================= #
104
+ when 'SOLVED',/-?-?solved/
105
+ set_last_word_solved
106
+ # ======================================================================= #
107
+ # === askeng --yaml-file?
108
+ # ======================================================================= #
109
+ when 'FILE?',
110
+ 'YAML_FILE?','--yaml-file?'
111
+ feedback_yaml_file
112
+ exit
113
+ # ======================================================================= #
114
+ # === askeng --open-dictionary
115
+ # ======================================================================= #
116
+ when 'OPEN_DICTIONARY','OPEN_DICT','--open-dictionary'
117
+ open_main_yaml_file_in_main_editor
118
+ exit
119
+ # ======================================================================= #
120
+ # === askeng --repeat
121
+ # ======================================================================= #
122
+ when 'REPEAT','--repeat'
123
+ _ = STORE_LAST_QUESTION_ASKED_HERE
124
+ if File.exist? _
125
+ i = File.read(_)
126
+ else
127
+ opnn; e 'The file `'+sfile(_)+'` was not found, thus we can'
128
+ opnn; e 'not read in anything.'
129
+ exit
130
+ end
131
+ # ======================================================================= #
132
+ # === askeng --url
133
+ # ======================================================================= #
134
+ when '--url','URL'
135
+ feedback_url
136
+ # ======================================================================= #
137
+ # === askeng --random
138
+ # ======================================================================= #
139
+ when /^-?-?random$/i,'RAND','rand' # Pass through here.
140
+ i = return_random_word if available_keys?
141
+ # else tag
142
+ else # Handle assignment cases next.
143
+ if i.include?('=') and i.downcase.include? 'delay'
144
+ new_delay = i.split('=').last.strip
145
+ e 'It seems as if you may want to assign a new delay.'
146
+ e 'We will thus set the last line of this file here'
147
+ e 'with the new delay of:'
148
+ e ' '+sfancy(new_delay)
149
+ what = File.readlines(Dictionaries::AskEnglishWord.main_file?)
150
+ what[-1,1] = new_delay # Set the new entry here.
151
+ SaveFile.write_what_into(what.join, Dictionaries::AskEnglishWord.main_file?)
152
+ exit
153
+ end
154
+ end
155
+ i = i.to_s.dup
156
+ i = i.downcase if SHALL_WE_DOWNCASE
157
+ if i.size == 1 # We assume that the user wants to get a category.
158
+ i = find_all_matches_for(i).sample
159
+ end
160
+ @search_for_this_word = i # We will search for this word here.
161
+ end
162
+
163
+ end; end
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'dictionaries/commandline/parse_commandline.rb'
6
+ # =========================================================================== #
7
+ module Dictionaries
8
+
9
+ require 'dictionaries/toplevel_methods/show_help.rb'
10
+ require 'dictionaries/class/ask_word_from_dictionary.rb'
11
+
12
+ # ========================================================================= #
13
+ # === Dictionaries.start_gtk_component
14
+ #
15
+ # This module-method will start the GTK component.
16
+ # ========================================================================= #
17
+ def self.start_gtk_component
18
+ require 'dictionaries/gui/gtk3/dictionary/dictionary.rb'
19
+ Dictionaries::GUI::Gtk::Dictionary.run
20
+ end
21
+
22
+ # ========================================================================= #
23
+ # === Dictionaries.parse_commandline
24
+ # ========================================================================= #
25
+ def self.parse_commandline(
26
+ i = ARGV
27
+ )
28
+ if i.is_a? Array
29
+ i.each {|entry| parse_commandline(entry) }
30
+ else
31
+ case i # case tag
32
+ # ===================================================================== #
33
+ # === dictionaries --read=www.nytimes.com.html
34
+ # ===================================================================== #
35
+ when /^-?-?read=(.+)$/i
36
+ _ = $1.to_s.dup
37
+ require 'dictionaries/toplevel_methods/misc.rb'
38
+ if File.exist? _
39
+ e 'Finding unique words ... this may take a while. Please be'
40
+ e 'patient.'
41
+ unique_words = ::Dictionaries.return_unique_words_from_this_file(_, :default, :remove_HTML_tags).sort
42
+ pp unique_words
43
+ e 'n entries: '+unique_words.size.to_s
44
+ else
45
+ e 'No file exists at '+sfile(_)+'.'
46
+ end
47
+ # ===================================================================== #
48
+ # === dictionaries --gui
49
+ # ===================================================================== #
50
+ when /^-?-?gui$/i,
51
+ /^-?-?gtk$/i,
52
+ /^-?-?start(-|_)?gtk$/i
53
+ start_gtk_component
54
+ # ===================================================================== #
55
+ # === dictionaries --sinatra
56
+ # ===================================================================== #
57
+ when /^-?-?sinatra$/i
58
+ require 'dictionaries/sinatra/app.rb'
59
+ Dictionaries.start_sinatra_interface
60
+ # ===================================================================== #
61
+ # === dictionaries --n-words?
62
+ # ===================================================================== #
63
+ when /^-?-?n(_|-)?words\??$/i
64
+ e "#{Colours.sfancy(Dictionaries.n_entries?)} english-to-german "\
65
+ "translations are presently registered in this project."
66
+ # ===================================================================== #
67
+ # === dictionaries --help
68
+ # ===================================================================== #
69
+ when /help/
70
+ show_help
71
+ end
72
+ end
73
+ end
74
+
75
+ end
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'dictionaries/constants.rb'
6
+ # =========================================================================== #
7
+ module Dictionaries
8
+
9
+ require 'dictionaries/project/project_yaml_directory.rb'
10
+ require 'dictionaries/version/version.rb'
11
+
12
+ # ========================================================================= #
13
+ # === Dictionaries::N
14
+ # ========================================================================= #
15
+ N = "\n"
16
+
17
+ # ========================================================================= #
18
+ # === Dictionaries::URL_FOR_DICT_LEO
19
+ # ========================================================================= #
20
+ URL_FOR_DICT_LEO = 'http://dict.leo.org/'
21
+
22
+ # ========================================================================= #
23
+ # === URL_FOR_ITALIAN_DICTIONARY
24
+ # ========================================================================= #
25
+ URL_FOR_ITALIAN_DICTIONARY = 'http://www.wordreference.com/iten/'
26
+
27
+ # ========================================================================= #
28
+ # === LPAD
29
+ # ========================================================================= #
30
+ LPAD = ' '
31
+
32
+ # ========================================================================= #
33
+ # === RUBY_SRC
34
+ # ========================================================================= #
35
+ if ENV['RUBY_SRC']
36
+ RUBY_SRC = ENV['RUBY_SRC'].to_s.dup+'/'
37
+ else # else we just hardcode it anyway.
38
+ RUBY_SRC = '/Users/x/DATA/PROGRAMMING_LANGUAGES/RUBY/src/'
39
+ end
40
+
41
+ # ========================================================================= #
42
+ # === MY_DICTIONARIES
43
+ #
44
+ # This constant is only valid for my own system.
45
+ # ========================================================================= #
46
+ MY_DICTIONARIES = RUBY_SRC+'dictionaries/lib/dictionaries/yaml/'
47
+
48
+ # ========================================================================= #
49
+ # === SCIENCE_DIR
50
+ # ========================================================================= #
51
+ SCIENCE_DIR = ENV['SCIENCE'].to_s+'/'
52
+
53
+ # ========================================================================= #
54
+ # === DEPOT_INFORMATION_DIR
55
+ # ========================================================================= #
56
+ DEPOT_INFORMATION_DIR = '/Depot/Information/'
57
+
58
+ # ========================================================================= #
59
+ # === DICTIONARIES_DIR
60
+ #
61
+ # This constant will point at a path such as this one here:
62
+ #
63
+ # /Programs/Ruby/2.6.3/lib/ruby/site_ruby/2.6.0/dictionaries/yaml/
64
+ #
65
+ # ========================================================================= #
66
+ DICTIONARIES_DIR = Dictionaries.dictionary_directory?
67
+
68
+ # ========================================================================= #
69
+ # === ENGLISH_WORDS
70
+ #
71
+ # This constant is no longer that important because we can now
72
+ # automatically infer the name of the .yml file.
73
+ # ========================================================================= #
74
+ ENGLISH_WORDS = DICTIONARIES_DIR+'english.yml'
75
+ ENGLISH_YAML_FILE = ENGLISH_WORDS # === ENGLISH_YAML_FILE
76
+ FILE_ENGLISH_WORDS = ENGLISH_WORDS # === FILE_ENGLISH_WORDS
77
+ FILE_ENGLISH_DICTIONARY = ENGLISH_YAML_FILE
78
+
79
+ # ========================================================================= #
80
+ # === Dictionaries.file_english
81
+ # ========================================================================= #
82
+ def self.file_english
83
+ FILE_ENGLISH_DICTIONARY
84
+ end
85
+
86
+ # ========================================================================= #
87
+ # === ITALIAN_WORDS
88
+ #
89
+ # This constant is no longer that important because we can now
90
+ # automatically infer the name of the .yml file.
91
+ # ========================================================================= #
92
+ ITALIAN_WORDS = DICTIONARIES_DIR+'italian.yml'
93
+ ITALIAN_YAML_FILE = ITALIAN_WORDS
94
+ FILE_ITALIAN_DICTIONARY = ITALIAN_YAML_FILE
95
+
96
+ # ========================================================================= #
97
+ # === STORE_LINE_NUMBER_HERE
98
+ # ========================================================================= #
99
+ STORE_LINE_NUMBER_HERE = DEPOT_INFORMATION_DIR+'line_number_of_the_last_word'
100
+
101
+ # ========================================================================= #
102
+ # === STORE_LAST_ENGLISH_QUESTION_ASKED_HERE
103
+ # ========================================================================= #
104
+ STORE_LAST_ENGLISH_QUESTION_ASKED_HERE =
105
+ DEPOT_INFORMATION_DIR+'last_english_question_asked' # cat $MY_TEMP/last_english_question_asked
106
+
107
+ # ========================================================================= #
108
+ # === STORE_LAST_ITALIAN_QUESTION_ASKED_HERE
109
+ # ========================================================================= #
110
+ STORE_LAST_ITALIAN_QUESTION_ASKED_HERE =
111
+ DEPOT_INFORMATION_DIR+'last_italian_question_asked' # cat $MY_TEMP/last_italian_question_asked
112
+
113
+ # ========================================================================= #
114
+ # === SHALL_WE_DOWNCASE
115
+ # ========================================================================= #
116
+ SHALL_WE_DOWNCASE = true
117
+
118
+ # ========================================================================= #
119
+ # === USE_THIS_ENCODING
120
+ #
121
+ # This is the main encoding to use.
122
+ # ========================================================================= #
123
+ USE_THIS_ENCODING = 'ISO-8859-1'
124
+ MAIN_ENCODING = USE_THIS_ENCODING
125
+
126
+ # ========================================================================= #
127
+ # === DEFAULT_DELAY
128
+ #
129
+ # Specify how long to wait before revealing the translated word.
130
+ # ========================================================================= #
131
+ DEFAULT_DELAY = 1.6
132
+
133
+ end