Text::Tx - Perl interface to Tx by OKANOHARA Daisuke


Text-Tx documentation  | view source Contained in the Text-Tx distribution.

Index


NAME

Top

Text::Tx - Perl interface to Tx by OKANOHARA Daisuke

SYNOPSIS

Top

  use Text::Tx; 
  my $td     = Text::Tx->open("words.tx");
  my $newstr = $td->gsub($str, sub{ 
     qq(<a href="http://dictionary.com/browse/$_[0]">$_[0]</a>)
  }); # link'em all!

DESCRIPTION

Top

Tx is a library for a compact trie data structure by OKANOHARA Daisuke. Tx requires 1/4 - 1/10 of the memory usage compared to the previous implementations, and can therefore handle quite a large number of keys (e.g. 1 billion) efficiently.

Suppose words.tx is a pre-built tx by txbuild command which contains foo, bar, and baz,

  $newstr = $td->gsub($str, sub{"<$_[0]>"});

is equivalent to

  my $newstr = $str;
  $newstr = s{ (foo|bar|baz) }{ "<<$1>" }msgex;

Sounds less convenient? But what happens if the alteration contains thousands of words? It takes a whole lot of time and memory just to compile the regexp. Tx and Text::Tx does just that.

REQUIREMENT

Top

Tx 0.04 or above. Available at

http://www-tsujii.is.s.u-tokyo.ac.jp/~hillbig/tx.htm

To install, just

  fetch http://www-tsujii.is.s.u-tokyo.ac.jp/~hillbig/software/tx-0.04.tar.gz
  tar zxvf tx-0.04.tar.gz
  cd tx-0.04
  configure
  make
  sudo make install

EXPORT

None.

SEE ALSO

Top

http://www-tsujii.is.s.u-tokyo.ac.jp/~hillbig/tx.htm

Regexp::Assemble

AUTHOR

Top

Dan Kogai, <dankogai@dan.co.jp>

COPYRIGHT AND LICENSE

Top


Text-Tx documentation  | view source Contained in the Text-Tx distribution.