README.md in sequitur-0.1.10 vs README.md in sequitur-0.1.11
- old
+ new
@@ -13,10 +13,17 @@
### What is the Sequitur algorithm? ###
The following are good entry points to learn about the algorithm:
[Sequitur algorithm home](http://sequitur.info/)
[Wikipedia](http://en.wikipedia.org/wiki/Sequitur_algorithm)
+### Highlights ###
+* Pure Ruby implementation
+* No runtime dependency with other gems,
+* Test suite with 100%,
+* Documentation: 100% coverage (according to YARD), green badge from inch.io
+* Algorithm works with different input token types (no limited to single character)
+
### The theory in a nutshell ###
Given a sequence of input tokens (say, characters), the Sequitur algorithm
will represent that input sequence as a set of rules. As the algorithm detects
automatically repeated token patterns, the resulting rule set can encode repetitions in the input
in a very compact way.
@@ -190,10 +197,60 @@
$[sudo] gem install sequitur
```
-### TODO: Add more documentation ###
+### Good to know ###
+The above examples might give the impression that the input stream must consist of single
+character tokens. This is simply not true.
+This implementation is flexible enough to cope with other kinds of input values.
+The next example shows how integer values can be correctly processed by Sequitur.
+Assume that the input is the array of Fixnums *[1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5]*.
+Then Sequitur algorithm will generate the rule set:
+```
+start : P1 P2 P3 P3 e.
+P1 : a b.
+P2 : P1 c.
+P3 : P2 d.
+```
+
+
+```ruby
+require 'sequitur' # Load the Sequitur library
+
+#
+# Purpose: demo of Sequitur with a stream of integer values
+#
+input_sequence = [1, 2, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 5]
+
+# Generate the grammar from the sequence
+grammar = Sequitur.build_from(input_sequence)
+
+
+# Use a formatter to display the grammar rules on the console output
+formatter = Sequitur::Formatter::BaseText.new(STDOUT)
+
+# Now render the rules
+formatter.render(grammar.visitor)
+
+# Rendered output is:
+# start : P1 P2 P3 P3 5.
+# P1 : 1 2.
+# P2 : P1 3.
+# P3 : P2 4.
+
+# Playing a bit with the API
+# Access last symbol from rhs of start production:
+last_symbol_p0 = grammar.start.rhs.symbols[-1]
+puts last_symbol_p0 # => 5
+
+# Access first symbol from rhs of P1 production:
+first_symbol_p1 = grammar.productions[1].rhs.symbols[0]
+
+puts first_symbol_p1 # => 1
+```
+
+More examples are available in the examples folder.
Copyright
---------
Copyright (c) 2014, Dimitri Geshef. Sequitur is released under the MIT License see [LICENSE.txt](https://github.com/famished-tiger/Sequitur/blob/master/LICENSE.txt) for details.
\ No newline at end of file