- 追加された行はこの色です。
- 削除された行はこの色です。
#freeze
[[FrontPage]]
This is a Ruby 1.8/1.9 binding of Tx, a library for a compact trie data structure.
For details of Tx, see: [[Tx: Succinct Trie Data structure:http://www-tsujii.is.s.u-tokyo.ac.jp/~hillbig/tx.htm]]
#contents
** How to install [#y0d82ffb]
$ sudo gem install tx
Or
$ wget http://gimite.net/archive/tx-ruby-0.0.5.tar.gz
$ tar xvzf tx-ruby-*.tar.gz
$ cd tx-ruby
$ sudo ruby setup.rb
- If your Ruby is 1.8.x mswin32, you don't need compilers (binary is bundled).
- Tx library is bundled, so you don't need to install it separately.
** Document [#b2f21339]
- [[Document in RDoc format:http://gimite.net/gimite/rubymess/tx-ruby/]]
- Usage example of simple index:
require "rubygems"
require "tx"
# Builds an index and saves it to a file.
builder = Tx::Builder.new
builder.add_all(["foo", "ho", "hog", "hoga", "hoge", "hogeshi"])
builder.build("test.index")
# Loads an index.
index = Tx::Index.open("test.index")
# Simple lookup.
index.include?("hoge") #=> true
index.include?("bar") #=> false
# Searches prefixes of the word.
index.longest_prefix("hogeeee") #=> 4 (which means "hoge" is in the index)
index.search_prefixes("hoge") #=> ["ho", "hog", "hoge"]
# Searches words which begin with the string.
index.search_expansions("hog") #=> ["hog", "hoga", "hoge", "hogeshi"]
# Finds all occurences of words in the index.
index.scan("hogefugafoo") #=> [["hoge", 0], ["foo", 8]]
# Replaces words in the index.
index.gsub("hogefugafoo"){ |s, i| s.upcase }
#=> "HOGEfugaFOO"
- Usage example of Hash-like index:
require "tx"
# Builds an index and saves it to a file.
builder = Tx::MapBuilder.new
builder.add("ho", "foo")
builder.add("hoge", "bar")
builder.build("test")
# Loads an index.
map = Tx::Map.open("test")
# Simple lookup.
map.has_key?("hoge") #=> true
map["hoge"] #=> "bar"
map["fuga"] #=> nil
# Searches prefixes/expansion of the word in keys.
map.key_index.longest_prefix("hogeeee") #=> 4 (which means the index has a key "hoge")
map.key_index.search_prefixes("hoge") #=> ["ho", "hoge"]
map.key_index.search_expansions("ho") #=> ["ho", "hoge"]
# Finds all occurences of keys in the index.
index.scan("hogehoga") #=> [["hoge", 0, "bar"], ["ho", 4, "foo"]]
** License [#ldb17bfc]
New BSD License.
** History [#x9b5a3e1]
- 0.0.5
-- Based on Tx 0.13.
-- Fixed compilation error in recent Ubuntu (thanks to ROBA).
-- Supported Ruby 1.9.x.
-- Added Set/Hash-like methods to Tx::Index and Tx::Map.
- 0.0.4
-- Based on Tx 0.09.
-- Added Hash-like interface: Tx::Map and Tx::MapBuilder.
- 0.0.3
-- Added Tx::Index#scan and Tx::Index#gsub.
-- Fixed a bug that Ruby crashes when opening non-existing index file.
- 0.0.2
-- ''(Incompatible with 0.0.1)'' Result of Tx::Index#search_expansions now includes str itself if it's in the index.
-- Fixed performance problem.
- 0.0.1
-- First version. Based on Tx 0.0.4.
** How to hack [#kb362ca2]
Source code is on [[Github:http://github.com/gimite/tx-ruby]].
Some hints:
- This library is implemented with SWIG (So I guess it's easy to generate binding for other script languages). You need to install SWIG to regenerate ext/tx_swig_wrap.cxx if you edit ext/tx_swig.{h,i}.
- To generate ext/tx_swig_wrap.cxx which works on Ruby 1.9, you need to apply ext/swig.patch to SWIG.
- To build lib/i386-msvcrt/tx_core.so, follow [[instruction here:http://d.hatena.ne.jp/Gimite/searchdiary?word=cygwin]] (Japanese).
** Comments [#j6538610]
- 1 -- [[1]] &new{2014-04-03 (Thu) 13:08:42};
- 1 -- [[1]] &new{2014-04-03 (Thu) 13:08:46};
- 1 -- [[-1']] &new{2014-04-03 (Thu) 13:08:47};
-- 1' -- [[1]] &new{2014-04-03 (Thu) 13:08:49};
- 1 -- [[1]] &new{2014-04-03 (Thu) 13:08:51};
- 1 -- [[1]] &new{2014-04-29 (Tue) 00:02:38};
- 1 -- [[1]] &new{2014-04-29 (Tue) 00:02:40};
- 1 -- [[-1']] &new{2014-04-29 (Tue) 00:02:41};
-- 1' -- [[1]] &new{2014-04-29 (Tue) 00:02:42};
- 1 -- [[1]] &new{2014-04-29 (Tue) 00:02:43};
- 1 -- [[1]] &new{2014-06-30 (Mon) 13:38:18};
- 1 -- [[1]] &new{2014-06-30 (Mon) 13:38:45};
- 1 -- [[-1']] &new{2014-06-30 (Mon) 13:38:50};
-- 1' -- [[1]] &new{2014-06-30 (Mon) 13:39:13};
- 1 -- [[1]] &new{2014-06-30 (Mon) 13:39:15};
- 1 -- [[1]] &new{2014-07-04 (Fri) 08:26:22};
- 1 -- [[-1']] &new{2014-07-04 (Fri) 08:26:24};
-- 1' -- [[1]] &new{2014-07-04 (Fri) 08:26:28};
- 1 -- [[1]] &new{2014-07-04 (Fri) 08:26:32};
- 1 -- [[1]] &new{2014-08-07 (Thu) 15:10:33};
- 1 -- [[1]] &new{2014-08-07 (Thu) 15:10:37};
- 1 -- [[-1']] &new{2014-08-07 (Thu) 15:10:38};
-- 1' -- [[1]] &new{2014-08-07 (Thu) 15:10:39};
- 1 -- [[1]] &new{2014-08-07 (Thu) 15:10:40};
- 1 -- [[1]] &new{2014-08-11 (Mon) 19:28:24};
- 1 -- [[1]] &new{2014-08-11 (Mon) 19:28:26};
- 1 -- [[-1']] &new{2014-08-11 (Mon) 19:28:27};
-- 1' -- [[1]] &new{2014-08-11 (Mon) 19:28:28};
- 1 -- [[1]] &new{2014-08-11 (Mon) 19:28:29};
- 1 -- [[1]] &new{2014-10-06 (Mon) 15:53:52};
- 1 -- [[-1']] &new{2014-10-06 (Mon) 15:53:53};
-- 1' -- [[1]] &new{2014-10-06 (Mon) 15:53:54};
- 1 -- [[1]] &new{2014-10-06 (Mon) 15:53:56};
- 1 -- [[1]] &new{2014-10-15 (Wed) 10:29:51};
- 1 -- [[1]] &new{2014-10-15 (Wed) 10:29:56};
- 1 -- [[-1']] &new{2014-10-15 (Wed) 10:29:59};
-- 1' -- [[1]] &new{2014-10-15 (Wed) 10:29:59};
- 1 -- [[1]] &new{2014-10-15 (Wed) 10:30:01};
- 1 -- [[1]] &new{2014-11-18 (Tue) 18:21:36};
- 1 -- [[-1']] &new{2014-11-18 (Tue) 18:21:37};
-- 1' -- [[1]] &new{2014-11-18 (Tue) 18:21:38};
- 1 -- [[1]] &new{2014-11-18 (Tue) 18:21:39};
- 1 -- [[1]] &new{2014-11-24 (Mon) 06:23:12};
- 1 -- [[1]] &new{2014-11-24 (Mon) 06:23:15};
- 1 -- [[-1']] &new{2014-11-24 (Mon) 06:23:15};
-- 1' -- [[1]] &new{2014-11-24 (Mon) 06:23:16};
- 1 -- [[1]] &new{2014-11-24 (Mon) 06:23:17};
- 1 -- [[-1']] &new{2014-12-15 (Mon) 11:24:51};
-- 1' -- [[1]] &new{2014-12-15 (Mon) 11:24:52};
- 1 -- [[1]] &new{2014-12-15 (Mon) 11:24:52};
- 1 -- [[1]] &new{2014-12-31 (Wed) 14:45:26};
- 1 -- [[1]] &new{2014-12-31 (Wed) 14:45:29};
- 1 -- [[-1']] &new{2014-12-31 (Wed) 14:45:30};
-- 1' -- [[1]] &new{2014-12-31 (Wed) 14:45:31};
- 1 -- [[1]] &new{2014-12-31 (Wed) 14:45:32};
- 1 -- [[1]] &new{2015-01-11 (Sun) 12:38:31};
- 1 -- [[1]] &new{2015-01-11 (Sun) 12:38:36};
- 1 -- [[-1']] &new{2015-01-11 (Sun) 12:38:37};
-- 1' -- [[1]] &new{2015-01-11 (Sun) 12:38:38};
- 1 -- [[1]] &new{2015-01-11 (Sun) 12:38:41};
- 1 -- [[-1']] &new{2015-02-16 (Mon) 10:38:22};
-- 1' -- [[1]] &new{2015-02-16 (Mon) 10:38:23};
- 1 -- [[1]] &new{2015-02-16 (Mon) 10:38:24};
- 1 -- [[-1']] &new{2015-02-21 (Sat) 07:15:53};
-- 1' -- [[1]] &new{2015-02-21 (Sat) 07:15:54};
- 1 -- [[1]] &new{2015-02-21 (Sat) 07:15:55};
- 1 -- [[1]] &new{2015-03-23 (Mon) 02:51:18};
- 1 -- [[1]] &new{2015-03-26 (Thu) 08:34:35};
- 1 -- [[1]] &new{2015-03-26 (Thu) 08:34:37};
- 1 -- [[-1']] &new{2015-03-26 (Thu) 08:34:38};
-- 1' -- [[1]] &new{2015-03-26 (Thu) 08:34:39};
- 1 -- [[1]] &new{2015-03-26 (Thu) 08:34:39};
#comment
- 1 -- [[1]] &new{2015-03-26 (Thu) 08:34:36};
- 1 -- [[1]] &new{2015-01-11 (Sun) 12:38:35};
- 1 -- [[1]] &new{2014-12-31 (Wed) 14:45:28};
- 1 -- [[1]] &new{2014-11-24 (Mon) 06:23:14};
- 1 -- [[1]] &new{2014-11-18 (Tue) 18:21:31};
- 1 -- [[1]] &new{2014-10-15 (Wed) 10:29:53};
- 1 -- [[1]] &new{2014-08-11 (Mon) 19:28:26};
- 1 -- [[1]] &new{2014-08-07 (Thu) 15:10:34};
- 1 -- [[1]] &new{2014-07-04 (Fri) 08:26:05};
- 1 -- [[1]] &new{2014-06-30 (Mon) 13:38:44};
- 1 -- [[1]] &new{2014-04-29 (Tue) 00:02:39};
- 1 -- [[1]] &new{2014-04-03 (Thu) 13:08:45};