meiou 0.1.3 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -34
- data/books/Crystallizing_Public_Opinion.txt +4506 -5236
- data/books/Social_Organization.txt +11457 -13282
- data/books/interpretation_of_dreams.txt +20171 -22183
- data/books/the_prince.txt +4744 -5181
- data/lib/meiou/astronomy.rb +65 -0
- data/lib/meiou/book.rb +16 -11
- data/lib/meiou/dictionary.rb +20 -14
- data/lib/meiou/emoji.rb +21 -0
- data/lib/meiou/version.rb +1 -1
- data/lib/meiou/word.rb +14 -1
- data/lib/meiou.rb +8 -0
- data/meiou.gemspec +2 -0
- metadata +31 -2
- data/books/Increasing_Human_Efficiency_in_Business.txt +0 -8868
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'astronomy'
|
2
|
+
|
3
|
+
module ASTRO
|
4
|
+
|
5
|
+
@@ASTRO = Astronomy::Information.new
|
6
|
+
|
7
|
+
def self.search k
|
8
|
+
h = {}
|
9
|
+
@@ASTRO.search(k).each { |e| h[e["name"]] = e["description"] }
|
10
|
+
return h
|
11
|
+
end
|
12
|
+
|
13
|
+
@@C = Hash.new { |h,k| h[k] = @@ASTRO.topics(k) }
|
14
|
+
|
15
|
+
def self.[] k
|
16
|
+
@@C[k]
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.keys
|
20
|
+
@@C.keys
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.to_h
|
24
|
+
h = Hash.new { |h,k| h[k] = {} }
|
25
|
+
ASTRO.keys.each { |e| ASTRO[e].each { |ee| h[e][ee['name']] = ee["description"] } }
|
26
|
+
return h
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.to_a
|
30
|
+
a = []
|
31
|
+
ASTRO.to_h.each_pair { |k,v| v.each_pair { |kk,vv| a << vv } }
|
32
|
+
return a
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.to_s
|
36
|
+
ASTRO.to_a.join("\n\n")
|
37
|
+
end
|
38
|
+
|
39
|
+
@@ASTRO.categories.each { |e| @@C[e] }
|
40
|
+
|
41
|
+
def self.zodiac
|
42
|
+
[ :cancer,:leo,:capricorn,:gemini,:aquarius,:libra,:taurus,:aries,:pisces ]
|
43
|
+
end
|
44
|
+
def self.movements
|
45
|
+
[ :rising, :falling, 'at rest' ]
|
46
|
+
end
|
47
|
+
def self.signs
|
48
|
+
[ :sun, :moon ]
|
49
|
+
end
|
50
|
+
def self.orbits
|
51
|
+
[ "in retrograde", "in procession", "at equinox", "at perogy", "at apogy" ]
|
52
|
+
end
|
53
|
+
def self.alignments
|
54
|
+
[:parallel,:tangential,:perpendicular]
|
55
|
+
end
|
56
|
+
def self.planets
|
57
|
+
[:mercury,:venus,:mars,:vesta,:ceres,:jupiter,:saturn,:uranus,:neptune,:pluto]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
module Meiou
|
62
|
+
def self.astronomy
|
63
|
+
ASTRO
|
64
|
+
end
|
65
|
+
end
|
data/lib/meiou/book.rb
CHANGED
@@ -12,7 +12,10 @@ module BOOK
|
|
12
12
|
[ :tiny, :info, :short, :med, :long ]
|
13
13
|
end
|
14
14
|
def self.size? w
|
15
|
-
|
15
|
+
|
16
|
+
if w.length < BOOK.size[0]
|
17
|
+
s = :ignore
|
18
|
+
elsif w.length > BOOK.size[0] && w.length <= BOOK.size[1]
|
16
19
|
s = :tiny
|
17
20
|
elsif w.length > BOOK.size[1] && w.length <= BOOK.size[2]
|
18
21
|
s = :info
|
@@ -46,14 +49,16 @@ module BOOK
|
|
46
49
|
if !/Project Gutenberg/.match(x)
|
47
50
|
if !/^[[[:upper:]]|[[:blank:]]|[[:punct:]]|[[:digit:]]]*$/.match(x)
|
48
51
|
s = BOOK.size?(x.split(/\s/))
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
Meiou.log "compile load item", "[#{@id}][#{i}] #{s}"
|
53
|
+
if s != :ignore
|
54
|
+
@bin[s].transaction { |db| db[i] = x }
|
55
|
+
@ind.transaction { |db| db[i] = s }
|
56
|
+
@mod.transaction { |db| db[i] = MOOD[x] }
|
57
|
+
Meiou.extract(x) { |e| @tag.transaction { |db| if !db.key?(e[:word]); db[e[:word]] = []; end; db[e[:word]] << i; } }
|
58
|
+
end
|
54
59
|
else
|
55
60
|
if !/GUTENBERG/.match(x)
|
56
|
-
|
61
|
+
Meiou.log "compile load section", %[#{@id}>#{i}: #{x}]
|
57
62
|
@sec.transaction { |db| db[i] = x }
|
58
63
|
@top.transaction { |db| db[x] = i }
|
59
64
|
end
|
@@ -166,20 +171,20 @@ module BOOK
|
|
166
171
|
def self.init!
|
167
172
|
Dir['books/*'].each { |e|
|
168
173
|
k = e.gsub("books/", "").gsub(".txt", "").gsub("_", " ");
|
169
|
-
|
174
|
+
Meiou.log :init_scan, %[Scanning #{k}...]
|
170
175
|
@@BOOK[k]
|
171
176
|
}
|
172
|
-
|
177
|
+
Meiou.log :init_done, %[Books scanned!]
|
173
178
|
return "DONE!"
|
174
179
|
end
|
175
180
|
|
176
181
|
def self.compile!
|
177
182
|
Dir['books/*'].each { |e|
|
178
183
|
k = e.gsub("books/", "").gsub(".txt", "").gsub("_", " ");
|
179
|
-
|
184
|
+
Meiou.log :compile_load, %[#{k}...]
|
180
185
|
@@BOOK[k].load(e)
|
181
186
|
}
|
182
|
-
|
187
|
+
Meiou.log :compile_done, %[done!]
|
183
188
|
return "DONE!"
|
184
189
|
end
|
185
190
|
end
|
data/lib/meiou/dictionary.rb
CHANGED
@@ -3,14 +3,19 @@ require 'tokenizer'
|
|
3
3
|
module DICT
|
4
4
|
# extract a list of tokens from +payload+ and handle with block passing +index+ and +WORD[word]+.
|
5
5
|
def self.[] k
|
6
|
-
DICT.
|
6
|
+
DICT.know(k, define: true, example: true )
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def self.know input, h={}
|
10
|
-
a = []
|
11
|
-
DICT
|
10
|
+
a = []
|
11
|
+
DICT.keywords(input).each { |e|
|
12
|
+
w = WORD[e]
|
12
13
|
if h[:define] == true
|
13
|
-
|
14
|
+
if w[:def].length > 0
|
15
|
+
a << %[#{w[:word].capitalize} means #{w[:def].sample}.];
|
16
|
+
else
|
17
|
+
a << %[#{w[:word].capitalize} means #{w[:word]}.];
|
18
|
+
end
|
14
19
|
end
|
15
20
|
BOOK.word(w[:word]) { |r|
|
16
21
|
if h[:cite] == true
|
@@ -25,13 +30,12 @@ module DICT
|
|
25
30
|
return a
|
26
31
|
end
|
27
32
|
|
28
|
-
def self.
|
33
|
+
def self.keywords input, &b
|
29
34
|
a = []
|
30
|
-
Tokenizer::WhitespaceTokenizer.new().tokenize(
|
35
|
+
Tokenizer::WhitespaceTokenizer.new().tokenize(input).each do |e|
|
31
36
|
d = Meiou.word[e]
|
32
37
|
if d != nil
|
33
|
-
if "#{e}".length > 2 && !/[[:punct:]]/.match(e) && !['the','and','but','this','that'].include?(e.downcase) && d != false
|
34
|
-
#puts %[Meiou | #{e} | #{d[:pos].sample} | #{d[:def].sample}]
|
38
|
+
if "#{e}".length > 2 && !/[[:punct:]]/.match(e) && !['the','and','but','this','that'].include?(e.downcase) && d != false
|
35
39
|
if block_given?
|
36
40
|
a << b.call(d)
|
37
41
|
else
|
@@ -45,12 +49,14 @@ module DICT
|
|
45
49
|
end
|
46
50
|
|
47
51
|
module Meiou
|
48
|
-
def self.
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
52
|
+
def self.extract k, &b
|
53
|
+
if block_given?
|
54
|
+
DICT.keywords(k) { |e| b.call(e) }
|
55
|
+
else
|
56
|
+
DICT.keywords(k)
|
57
|
+
end
|
53
58
|
end
|
59
|
+
|
54
60
|
def self.[] k
|
55
61
|
DICT.know(k, define: true, example: true)
|
56
62
|
end
|
data/lib/meiou/emoji.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'gemoji'
|
2
|
+
|
3
|
+
module EMOJI
|
4
|
+
|
5
|
+
def self.[] k
|
6
|
+
Emoji.find_by_alias(k.to_s)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.translate i
|
10
|
+
a = []
|
11
|
+
Meiou.extract(i) { |e| if EMOJI[e[:word]]; a << EMOJI[e[:word]].raw; else; a << e[:word]; end }
|
12
|
+
return a
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
module Meiou
|
18
|
+
def self.simplify i
|
19
|
+
EMOJI.translate i
|
20
|
+
end
|
21
|
+
end
|
data/lib/meiou/version.rb
CHANGED
data/lib/meiou/word.rb
CHANGED
@@ -5,7 +5,17 @@ module WORD
|
|
5
5
|
# find +word+.
|
6
6
|
def self.term word
|
7
7
|
ds, df = [], []
|
8
|
-
WordNet::Lemma.find_all(word).each { |e|
|
8
|
+
WordNet::Lemma.find_all(word).each { |e|
|
9
|
+
ds << e.pos;
|
10
|
+
e.synsets.each { |ee|
|
11
|
+
ee.expanded_hypernyms.each { |eee|
|
12
|
+
ee.gloss.gsub('"', "").gsub("--", " ").split("; ").each { |eeee|
|
13
|
+
df << eeee
|
14
|
+
df.uniq!
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
9
19
|
#if ds.include?('n') && !ds.include?('v')
|
10
20
|
if ds.length > 0
|
11
21
|
return { word: word, pos: ds, def: df }
|
@@ -29,6 +39,9 @@ module Meiou
|
|
29
39
|
def self.word
|
30
40
|
WORD
|
31
41
|
end
|
42
|
+
def self.meaning(w, ww, &b)
|
43
|
+
WORD[w][:def].each { |e| if Regexp.new(ww).match(e); b.call(e); end }
|
44
|
+
end
|
32
45
|
def self.words
|
33
46
|
WORD.keys
|
34
47
|
end
|
data/lib/meiou.rb
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
require 'pstore'
|
4
4
|
|
5
|
+
if !Dir.exist? 'db'
|
6
|
+
Dir.mkdir 'db'
|
7
|
+
end
|
8
|
+
|
5
9
|
module Meiou
|
6
10
|
TRAMPSTAMP = '[MEIOU]'
|
7
11
|
class Error < StandardError; end
|
@@ -32,6 +36,10 @@ require_relative "meiou/version"
|
|
32
36
|
|
33
37
|
require_relative "meiou/wiki"
|
34
38
|
|
39
|
+
require_relative "meiou/emoji"
|
40
|
+
|
41
|
+
require_relative "meiou/astronomy"
|
42
|
+
|
35
43
|
require_relative "meiou/dictionary"
|
36
44
|
|
37
45
|
require_relative "meiou/word"
|
data/meiou.gemspec
CHANGED
@@ -37,6 +37,8 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_dependency "tokenizer"
|
38
38
|
spec.add_dependency "textmood"
|
39
39
|
spec.add_dependency "tokipona"
|
40
|
+
spec.add_dependency "astronomy"
|
41
|
+
spec.add_dependency "gemoji"
|
40
42
|
# For more information and examples about making a new gem, check out our
|
41
43
|
# guide at: https://bundler.io/guides/creating_gem.html
|
42
44
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meiou
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Olson
|
@@ -94,6 +94,34 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: astronomy
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: gemoji
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
97
125
|
description: A wrapper for for wikipedia entries, curated txt files, and other sources
|
98
126
|
of knowledge.
|
99
127
|
email:
|
@@ -136,14 +164,15 @@ files:
|
|
136
164
|
- books/Applied_Psychology_for_Nurses.txt
|
137
165
|
- books/Crystallizing_Public_Opinion.txt
|
138
166
|
- books/Doctor_and_Patient.txt
|
139
|
-
- books/Increasing_Human_Efficiency_in_Business.txt
|
140
167
|
- books/Roman_Farm_Management.txt
|
141
168
|
- books/Social_Organization.txt
|
142
169
|
- books/interpretation_of_dreams.txt
|
143
170
|
- books/the_prince.txt
|
144
171
|
- lib/meiou.rb
|
172
|
+
- lib/meiou/astronomy.rb
|
145
173
|
- lib/meiou/book.rb
|
146
174
|
- lib/meiou/dictionary.rb
|
175
|
+
- lib/meiou/emoji.rb
|
147
176
|
- lib/meiou/mood.rb
|
148
177
|
- lib/meiou/tokipona.rb
|
149
178
|
- lib/meiou/version.rb
|