dictionaries 0.3.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +354 -0
  3. data/bin/dictionaries +7 -0
  4. data/bin/unique_words_in_this_file +7 -0
  5. data/dictionaries.gemspec +84 -0
  6. data/doc/README.gen +292 -0
  7. data/doc/todo/todo.md +8 -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/base/base.rb +78 -0
  11. data/lib/dictionaries/class/class.rb +903 -0
  12. data/lib/dictionaries/commandline/parse_commandline.rb +85 -0
  13. data/lib/dictionaries/constants/constants.rb +134 -0
  14. data/lib/dictionaries/gui/tk/README.md +2 -0
  15. data/lib/dictionaries/gui/tk/dictionary.rb +85 -0
  16. data/lib/dictionaries/gui/universal_widgets/dictionary/dictionary.rb +516 -0
  17. data/lib/dictionaries/helper_module/helper_module.rb +60 -0
  18. data/lib/dictionaries/project/project.rb +36 -0
  19. data/lib/dictionaries/require_project/require_project.rb +14 -0
  20. data/lib/dictionaries/sinatra/app.rb +123 -0
  21. data/lib/dictionaries/sinatra/english_to_german.rb +84 -0
  22. data/lib/dictionaries/spell_checker/README.md +5 -0
  23. data/lib/dictionaries/spell_checker/spell_checker.rb +133 -0
  24. data/lib/dictionaries/statistics/statistics.rb +59 -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 +231 -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 +3263 -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/polish.yml +2 -0
  45. data/lib/dictionaries/yaml/portugese.yml +41 -0
  46. data/lib/dictionaries/yaml/russian.yml +10 -0
  47. data/lib/dictionaries/yaml/spanish.yml +147 -0
  48. data/lib/dictionaries/yaml/swedish.yml +104 -0
  49. data/lib/dictionaries.rb +1 -0
  50. data/test/translation_example.html +2758 -0
  51. metadata +211 -0
