meiou 0.1.0 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03d15fe601d5531e80ada0b3a3bb845b9725658f02f15c23fbf83453cb165b25
4
- data.tar.gz: b068278d25c4a7af7ad35cd0a8307b31f37e9f69eb40eaf5c26f18a0da6631c7
3
+ metadata.gz: ffaee59e725de71fe02e8172475790aad75e79a26e99382eda714dc339983798
4
+ data.tar.gz: 9461f7eebafcc7a28e12f59883910cf7644f1b3d8b01e5ced737968b85196e9c
5
5
  SHA512:
6
- metadata.gz: e5dd53aa6765e2731d745e6dd458639c1b926731b8ae786314d4ac37318fdc5b5c03068a67eb9bc0cfafae044a00b0f9ce2100c9fb627a38efe76a0cb25e82b0
7
- data.tar.gz: 1e4514909e96d0e7798147093e11630db60bb202a065231492e9ecc75a835e2160d2729d7255acb70c7161d0edeed9563bdf0b2c0a95233feb371cff51777906
6
+ metadata.gz: 111be57c597ab493422a48bbd3eb00dcbb941a2b62f0a43882d8a299611a83608f25abd5ab47772dd2e9560ba48df38ddabda118eed5f9200173cf9bde09aeaa
7
+ data.tar.gz: 70898d2927f4c5f317011cd8e00ab02bd420811c84c2e31f928df3511dc0bd94a546ff1f7bbe65f80ff3170e9ce839f72c5d46aa1015c6c94e83f7fd84371a23
data/lib/meiou/book.rb CHANGED
@@ -49,9 +49,8 @@ module BOOK
49
49
  @bin[s].transaction { |db| db[i] = x }
50
50
  @ind.transaction { |db| db[i] = s }
51
51
  @mod.transaction { |db| db[i] = MOOD[x] }
52
- if s == :info
53
- Meiou.extract(x) { |e| @tag.transaction { |db| if !db.key?(e[:word]); db[e[:word]] = []; end; db[e[:word]] << i; } }
54
- end
52
+ puts ":INFO"
53
+ Meiou.extract(x) { |e| @tag.transaction { |db| if !db.key?(e[:word]); db[e[:word]] = []; end; db[e[:word]] << i; } }
55
54
  else
56
55
  if !/GUTENBERG/.match(x)
57
56
  puts %[#{@id}>#{i}: #{x}]
@@ -2,17 +2,8 @@ require 'tokenizer'
2
2
 
3
3
  module DICT
4
4
  # extract a list of tokens from +payload+ and handle with block passing +index+ and +WORD[word]+.
5
- def self.[] payload, &block
6
- Tokenizer::WhitespaceTokenizer.new().tokenize(payload).each do |e|
7
- d = Meiou.word[e]
8
- if d != nil
9
- if "#{e}".length > 2 && !/[[:punct:]]/.match(e) && !['the','and','but','this','that'].include?(e.downcase) && d != false
10
- #puts %[Meiou | #{e} | #{d[:pos].sample} | #{d[:def].sample}]
11
- block.call(d)
12
- end
13
- end
14
- end
15
- return nil
5
+ def self.[] k
6
+ DICT.extract(k)
16
7
  end
17
8
 
18
9
  def self.know input, h={}
@@ -33,9 +24,33 @@ module DICT
33
24
  }
34
25
  return a
35
26
  end
27
+
28
+ def self.extract i, &b
29
+ a = []
30
+ Tokenizer::WhitespaceTokenizer.new().tokenize(i).each do |e|
31
+ d = Meiou.word[e]
32
+ 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}]
35
+ if block_given?
36
+ a << b.call(d)
37
+ else
38
+ a << e
39
+ end
40
+ end
41
+ end
42
+ end
43
+ return a
44
+ end
36
45
  end
37
46
 
38
47
  module Meiou
48
+ def self.keywords k
49
+ DICT.know(k)
50
+ end
51
+ def self.extract k
52
+ DICT[k]
53
+ end
39
54
  def self.[] k
40
55
  DICT.know(k, define: true, example: true)
41
56
  end
@@ -0,0 +1,68 @@
1
+ require 'tokipona'
2
+ require 'yaml'
3
+
4
+ module TOKI
5
+ @@T = Hash.new { |h,k| h[k] = T.new(k) }
6
+ class T
7
+ attr_reader :pos
8
+ def initialize k
9
+ @id = k
10
+ @pos = {}
11
+ end
12
+ def pos? k
13
+ if @pos.has_key? k
14
+ return true
15
+ else
16
+ return false
17
+ end
18
+ end
19
+ def [] k
20
+ @pos[k]
21
+ end
22
+ def keys
23
+ @pos.keys
24
+ end
25
+ def define h={}
26
+ h.each_pair do |k,v|
27
+ [v].flatten.each { |e| TOKI.concept[e] = @id }
28
+ @pos[k] = v
29
+ end
30
+ end
31
+ end
32
+
33
+ def self.[] k
34
+ @@T[k]
35
+ end
36
+ def self.keys
37
+ @@T.keys
38
+ end
39
+
40
+ @@C = {}
41
+ def self.concept
42
+ @@C
43
+ end
44
+
45
+ def self.english s
46
+ h = {}
47
+ Tokipona::Tokenizer.tokenize(s).each do |e|
48
+ if !/[[:punct:]]/.match(e)
49
+ h[e] = TOKI[e]
50
+ end
51
+ end
52
+ return h
53
+ end
54
+
55
+ def self.tokipona s
56
+ h = {}
57
+ Tokenizer::WhitespaceTokenizer.new().tokenize(s).each do |e|
58
+ if !/[[:punct:]]/.match(e)
59
+ if TOKI.concept.has_key?(e)
60
+ h[e] = TOKI.concept[e]
61
+ end
62
+ end
63
+ end
64
+ return h
65
+ end
66
+
67
+ YAML.load(File.read(ENV['TOKIPONA'] || '../tokipona.yaml')).each_pair { |k,v| @@T[k].define(v) }
68
+ end
data/lib/meiou/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Meiou
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.3"
5
5
  end
data/lib/meiou.rb CHANGED
@@ -40,4 +40,6 @@ require_relative "meiou/book"
40
40
 
41
41
  require_relative "meiou/mood"
42
42
 
43
+ require_relative "meiou/tokipona"
44
+
43
45
  Meiou.init!
data/meiou.gemspec CHANGED
@@ -36,6 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_dependency "rwordnet"
37
37
  spec.add_dependency "tokenizer"
38
38
  spec.add_dependency "textmood"
39
+ spec.add_dependency "tokipona"
39
40
  # For more information and examples about making a new gem, check out our
40
41
  # guide at: https://bundler.io/guides/creating_gem.html
41
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meiou
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Olson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-14 00:00:00.000000000 Z
11
+ date: 2024-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: wikipedia-client
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: tokipona
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: A wrapper for for wikipedia entries, curated txt files, and other sources
84
98
  of knowledge.
85
99
  email:
@@ -131,6 +145,7 @@ files:
131
145
  - lib/meiou/book.rb
132
146
  - lib/meiou/dictionary.rb
133
147
  - lib/meiou/mood.rb
148
+ - lib/meiou/tokipona.rb
134
149
  - lib/meiou/version.rb
135
150
  - lib/meiou/wiki.rb
136
151
  - lib/meiou/word.rb