RSyntaxTree

Yet another syntax tree generator made with Ruby and RMagick

Phrase [labelled bracket notation]:  

Font   Fontsize   Format   Terminal   Symmetrize   Color   Auto subscript  

About

RSyntaxTree is a graphical syntax tree generator written in the Ruby programming language. It is basically a port of phpSyntaxTree created by André Eisenbach.

While phpSyntaxTree does not accept multi-byte characters as those in Chinese, Japanese, and Korean, RSyntaxTree handles text of any language as long as encoded in UTF-8 and fonts have been installed. Additionally, RSyntaxTree can output 'symmetrized' tree diagrams, a functionality that is not implemented in phpSyntaxTree.

RSyntaxTree consists of an easy-to-use ruby library and web-based interface made with Ruby on Rails.

Working web interface is available at http://yohasebe.com/rsyntaxtree/

For the latest updates and downloads please visit http://rubyforge.org/projects/rsyntaxtree/

RSyntaxTree is distributed under the GNU Public License.

Sample Images

under construction

Usage

Enter a sentence in a labeled bracket notation into the text area above and click the “Draw” button. A graphical syntax tree will appear immediately. English, Japanese, Chinese, and Korean have been tested so far.

Every branch or leaf of a tree must belong to a node. To create a node, place a label right next to the opening bracket. Arbitrary number of branches can follow with a preceding space. When a node has one and only one leaf and the leaf contains more than one space characters (i.e. when it’s a phrase).

You can put a subscript to any node by putting the _ character between the main label and the subscript. For example, NP_TOP will be rendered as NPTOP. Or you can select the “Auto subscript” option so that nodes of the same label will be automatically numbered. (e.g. NP1, NP2)

You can select from multiple image formats (png, jpg, gif, and bmp). Also RSyntaxTree is capable of generating SVG files. This is very convenient for those who want to modify output images on third party vector graphic software (such as Adobe Illustrator and Microsoft Visio). Just click on the link that appears below the (non SVG) syntax tree image.

Other options “Font”, “Fontsize”, and “Color” would be rather self-explanatory. You can change the appearance of the resulting image to suit your purpose.

Requirements

As a ruby application/library

Ruby 1.8 or higher with RMagick (the latter requires your system have either ImageMagick or GraphickMagick already installed)

With web interface

Web server with Ruby on Rails 1.0 or higher in addition to above.

Installation

First, download the archived package from the project site. Unpack it and copy files and folders to a suitable directory of your system. See /bin/stgraph.rb for how to create syntax trees from within a ruby script.

If you prefer to use web interface, build a new rails application:

  rails your_new_application

Then copy all the files and folders of RSyntaxTree package to RAILS_ROOT and set the permissions if necessary.

If you find any problems, or have any suggestions, please let me know via the project site, or send email to yohasebe@gmail.com

Acknowledgments

I especially thank the following people:

  • AndrĂ© Eisenbach for creating phpSyntaxTree, which RSyntaxTree is largely based on.

  • Developers of ImageMagick graphic library and its Ruby interface RMagick (Timothy P. Hunter).

  • Yukihiro Matsumoto and other contributers to Ruby community for making such a fun-to-use programming language possible.