Sequitur

Ruby gem implementing the Sequitur algorithm
Homepage

Build Status Gem Version

What is the Sequitur algorithm?

Sequitur home
Wikipedia

Sequitur is an algorithm that generates a set of rules representing a sequence of input tokens.
It detects repeated token patterns and can represent them in a compact way.

Synopsis


    require 'sequitur' # Load the Sequitur library

    input_sequence =  'abcabdab'

    # The SEQUITUR algorithm will detect the repeated 'ab' pattern
    # and will generate a context-free grammar that represents the input string
    grammar = Sequitur.build_from(input_sequence)

    # Display the grammar rules
    # Each rule is displayed with the format:
    # rule_id : a_sequence_grammar_symbols
    # Where: 
    # - rule_id is the object id of a rule (in decimal)
    # - a grammar symbol is either a terminal symbol 
    # (i.e. a character from the input) or the id of a production
    puts grammar.to_string

TODO: Add more documentation

Copyright (c) 2014, Dimitri Geshef. Sequitur is released under the MIT License see LICENSE.txt for details.