tyler-trie 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +4 -0
- data/ext/libdatrie/AUTHORS +1 -0
- data/ext/libdatrie/COPYING +510 -0
- data/ext/libdatrie/ChangeLog +410 -0
- data/ext/libdatrie/INSTALL +236 -0
- data/ext/libdatrie/Makefile.am +5 -0
- data/ext/libdatrie/Makefile.in +661 -0
- data/ext/libdatrie/NEWS +27 -0
- data/ext/libdatrie/README +32 -0
- data/ext/libdatrie/aclocal.m4 +7431 -0
- data/ext/libdatrie/config.guess +1516 -0
- data/ext/libdatrie/config.h.in +74 -0
- data/ext/libdatrie/config.sub +1626 -0
- data/ext/libdatrie/configure +22008 -0
- data/ext/libdatrie/configure.ac +71 -0
- data/ext/libdatrie/datrie.pc.in +11 -0
- data/ext/libdatrie/datrie/Makefile.am +35 -0
- data/ext/libdatrie/datrie/Makefile.in +522 -0
- data/ext/libdatrie/datrie/alpha-map.c +170 -0
- data/ext/libdatrie/datrie/alpha-map.h +36 -0
- data/ext/libdatrie/datrie/darray.c +674 -0
- data/ext/libdatrie/datrie/darray.h +229 -0
- data/ext/libdatrie/datrie/fileutils.c +151 -0
- data/ext/libdatrie/datrie/fileutils.h +36 -0
- data/ext/libdatrie/datrie/libdatrie.def +31 -0
- data/ext/libdatrie/datrie/sb-trie.c +331 -0
- data/ext/libdatrie/datrie/sb-trie.h +279 -0
- data/ext/libdatrie/datrie/tail.c +344 -0
- data/ext/libdatrie/datrie/tail.h +200 -0
- data/ext/libdatrie/datrie/trie-private.h +31 -0
- data/ext/libdatrie/datrie/trie.c +413 -0
- data/ext/libdatrie/datrie/trie.h +270 -0
- data/ext/libdatrie/datrie/triedefs.h +63 -0
- data/ext/libdatrie/datrie/typedefs.h +113 -0
- data/ext/libdatrie/depcomp +530 -0
- data/ext/libdatrie/doc/Doxyfile.in +244 -0
- data/ext/libdatrie/doc/Makefile.am +29 -0
- data/ext/libdatrie/doc/Makefile.in +352 -0
- data/ext/libdatrie/install-sh +323 -0
- data/ext/libdatrie/ltmain.sh +6938 -0
- data/ext/libdatrie/man/Makefile.am +4 -0
- data/ext/libdatrie/man/Makefile.in +381 -0
- data/ext/libdatrie/man/trietool.1 +107 -0
- data/ext/libdatrie/missing +360 -0
- data/ext/libdatrie/tools/Makefile.am +7 -0
- data/ext/libdatrie/tools/Makefile.in +460 -0
- data/ext/libdatrie/tools/trietool.c +308 -0
- data/ext/trie/extconf.rb +12 -0
- data/ext/trie/trie.c +174 -0
- data/lib/trie.rb +1 -0
- data/spec/test-trie/README +1 -0
- data/spec/trie_spec.rb +79 -0
- metadata +139 -0
data/lib/trie.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../ext/trie/trie'
|
@@ -0,0 +1 @@
|
|
1
|
+
This directory is used to store Trie files while running the specs. Don't delete it.
|
data/spec/trie_spec.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'trie'
|
2
|
+
|
3
|
+
TRIE_PATH = 'spec/test-trie'
|
4
|
+
|
5
|
+
describe Trie do
|
6
|
+
before :each do
|
7
|
+
@trie = Trie.new(TRIE_PATH);
|
8
|
+
@trie.add('rocket')
|
9
|
+
@trie.add('rock')
|
10
|
+
@trie.add('frederico')
|
11
|
+
end
|
12
|
+
|
13
|
+
after :each do
|
14
|
+
@trie.close
|
15
|
+
File.delete('spec/test-trie/trie.br')
|
16
|
+
File.delete('spec/test-trie/trie.tl')
|
17
|
+
File.delete('spec/test-trie/trie.sbm')
|
18
|
+
end
|
19
|
+
|
20
|
+
describe :path do
|
21
|
+
it 'returns the correct path' do
|
22
|
+
@trie.path.should == TRIE_PATH
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe :has_key? do
|
27
|
+
it 'returns true for words in the trie' do
|
28
|
+
@trie.has_key?('rocket').should be_true
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns nil for words that are not in the trie' do
|
32
|
+
@trie.has_key?('not_in_the_trie').should be_nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe :get do
|
37
|
+
it 'returns -1 for words in the trie without a weight' do
|
38
|
+
@trie.get('rocket').should == -1
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'returns nil if the word is not in the trie' do
|
42
|
+
@trie.get('not_in_the_trie').should be_nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe :add do
|
47
|
+
it 'adds a word to the trie' do
|
48
|
+
@trie.add('forsooth').should == true
|
49
|
+
@trie.get('forsooth').should == -1
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe :delete do
|
54
|
+
it 'deletes a word from the trie' do
|
55
|
+
@trie.delete('rocket').should == true
|
56
|
+
@trie.has_key?('rocket').should be_nil
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe :children do
|
61
|
+
it 'returns all words beginning with a given prefix' do
|
62
|
+
children = @trie.children('roc')
|
63
|
+
children.size.should == 2
|
64
|
+
children.should include('rock')
|
65
|
+
children.should include('rocket')
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'returns nil if prefix does not exist' do
|
69
|
+
@trie.children('ajsodij').should be_nil
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'includes the prefix if the prefix is a word' do
|
73
|
+
children = @trie.children('rock')
|
74
|
+
children.size.should == 2
|
75
|
+
children.should include('rock')
|
76
|
+
children.should include('rocket')
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tyler-trie
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tyler McMullen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-03-08 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: TODO
|
17
|
+
email: tyler@scribd.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions:
|
21
|
+
- ext/trie/extconf.rb
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- VERSION.yml
|
26
|
+
- lib/trie.rb
|
27
|
+
- spec/test-trie
|
28
|
+
- spec/test-trie/README
|
29
|
+
- spec/trie_spec.rb
|
30
|
+
- ext/libdatrie
|
31
|
+
- ext/libdatrie/aclocal.m4
|
32
|
+
- ext/libdatrie/AUTHORS
|
33
|
+
- ext/libdatrie/ChangeLog
|
34
|
+
- ext/libdatrie/config.guess
|
35
|
+
- ext/libdatrie/config.h
|
36
|
+
- ext/libdatrie/config.h.in
|
37
|
+
- ext/libdatrie/config.log
|
38
|
+
- ext/libdatrie/config.status
|
39
|
+
- ext/libdatrie/config.sub
|
40
|
+
- ext/libdatrie/configure
|
41
|
+
- ext/libdatrie/configure.ac
|
42
|
+
- ext/libdatrie/COPYING
|
43
|
+
- ext/libdatrie/datrie
|
44
|
+
- ext/libdatrie/datrie/alpha-map.c
|
45
|
+
- ext/libdatrie/datrie/alpha-map.h
|
46
|
+
- ext/libdatrie/datrie/alpha-map.lo
|
47
|
+
- ext/libdatrie/datrie/alpha-map.o
|
48
|
+
- ext/libdatrie/datrie/darray.c
|
49
|
+
- ext/libdatrie/datrie/darray.h
|
50
|
+
- ext/libdatrie/datrie/darray.lo
|
51
|
+
- ext/libdatrie/datrie/darray.o
|
52
|
+
- ext/libdatrie/datrie/fileutils.c
|
53
|
+
- ext/libdatrie/datrie/fileutils.h
|
54
|
+
- ext/libdatrie/datrie/fileutils.lo
|
55
|
+
- ext/libdatrie/datrie/fileutils.o
|
56
|
+
- ext/libdatrie/datrie/libdatrie.def
|
57
|
+
- ext/libdatrie/datrie/libdatrie.la
|
58
|
+
- ext/libdatrie/datrie/Makefile
|
59
|
+
- ext/libdatrie/datrie/Makefile.am
|
60
|
+
- ext/libdatrie/datrie/Makefile.in
|
61
|
+
- ext/libdatrie/datrie/sb-trie.c
|
62
|
+
- ext/libdatrie/datrie/sb-trie.h
|
63
|
+
- ext/libdatrie/datrie/sb-trie.lo
|
64
|
+
- ext/libdatrie/datrie/sb-trie.o
|
65
|
+
- ext/libdatrie/datrie/tail.c
|
66
|
+
- ext/libdatrie/datrie/tail.h
|
67
|
+
- ext/libdatrie/datrie/tail.lo
|
68
|
+
- ext/libdatrie/datrie/tail.o
|
69
|
+
- ext/libdatrie/datrie/trie-private.h
|
70
|
+
- ext/libdatrie/datrie/trie.c
|
71
|
+
- ext/libdatrie/datrie/trie.h
|
72
|
+
- ext/libdatrie/datrie/trie.lo
|
73
|
+
- ext/libdatrie/datrie/trie.o
|
74
|
+
- ext/libdatrie/datrie/triedefs.h
|
75
|
+
- ext/libdatrie/datrie/typedefs.h
|
76
|
+
- ext/libdatrie/datrie.pc
|
77
|
+
- ext/libdatrie/datrie.pc.in
|
78
|
+
- ext/libdatrie/depcomp
|
79
|
+
- ext/libdatrie/doc
|
80
|
+
- ext/libdatrie/doc/Doxyfile
|
81
|
+
- ext/libdatrie/doc/Doxyfile.in
|
82
|
+
- ext/libdatrie/doc/Makefile
|
83
|
+
- ext/libdatrie/doc/Makefile.am
|
84
|
+
- ext/libdatrie/doc/Makefile.in
|
85
|
+
- ext/libdatrie/INSTALL
|
86
|
+
- ext/libdatrie/install-sh
|
87
|
+
- ext/libdatrie/libtool
|
88
|
+
- ext/libdatrie/ltmain.sh
|
89
|
+
- ext/libdatrie/Makefile
|
90
|
+
- ext/libdatrie/Makefile.am
|
91
|
+
- ext/libdatrie/Makefile.in
|
92
|
+
- ext/libdatrie/man
|
93
|
+
- ext/libdatrie/man/Makefile
|
94
|
+
- ext/libdatrie/man/Makefile.am
|
95
|
+
- ext/libdatrie/man/Makefile.in
|
96
|
+
- ext/libdatrie/man/trietool.1
|
97
|
+
- ext/libdatrie/missing
|
98
|
+
- ext/libdatrie/NEWS
|
99
|
+
- ext/libdatrie/README
|
100
|
+
- ext/libdatrie/stamp-h1
|
101
|
+
- ext/libdatrie/tools
|
102
|
+
- ext/libdatrie/tools/Makefile
|
103
|
+
- ext/libdatrie/tools/Makefile.am
|
104
|
+
- ext/libdatrie/tools/Makefile.in
|
105
|
+
- ext/libdatrie/tools/trietool
|
106
|
+
- ext/libdatrie/tools/trietool.c
|
107
|
+
- ext/libdatrie/tools/trietool.o
|
108
|
+
- ext/trie
|
109
|
+
- ext/trie/extconf.rb
|
110
|
+
- ext/trie/trie.c
|
111
|
+
has_rdoc: false
|
112
|
+
homepage: http://github.com/tyler/trie
|
113
|
+
post_install_message:
|
114
|
+
rdoc_options: []
|
115
|
+
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
- ext
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: "0"
|
124
|
+
version:
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: "0"
|
130
|
+
version:
|
131
|
+
requirements: []
|
132
|
+
|
133
|
+
rubyforge_project:
|
134
|
+
rubygems_version: 1.2.0
|
135
|
+
signing_key:
|
136
|
+
specification_version: 2
|
137
|
+
summary: TODO
|
138
|
+
test_files: []
|
139
|
+
|