dictionaries 0.3.70

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.

Potentially problematic release.


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

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/gtk3/dictionary/dictionary.rb +457 -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/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 +3157 -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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f8c82e01cc298a8ace05f188c2b9d3d42641ab9e3e29b086229ae29f2e1826d2
4
+ data.tar.gz: d0d57f924c7acbe15bf0f22465b579aa1353109d4723ad3a12b9172efbad6875
5
+ SHA512:
6
+ metadata.gz: ad9b03b32e7645e897808ae2f8ec2736154bf24c3bb8f35db370e139717607f2de8d6a744dc1f9a739d10381d2c85bda6be518e7ed9d8e9c2b8efc942a132e63
7
+ data.tar.gz: 173a60087bb769c3e5d291a18e103858350b2d071b24532e3fb4e53e2c17b95e234ee5faa68ebeed4aebd5f640ef48fe1b5756001ec00dc56573231f86c645f2
data/README.md ADDED
@@ -0,0 +1,354 @@
1
+ [![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://www.gobolinux.org/)
2
+ [![forthebadge](https://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">02.12.2023</span> (dd.mm.yyyy notation), at <span style="color: steelblue; font-weight: bold">13:56:45</span> o'clock.
6
+
7
+ ## Environment variable to use a specific yaml file
8
+
9
+ You can use an <b>environment variable</b> to denote the default
10
+ yaml file in use. This allows you to use your own yaml file
11
+ format, rather than the yaml files that are distributed with
12
+ this gem.
13
+
14
+ The name of that environment variable must be <b>DICTIONARIES_FILE</b>.
15
+ It shall point to your yaml file that holds the key-value pairs.
16
+
17
+ For example, if your file is at /opt/czech.yml, then
18
+ DICTIONARIES_FILE should point at that location.
19
+
20
+ In bash, this may be equivalent to:
21
+
22
+ export DICTIONARIES_FILE=/opt/czech.yml
23
+
24
+ Note that in the long run, the dictionaries gem could be extended
25
+ with these yaml files - or allow means to download these files
26
+ over the www. But before we can do so, let's aim for at the least
27
+ 100 words in such a file before we would consider distributing
28
+ it or offering means to distribute said file.
29
+
30
+ ## Difficult english sentences
31
+
32
+ English is not the most difficult language in the world, but when it
33
+ comes to proper pronounciation of words, english can be surprisingly
34
+ difficult.
35
+
36
+ This subsection may keep a listing of sentences that, for one reason
37
+ or the other, can be somewhat difficult to **read out aloud** without
38
+ mistake, on a first try. It is just a fun-subsection, not meant to be
39
+ taken too seriously; and it is quite subjective.
40
+
41
+ Without any further ado, here comes a listing of sentences that may
42
+ be difficult to pronounce properly so:
43
+
44
+ I would like to distribute something.
45
+
46
+ ## Obtaining all translations into german for a given english word
47
+
48
+ Since as of **November 2020** the following API exists:
49
+
50
+ Dictionaries.return_array_of_translated_words_from_online_leo('cat')
51
+ Dictionaries.return_array_of_translated_words_from_online_leo('dog')
52
+ Dictionaries.return_array_of_translated_words_from_online_leo('human')
53
+
54
+ This will return an Array of german names. It does not work 100% perfectly
55
+ as it is based on a regex; and using a regex to parse HTML is never a
56
+ trivial way. But if you just want to get the first entry, just call
57
+ .first on it, and in most cases this is the best, most likely
58
+ translation available.
59
+
60
+ The regex has to find matches to entries such as the following one:
61
+
62
+ </repr><words><word>der Jazzfan</word></words>
63
+
64
+ Anyone to come up with a more accurate regex is welcome to share it. :)
65
+
66
+ This functionality was specifically necessary because I needed to
67
+ use this in the ruby-gtk bindings for this project.
68
+
69
+ ## Dictionaries.return_unique_words_from_this_file
70
+
71
+ This method will return all words that are presently not registered
72
+ in the english dictionary.
73
+
74
+ The idea here is for me to slowly add more english words into the
75
+ yaml file. I won't add every english word that exists, but I will
76
+ try to aim for a seizable number in the long run, such as
77
+ 5000 english words - already halfway there. \o/
78
+
79
+ ## GUI component
80
+
81
+ The **GUI component** of the dictionaries gem defaults to
82
+ **GTK3** finally. It is not a very advanced GUI, though.
83
+
84
+ First, install the gtk3 gem:
85
+
86
+ gem install gtk3
87
+
88
+ Then install the gtk_paradise project:
89
+
90
+ gem install gtk_paradise
91
+
92
+ Now you should be able to start the GUI component if the above
93
+ has worked:
94
+
95
+ dictionaries --gui
96
+
97
+ See also the help options.
98
+
99
+ dictionaries --help
100
+
101
+ You may need to install some .h files if you use a specific
102
+ Linux distribution; look at the relevant -dev packages for
103
+ this. Or just compile from source. :)
104
+
105
+ The current version of ruby-gtk3 in October 2021 looks like
106
+ this:
107
+
108
+ <img src="https://i.imgur.com/K430Kae.png" style="margin-left: 2em">
109
+
110
+ Yes, this isn't very pretty; I just wanted to focus a bit on
111
+ the functionality. Tons of things are missing, such as
112
+ switching to other .yml files from within the GUI itself.
113
+ I just wanted to showcase a demo - the convert from
114
+ english-to-german functionality is working, though, so
115
+ the GUI is functional, even if not super-pretty.
116
+
117
+ In **February 2022** this was improved a little bit. It's still
118
+ not extremely pretty, but you can see a few small improvements.
119
+ In the long run I will add functionality to switch between
120
+ different .yml files (thus, different dictionaries, such as
121
+ english, italian and so forth) - but it is a hobby project.
122
+ I won't have enough time to add all dictionaries into this
123
+ project as-is. I will, however had, add the possibility to
124
+ load custom .yml files and other formats in the long run,
125
+ so others can adapt the project to suit their needs.
126
+
127
+ <img src="https://i.imgur.com/ChFJmfo.png" style="margin-left: 2em">
128
+
129
+ ## sinatra
130
+
131
+ To start the sinatra interface of the dictionaries gem, do:
132
+
133
+ dictionaries --sinatra
134
+
135
+ You can then visit it on the localhost and it may look like
136
+ this:
137
+
138
+ <img src="https://i.imgur.com/uhzbXZ1.png" style="margin: 0.5em; margin-left: 2em">
139
+
140
+ You can then input an english word into the form, or the
141
+ URL area in your browser. If this word is registered in
142
+ the .yml file then the following result can be seen:
143
+
144
+ <img src="https://i.imgur.com/i1RqRmr.png" style="margin: 0.5em; margin-left: 2em">
145
+
146
+ This is really just very basic - I wanted to show the
147
+ functionality. You may have to adapt the code if you
148
+ have a more realistic use case, so consider the images
149
+ above just as examples of how this <b>could</b> be
150
+ used in a website.
151
+
152
+ ## Generating a .pdf file containing the translations
153
+
154
+ Since as of <b>July 2022</b> you can generate a .pdf file
155
+ with all the translated words. This functionality depends
156
+ on the <b>prawn</b> gem right now, so make sure that
157
+ this gem is installed before invoking the ruby code
158
+ that generates the .pdf file.
159
+
160
+ The toplevel API for creating the .pdf file is as follows:
161
+
162
+ Dictionaries.generate_pdf_file
163
+
164
+ ## Statistical information
165
+
166
+ On the <b>24.01.2023</b>, the Statistics submodule was
167
+ added towards module Dictionaries. The purpose of that
168
+ submodule is to simply display some information about
169
+ the project - in particular how many words are kept in
170
+ each individual .yml file (the yaml file that contains
171
+ all words in a given language).
172
+
173
+ For instance, on that day, the dictionaries gem contains
174
+ these word-translations in total:
175
+
176
+ chinese 15 words.
177
+ danish 1 words.
178
+ dutch 1 words.
179
+ english 2489 words.
180
+ farsi 4 words.
181
+ finnish 2 words.
182
+ italian 191 words.
183
+ japanese 2 words.
184
+ norwegian 5 words.
185
+ russian 3 words.
186
+ spanish 23 words.
187
+ swedish 1 words.
188
+
189
+ Expect more to be added over the coming months and years. As
190
+ can be seen english is the primary focus for this project,
191
+ in particular english-to-german and german-to-english.
192
+
193
+ Right now I am adding new entries manually for the most part,
194
+ but at a later point in time I may simply parse an existing
195
+ dictionary and then begin to add the missing entries more
196
+ systematically. Stay tuned for more information in this
197
+ regard in the future.
198
+
199
+ Since as of <b>May 2023</b> it is now possible to show how
200
+ many words are available per language file.
201
+
202
+ Use the following commandline invocation for this:
203
+
204
+ dictionaries --stats
205
+ dictionaries --statistics # both variants work
206
+
207
+ In <b>May 2023</b> the statistics were as follows:
208
+
209
+ chinese 15 words.
210
+ danish 1 words.
211
+ dutch 1 words.
212
+ english 2607 words.
213
+ farsi 4 words.
214
+ finnish 2 words.
215
+ italian 206 words.
216
+ japanese 2 words.
217
+ norwegian 5 words.
218
+ polish 1 words.
219
+ russian 3 words.
220
+ spanish 31 words.
221
+ swedish 1 words.
222
+
223
+ I may add to the above listing every some year or so, to
224
+ show how the project grows - and, also, in the event
225
+ that someone else may want to take over eventually.
226
+
227
+ ## Standalone .html example
228
+
229
+ Since as of August 2023 there is a small example file under
230
+ test/, to show how the dictionary could be used on a webpage:
231
+
232
+ <img src="https://i.imgur.com/XgN6CTD.png">
233
+
234
+ Note that the word-list, in JavaScript, is auto-generated from ruby,
235
+ but not updated regularly. So this is more a proof of concept
236
+ as-is. In the long run functionality will be added to the
237
+ dictionaries gem to allow users to embed the javascript-hash
238
+ into a webpage. Dictionaries for everyone! \o/
239
+
240
+ ## Why are there so few words registered in the dictionaries gem?
241
+
242
+ In August 2023, almost 3000 german-to-english words are registered
243
+ in the dictionaries gem. This is not a whole lot of words.
244
+
245
+ The main reason for this is that I manually add new entries, so
246
+ that takes time. I thus focus on my own use case.
247
+
248
+ However had, as I also want to make the dictionaries gem more
249
+ useful to other folks, I may begin to programmatically convert
250
+ entries, such as in the ding-dictionary, and integrate it into
251
+ the dictionaries gem. But for now this has to come at a later
252
+ time. This subsection was written in the event that people
253
+ are confused why there are so few words registered in this
254
+ project.
255
+
256
+ ## SpellChecker
257
+
258
+ A new class was added in November 2023. This class can be used
259
+ to "spell check" against the distributed .yml file for english
260
+ words (to german).
261
+
262
+ This class can be found here:
263
+
264
+ require 'dictionaries/spell_checker/spell_checker.rb'
265
+ Dictionaries::SpellChecker.new(ARGV)
266
+
267
+ It is currently unfinished. In the long run I plan to have
268
+ this class support all entries in the distributed .yml file,
269
+ but this will probably take a few years, considering how
270
+ slow I am in regards to this project here. Nonetheless, others
271
+ can then expand on this functionality, such as by subclassing
272
+ class Dictionaries::SpellChecker eventually.
273
+
274
+ You can also add words that have to be ignored, into a file
275
+ called <b>IGNORE_THESE_WORDS.md</b> - which is treated as a
276
+ YAML file by class Dictionaries::SpellChecker. It has to
277
+ exist in the current working directory. If it does exist,
278
+ then it will be loaded and each entry there will become
279
+ a word that will be ignored by class Dictionaries::Spellchecker.
280
+
281
+ ## Licence
282
+
283
+ Until the 17th of October 2019, this project was using the **GPLv2
284
+ licence** (no later clause).
285
+
286
+ However had, I believe that the GPLv2 licence is not great for
287
+ a project that focuses on existing words in **real languages**,
288
+ aka dictionaries. Thus, I have decided to change the licence into
289
+ the **MIT licence** on that day (**17.11.2019**, in dd.mm.yyyy notation).
290
+
291
+ So the gem is now MIT licenced. There may be dragons! \o/
292
+
293
+ For a description of that licence, see
294
+ https://opensource.org/licenses/MIT.
295
+
296
+
297
+ ## Contact information and mandatory 2FA (no longer) coming up in 2022 / 2023
298
+
299
+ If your creative mind has ideas and specific suggestions to make this gem
300
+ more useful in general, feel free to drop me an email at any time, via:
301
+
302
+ shevy@inbox.lt
303
+
304
+ Before that email I used an email account at Google gmail, but in **2021** I
305
+ decided to slowly abandon gmail, for various reasons. In order to limit the
306
+ explanation here, allow me to just briefly state that I do not feel as if I
307
+ want to promote any Google service anymore when the user becomes the end
308
+ product (such as via data collection by upstream services, including other
309
+ proxy-services). My feeling is that this is a hugely flawed business model
310
+ to begin with, and I no longer wish to support this in any way, even if
311
+ only indirectly so, such as by using services of companies that try to
312
+ promote this flawed model.
313
+
314
+ In regards to responding to emails: please keep in mind that responding
315
+ may take some time, depending on the amount of work I may have at that
316
+ moment. So it is not that emails are ignored; it is more that I have not
317
+ (yet) found the time to read and reply. This means there may be a delay
318
+ of days, weeks and in some instances also months. There is, unfortunately,
319
+ not much I can do when I need to prioritise my time investment, but I try
320
+ to consider <b>all</b> feedback as an opportunity to improve my projects
321
+ nonetheless.
322
+
323
+ In <b>2022</b> rubygems.org decided to make 2FA mandatory for every
324
+ gem owner eventually:
325
+
326
+ see
327
+ https://blog.rubygems.org/2022/06/13/making-packages-more-secure.html
328
+
329
+ Mandatory 2FA will eventually be extended to all rubygems.org developers and
330
+ maintainers. As I can not use 2FA, for reasons I will skip explaining here,
331
+ this means that my projects will eventually be removed, as I no longer
332
+ have any control over my projects hosted on rubygems.org (because I
333
+ can not use 2FA).
334
+
335
+ At that point, I no longer have any control what is done to my projects
336
+ since whoever is controlling the gems ecosystem took away our control
337
+ here. I am not sure at which point ruby became corporate-controlled -
338
+ that was not the case several years ago, so something has
339
+ changed.
340
+
341
+ Ruby also only allows 2FA users to participate on the issue tracker these
342
+ days:
343
+
344
+ https://bugs.ruby-lang.org/issues/18800
345
+
346
+ But this has been reverted some months ago, so it is no longer applicable.
347
+ Suffice to say that I do not think that we should only be allowed to
348
+ interact on the world wide web when some 'authority' authenticated us,
349
+ such as via mandatory 2FA, so I hope this won't come back again.
350
+
351
+ Fighting spam is a noble goal, but when it also means you lock out
352
+ real human people then this is definitely NOT a good situation
353
+ to be had.
354
+
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,84 @@
1
+ # =========================================================================== #
2
+ # Gemspec for Project Dictionaries.
3
+ # =========================================================================== #
4
+ require 'dictionaries/version/version.rb'
5
+ require 'roebe/toplevel_methods/misc.rb'
6
+ require 'dictionaries/ask_english_word.rb'
7
+
8
+ Gem::Specification.new { |s|
9
+
10
+ s.name = 'dictionaries'
11
+ s.version = Dictionaries::VERSION
12
+ s.date = Time.now.strftime('%Y-%m-%d')
13
+
14
+ DESCRIPTION = <<-EOF
15
+
16
+ This project is called dictionaries.
17
+
18
+ It used to be called ask_english_words but the name was changed towards
19
+ "dictionaries", when the focus became on dictionaries in general rather
20
+ than merely translations from and to the english language.
21
+
22
+ There are a total of #{Dictionaries.n_entries?} english words
23
+ registered, with the associated german translation. (It is
24
+ german primarily because that is my native language, but in
25
+ principle this project could be extended to include other
26
+ languages as well. You only need to add a yaml file containing
27
+ the key-value pairs.)
28
+
29
+ If you need a more comprehensive dictionary, I can recommend
30
+ the file de-en.txt that is part of the tu-chemnitz
31
+ distribution ( https://www-user.tu-chemnitz.de/~fri/ding/ ). That
32
+ file is really huge - about 20 MB.
33
+
34
+ In principle, the dictionaries project could be extended to
35
+ make use of that massive file instead. I will be thinking
36
+ about this for the time being (starting at July 2018).
37
+
38
+ EOF
39
+
40
+ s.summary = DESCRIPTION
41
+ s.description = DESCRIPTION
42
+
43
+ # ========================================================================= #
44
+ # Show this message when a user installs this project.
45
+ # ========================================================================= #
46
+ s.post_install_message = <<-EOF
47
+
48
+ This project can ask or translate english or italian words (or words
49
+ from any other language, as long as a .yml file is supplied that
50
+ contains these key-value pair entries).
51
+
52
+ This project is probably not very useful for other people, but it helps
53
+ me to improve my knowledge about the english or italian language or
54
+ any other language.
55
+
56
+ For more information, have a look at the main README.md file, which
57
+ can also be found on the hompage of this gem at rubygems.org, on
58
+ the bottom right side (see https://www.rubydoc.info/gems/dictionaries/ ).
59
+
60
+ EOF
61
+
62
+ s.authors = ['Robert A. Heiler']
63
+ s.email = Roebe.email?
64
+ s.files = Dir['**/*']
65
+ # s.files << 'README.md'
66
+ # s.files << 'USAGE.md'
67
+ s.license = 'MIT'
68
+ s.homepage = 'https://www.rubydoc.info/gems/dictionaries/'
69
+
70
+ s.required_ruby_version = '>= '+Roebe.third_most_stable_version_of_ruby
71
+ s.required_rubygems_version = '>= '+Gem::VERSION
72
+ s.rubygems_version = '>= '+Gem::VERSION
73
+
74
+ # ========================================================================= #
75
+ # External dependencies for the project:
76
+ # ========================================================================= #
77
+ s.add_dependency 'colours'
78
+ s.add_dependency 'generate_shell_completion'
79
+ s.add_dependency 'opn'
80
+ s.add_dependency 'open'
81
+ s.add_dependency 'save_file'
82
+ s.add_dependency 'xorg_buffer'
83
+
84
+ }