@@ -0,0 +1,85 @@
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/class.rb'
11
+ require 'dictionaries/statistics/statistics.rb'
12
+
13
+ # ========================================================================= #
14
+ # === Dictionaries.start_gtk_component
15
+ #
16
+ # This module-method will start the GTK component.
17
+ # ========================================================================= #
18
+ def self.start_gtk_component
19
+ require 'dictionaries/gui/gtk3/dictionary/dictionary.rb'
20
+ Dictionaries::GUI::Gtk::Dictionary.run
21
+ end
22
+
23
+ # ========================================================================= #
24
+ # === Dictionaries.parse_commandline
25
+ # ========================================================================= #
26
+ def self.parse_commandline(
27
+ i = ARGV
28
+ )
29
+ if i.is_a? Array
30
+ i.each {|entry| parse_commandline(entry) }
31
+ else
32
+ case i # case tag
33
+ # ===================================================================== #
34
+ # === dictionaries --stats
35
+ #
36
+ # This entry point allows the user to show some statistics about
37
+ # this project.
38
+ # ===================================================================== #
39
+ when /^-?-?stats\??$/i,
40
+ /^-?-?statistics\??$/i
41
+ Dictionaries::Statistics.report
42
+ # ===================================================================== #
43
+ # === dictionaries --read=www.nytimes.com.html
44
+ # ===================================================================== #
45
+ when /^-?-?read=(.+)$/i
46
+ _ = $1.to_s.dup
47
+ require 'dictionaries/toplevel_methods/misc.rb'
48
+ if File.exist? _
49
+ e 'Finding unique words ... this may take a while. Please be'
50
+ e 'patient.'
51
+ unique_words = ::Dictionaries.return_unique_words_from_this_file(_, :default, :remove_HTML_tags).sort
52
+ pp unique_words
53
+ e 'n entries: '+unique_words.size.to_s
54
+ else
55
+ e 'No file exists at '+sfile(_)+'.'
56
+ end
57
+ # ===================================================================== #
58
+ # === dictionaries --gui
59
+ # ===================================================================== #
60
+ when /^-?-?gui$/i,
61
+ /^-?-?gtk$/i,
62
+ /^-?-?start(-|_)?gtk$/i
63
+ start_gtk_component
64
+ # ===================================================================== #
65
+ # === dictionaries --sinatra
66
+ # ===================================================================== #
67
+ when /^-?-?sinatra$/i
68
+ require 'dictionaries/sinatra/app.rb'
69
+ Dictionaries.start_sinatra_interface
70
+ # ===================================================================== #
71
+ # === dictionaries --n-words?
72
+ # ===================================================================== #
73
+ when /^-?-?n(_|-)?words\??$/i
74
+ e "#{Colours.sfancy(Dictionaries.n_entries?)} english-to-german "\
75
+ "translations are presently registered in this project."
76
+ # ===================================================================== #
77
+ # === dictionaries --help
78
+ # ===================================================================== #
79
+ when /help/
80
+ show_help
81
+ end
82
+ end
83
+ end
84
+
85
+ end
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'dictionaries/constants/constants.rb'
6
+ # =========================================================================== #
7
+
8
+ module Dictionaries
9
+
10
+ require 'dictionaries/project/project.rb'
11
+ require 'dictionaries/version/version.rb'
12
+
13
+ # ========================================================================= #
14
+ # === Dictionaries::N
15
+ # ========================================================================= #
16
+ N = "\n"
17
+
18
+ # ========================================================================= #
19
+ # === Dictionaries::URL_FOR_DICT_LEO
20
+ # ========================================================================= #
21
+ URL_FOR_DICT_LEO = 'http://dict.leo.org/'
22
+
23
+ # ========================================================================= #
24
+ # === URL_FOR_ITALIAN_DICTIONARY
25
+ # ========================================================================= #
26
+ URL_FOR_ITALIAN_DICTIONARY = 'http://www.wordreference.com/iten/'
27
+
28
+ # ========================================================================= #
29
+ # === LPAD
30
+ # ========================================================================= #
31
+ LPAD = ' '
32
+
33
+ # ========================================================================= #
34
+ # === RUBY_SRC
35
+ # ========================================================================= #
36
+ if ENV['RUBY_SRC']
37
+ RUBY_SRC = ENV['RUBY_SRC'].to_s.dup+'/'
38
+ else # else we just hardcode it anyway.
39
+ RUBY_SRC = '/home/x/programming/ruby/src/'
40
+ end
41
+
42
+ # ========================================================================= #
43
+ # === MY_DICTIONARIES
44
+ #
45
+ # This constant is only valid for my own system.
46
+ # ========================================================================= #
47
+ MY_DICTIONARIES = "#{RUBY_SRC}dictionaries/lib/dictionaries/yaml/"
48
+
49
+ # ========================================================================= #
50
+ # === SCIENCE_DIR
51
+ # ========================================================================= #
52
+ SCIENCE_DIR = ENV['SCIENCE'].to_s+'/'
53
+
54
+ # ========================================================================= #
55
+ # === DEPOT_INFORMATION_DIR
56
+ # ========================================================================= #
57
+ DEPOT_INFORMATION_DIR = '/Depot/Information/'
58
+
59
+ # ========================================================================= #
60
+ # === DICTIONARIES_DIR
61
+ #
62
+ # This constant will point at a path such as this one here:
63
+ #
64
+ # /Programs/Ruby/2.6.3/lib/ruby/site_ruby/2.6.0/dictionaries/yaml/
65
+ #
66
+ # ========================================================================= #
67
+ DICTIONARIES_DIR = Dictionaries.dictionary_directory?
68
+
69
+ # ========================================================================= #
70
+ # === ENGLISH_WORDS
71
+ #
72
+ # This constant is no longer that important because we can now
73
+ # automatically infer the name of the .yml file.
74
+ # ========================================================================= #
75
+ ENGLISH_WORDS = DICTIONARIES_DIR+'english.yml'
76
+ ENGLISH_YAML_FILE = ENGLISH_WORDS # === ENGLISH_YAML_FILE
77
+ FILE_ENGLISH_WORDS = ENGLISH_WORDS # === FILE_ENGLISH_WORDS
78
+ FILE_ENGLISH_DICTIONARY = ENGLISH_YAML_FILE
79
+
80
+ # ========================================================================= #
81
+ # === Dictionaries.file_english
82
+ # ========================================================================= #
83
+ def self.file_english
84
+ FILE_ENGLISH_DICTIONARY
85
+ end; self.instance_eval { alias file_english? file_english } # === Dictionaries.file_english?
86
+
87
+ # ========================================================================= #
88
+ # === ITALIAN_WORDS
89
+ #
90
+ # This constant is no longer that important because we can now
91
+ # automatically infer the name of the .yml file.
92
+ # ========================================================================= #
93
+ ITALIAN_WORDS = DICTIONARIES_DIR+'italian.yml'
94
+ ITALIAN_YAML_FILE = ITALIAN_WORDS
95
+ FILE_ITALIAN_DICTIONARY = ITALIAN_YAML_FILE
96
+
97
+ # ========================================================================= #
98
+ # === STORE_LINE_NUMBER_HERE
99
+ # ========================================================================= #
100
+ STORE_LINE_NUMBER_HERE = DEPOT_INFORMATION_DIR+'line_number_of_the_last_word'
101
+
102
+ # ========================================================================= #
103
+ # === STORE_LAST_ENGLISH_QUESTION_ASKED_HERE
104
+ # ========================================================================= #
105
+ STORE_LAST_ENGLISH_QUESTION_ASKED_HERE =
106
+ DEPOT_INFORMATION_DIR+'last_english_question_asked' # cat $MY_TEMP/last_english_question_asked
107
+
108
+ # ========================================================================= #
109
+ # === STORE_LAST_ITALIAN_QUESTION_ASKED_HERE
110
+ # ========================================================================= #
111
+ STORE_LAST_ITALIAN_QUESTION_ASKED_HERE =
112
+ DEPOT_INFORMATION_DIR+'last_italian_question_asked' # cat $MY_TEMP/last_italian_question_asked
113
+
114
+ # ========================================================================= #
115
+ # === SHALL_WE_DOWNCASE
116
+ # ========================================================================= #
117
+ SHALL_WE_DOWNCASE = true
118
+
119
+ # ========================================================================= #
120
+ # === USE_THIS_ENCODING
121
+ #
122
+ # This is the main encoding to use.
123
+ # ========================================================================= #
124
+ USE_THIS_ENCODING = 'ISO-8859-1'
125
+ MAIN_ENCODING = USE_THIS_ENCODING
126
+
127
+ # ========================================================================= #
128
+ # === DEFAULT_DELAY
129
+ #
130
+ # Specify how long to wait before revealing the translated word.
131
+ # ========================================================================= #
132
+ DEFAULT_DELAY = 1.6
133
+
134
+ end
@@ -0,0 +1,2 @@
1
+ This directory includes experimental tk code. The main GUI is
2
+ ruby-gtk, so this is just a fallback.
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === Dictionaries::GUI::Tk::Dictionary
6
+ #
7
+ # This is a small TK-wrapper.
8
+ # =========================================================================== #
9
+ # require 'dictionaries/gui/tk/dictionary.rb'
10
+ # =========================================================================== #
11
+ begin
12
+ require 'tk'
13
+ rescue LoadError; end
14
+ require 'dictionaries/class/class.rb'
15
+ require 'dictionaries/toplevel_methods/e.rb'
16
+
17
+ module Dictionaries
18
+
19
+ module GUI
20
+
21
+ module Tk
22
+
23
+ class Dictionary < ::TkFrame # < Base === Dictionaries::GUI::Tk::Dictionary.new
24
+
25
+ include Colours::E
26
+
27
+ # ========================================================================= #
28
+ # === initialize
29
+ # ========================================================================= #
30
+ def initialize(
31
+ i = nil,
32
+ run_already = true
33
+ )
34
+ super()
35
+ reset
36
+ set_input(i)
37
+ title "TK wrapper for the Dictionaries project"
38
+ run if run_already
39
+ end
40
+
41
+ # ========================================================================= #
42
+ # === reset (reset tag)
43
+ # ========================================================================= #
44
+ def reset
45
+ end
46
+
47
+ # ========================================================================= #
48
+ # === set_input
49
+ # ========================================================================= #
50
+ def set_input(i = '')
51
+ i = i.first if i.is_a? Array
52
+ i = i.to_s.dup
53
+ @input = i
54
+ end
55
+
56
+ # ========================================================================= #
57
+ # === input?
58
+ # ========================================================================= #
59
+ def input?
60
+ @input
61
+ end
62
+
63
+ # ========================================================================= #
64
+ # === run (run tag)
65
+ # ========================================================================= #
66
+ def run
67
+ TkLabel.new(root) do
68
+ text 'Hello, World!'
69
+ pack { padx 15 ; pady 15; side 'left' }
70
+ end
71
+ end
72
+
73
+ # ========================================================================= #
74
+ # === Dictionaries::GUI:Tk::Dictionary[]
75
+ # ========================================================================= #
76
+ def self.[](i = '')
77
+ self.new(i)
78
+ end
79
+
80
+ end; end; end; end
81
+
82
+ if __FILE__ == $PROGRAM_NAME
83
+ Dictionaries::GUI:Tk::Dictionary.new(ARGV)
84
+ ::Tk.mainloop
85
+ end # dictionary.rb