Read the grammar hidden in your time series.
GrammarViz discretizes a signal into symbols, induces a context-free grammar over them, and turns the grammar's rare and frequent rules into variable-length anomalies and motifs — interactively, as the signal streams in.
Two linear-time algorithms, one interactive tool
Pattern discovery rests on Symbolic Aggregate approXimation (SAX), which turns the signal into a string, and a grammar-induction step — Sequitur or Re-Pair — which builds a context-free grammar from that string. Exploiting the grammar's hierarchy, rare and frequent rules surface as anomalies and motifs of varying length.
Anomaly discovery
Rare Rule Anomaly (RRA) and the rule-density curve find surprising subsequences of variable length, without fixing the anomaly length up front. RRA computes far fewer distances than HOT-SAX.
02 / motifMotif discovery
The most-used grammar rules correspond to recurrent patterns. Numerosity reduction and the CFG hierarchy let a single rule span motifs of different lengths.
03 / tuningParameter optimization
A grammar-reduction heuristic searches the discretization space automatically, ranking the window / PAA / alphabet settings that describe the series most compactly.
In wall-clock time HOT-SAX is faster than RRA on every series of the current RRA vs HOT-SAX benchmark, from 2,299 to 100,000 points.
Run it as a desktop app, a CLI, or a library
GrammarViz 3.0 is pure Java and needs Java 21 or newer. Drive the interactive Swing GUI for exploration, script the command line for batch jobs, or link the core as a dependency. The GUI follows an MVC split so the discovery engine is reusable on its own.
You can watch grammar rules form in real time as a signal is acquired.
Getting started
- Install Java 21 or newer;
java -versionprints the version you have. Older Java versions refuse to run the jar. - Download
grammarviz2-3.0.7-jar-with-dependencies.jarfrom the 3.0.7 release. - Start the GUI, with up to 4 GB of memory:
java -Xmx4g -jar grammarviz2-3.0.7-jar-with-dependencies.jar - Or run the anomaly CLI on the ECG 0606 series (
ecg0606_1.csv); run it without arguments to print its options:java -cp grammarviz2-3.0.7-jar-with-dependencies.jar net.seninp.grammarviz.GrammarVizAnomaly \ -alg RRA -i ecg0606_1.csv -w 100 -p 5 -a 5 --strategy NONE

Get the library
Add the dependency
GrammarViz ships as net.seninp:grammarviz2:3.0.7 on Maven Central. Download the self-contained jar from the latest release, or build it with mvn -Psingle package in the source repository.
<dependency>
<groupId>net.seninp</groupId>
<artifactId>grammarviz2</artifactId>
<version>3.0.7</version>
</dependency>Cite the work
Senin, P., Lin, J., Wang, X., Oates, T., Gandhi, S., Boedihardjo, A.P., Chen, C., Frankenstein, S. GrammarViz 3.0: Interactive Discovery of Variable-Length Time Series Patterns. ACM TKDD, 2018.