marisa 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Binary file
@@ -0,0 +1,61 @@
1
+ require "marisa"
2
+
3
+ keyset = Marisa::Keyset.new
4
+ keyset.push_back("cake")
5
+ keyset.push_back("cookie")
6
+ keyset.push_back("ice")
7
+ keyset.push_back("ice-cream")
8
+
9
+ trie = Marisa::Trie.new
10
+ trie.build(keyset)
11
+ print("no. keys: ", trie.num_keys(), "\n")
12
+ print("no. tries: ", trie.num_tries(), "\n")
13
+ print("no. nodes: ", trie.num_nodes(), "\n")
14
+ print("size: ", trie.io_size(), "\n")
15
+
16
+ agent = Marisa::Agent.new
17
+
18
+ agent.set_query("cake")
19
+ trie.lookup(agent)
20
+ print(agent.query_str(), ": ", agent.key_id(), "\n")
21
+
22
+ agent.set_query("cookie")
23
+ trie.lookup(agent)
24
+ print(agent.query_str(), ": ", agent.key_id(), "\n")
25
+
26
+ agent.set_query("cockoo")
27
+ if not trie.lookup(agent)
28
+ print(agent.query_str(), ": not found\n")
29
+ end
30
+
31
+ print("ice: ", trie.lookup("ice"), "\n")
32
+ print("ice-cream: ", trie.lookup("ice-cream"), "\n")
33
+ if trie.lookup("ice-age") == Marisa::INVALID_KEY_ID
34
+ print("ice-age: not found\n")
35
+ end
36
+
37
+ trie.save("sample.dic")
38
+ trie.load("sample.dic")
39
+
40
+ agent.set_query(0)
41
+ trie.reverse_lookup(agent)
42
+ print(agent.query_id(), ": ", agent.key_str(), "\n")
43
+
44
+ agent.set_query(1)
45
+ trie.reverse_lookup(agent)
46
+ print(agent.query_id(), ": ", agent.key_str(), "\n")
47
+
48
+ print("2: ", trie.reverse_lookup(2), "\n")
49
+ print("3: ", trie.reverse_lookup(3), "\n")
50
+
51
+ trie.mmap("sample.dic")
52
+
53
+ agent.set_query("ice-cream soda")
54
+ while trie.common_prefix_search(agent)
55
+ print(agent.query_str(), ": ", agent.key_str(), " (", agent.key_id(), ")\n")
56
+ end
57
+
58
+ agent.set_query("ic")
59
+ while trie.predictive_search(agent)
60
+ print(agent.query_str(), ": ", agent.key_str(), " (", agent.key_id(), ")\n")
61
+ end
@@ -0,0 +1,4 @@
1
+ module Marisa
2
+ end
3
+
4
+ require 'marisa/marisa'
@@ -0,0 +1,3 @@
1
+ module Marisa
2
+ VERSION = '0.2.6'
3
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'marisa/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "marisa"
8
+ spec.version = Marisa::VERSION
9
+ spec.authors = ["Hidekazu Kobayashi"]
10
+ spec.email = ["kobahide789@gmail.com"]
11
+ spec.licenses = ["BSD-2-Clause"]
12
+
13
+ spec.summary = %q{Ruby binding for marisa-trie}
14
+ spec.description = %q{Ruby binding for marisa-trie which is a static and space-efficient trie data structure.}
15
+ spec.homepage = "https://github.com/koba789/marisa-ruby"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.extensions = 'ext/marisa/extconf.rb'
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_development_dependency "rake", "~> 11.1"
24
+ spec.add_development_dependency "rake-compiler", "~> 1.0"
25
+ spec.add_development_dependency "pry", "~> 0.10"
26
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: marisa
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.6
5
+ platform: ruby
6
+ authors:
7
+ - Hidekazu Kobayashi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '11.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '11.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake-compiler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.10'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.10'
69
+ description: Ruby binding for marisa-trie which is a static and space-efficient trie
70
+ data structure.
71
+ email:
72
+ - kobahide789@gmail.com
73
+ executables: []
74
+ extensions:
75
+ - ext/marisa/extconf.rb
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - Gemfile
80
+ - LICENSE
81
+ - Rakefile
82
+ - ext/marisa/COPYING
83
+ - ext/marisa/Makefile
84
+ - ext/marisa/extconf.rb
85
+ - ext/marisa/marisa-swig.cxx
86
+ - ext/marisa/marisa-swig.h
87
+ - ext/marisa/marisa-swig_wrap.cxx
88
+ - ext/marisa/sample.dic
89
+ - ext/marisa/sample.rb
90
+ - lib/marisa.rb
91
+ - lib/marisa/version.rb
92
+ - marisa.gemspec
93
+ homepage: https://github.com/koba789/marisa-ruby
94
+ licenses:
95
+ - BSD-2-Clause
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.5.1
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Ruby binding for marisa-trie
117
+ test_files: []
118
+ has_rdoc: