Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A port of pytst to Ruby. It is a implementation of Ternary Search Trie (TST) and scanning by the Aho-Corasick algorithm.

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 doc
Octocat-spinner-32 example
Octocat-spinner-32 include
Octocat-spinner-32 not_used
Octocat-spinner-32 test
Octocat-spinner-32 test_ruby
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README
Octocat-spinner-32 RubyReference.h
Octocat-spinner-32 extconf.rb
Octocat-spinner-32 rubyTST.h
Octocat-spinner-32 ruby_gen
Octocat-spinner-32 tst.i

ruby-pytst is a port of pytst to Ruby.
It is a implementation of Ternary Search Trie (TST) and it also supports 
scanning by the Aho-Corasick algorithm.
It is built with SWIG.

This software is distributed under LGPL.

I have successfully built on the following environments.

  (1) Mac OS X 10.4, Ruby 1.8.4 (Fink)
  (2) Fedora Core 5, Ruby 1.8.4

tst_wrap.cxx in this package was generated on (1) with SWIG 1.3.19.

Masaki Yatsu <>


Generate the Makefile.

  % ruby extconf.rb

Make it.

  % make

Then, install it as root.

  % make install

If you want to generate the Ruby wrapper codes from tst.i by yourself,
execute the following at the beginning.

  % swig -c++ -ruby -Iinclude tst.i

How to Use

There is no documentation at this point, but there is README.html of pytst
in the doc directory.

There are examples in the example directory.
You can run examples like this.

  % ruby example/tokenize.rb

ruby-pytst supports following character sets.

  * ASCII      ($KCODE = 'NONE')
  * EUC-JP     ($KCODE = 'EUC')
  * Shift_JIS  ($KCODE = 'SJIS')
  * UTF-8      ($KCODE = 'UTF8')

You have to specify $KCODE *before* you create a Pytst::TST.

There is a EUC-JP example in the example directory.

  % ruby -Ke example/japanese_euc.rb

The option '-Ke' means $KCODE = 'EUC'.

See also


Ternary Search Trie:

Aho-Corasick algorithm
Something went wrong with that request. Please try again.