1. A method for measuring similarity between clustered data grammars, comprising: receiving, at an apparatus having one or more processors, at least a first data stream from a first device and a second data stream from a second device, wherein the first data stream and the second data stream each include one or more sequenced data items; constructing, by the one or more processors, at least a first grammar associated with the first device and a second grammar associated with the second device, wherein the first grammar and the second grammar each comprise a symbol sequence that re-expresses the one or more sequenced data items in the respective data streams received from the first device and the second device; calculating, by the one or more processors, one or more distance metrics that quantify a similarity between the first grammar and the second grammar according to a comparison between one or more rules that represent a repeated pattern in the symbol sequence associated with the first grammar and one or more rules that represent a repeated pattern in the symbol sequence associated with the second grammar; and determining, by the one or more processors, a relationship between the first device and the second device according to the one or more distance metrics.
9. The method recited in claim 1 , wherein the one or more distance metrics include an integer score that indicates a nesting level associated with the one or more rules in the first grammar and the one or more rules in the second grammar.