compound context seq fn: scompress


scompress:
    description:
        scompress[source-op, dest-op]
        scompress[source-op, dest-op, "str"]
        scompress[source-op, dest-op, "str", min-ngram-len, max-ngram-len]
        reads in all the patterns that are defined with respect to 'source-op'
        then breaks those patterns into smaller and smaller ngrams
        counting the frequency of those ngrams
        for a given ngram size, the first, most common, ngram is then promoted to its own pattern
        repeat, until ngram size is 1
        then save all the new patterns with respect to the 'dest-op' operator
        If "str" is given, use that instead of "scompress: ".

    examples:
        -- learn a couple of simple sequences, that have shared 'ngram structure':
        seq |one> => |A> . |B> . |C> . |D> . |E> . |F>
        seq |two> => |G> . |B> . |C> . |H> . |B> . |C> . |D> . |X> . |Y>

        -- in this case we have shared ngrams: |B> . |C> . |D> and |B> . |C>

        -- now run the operator:
        scompress[seq, new-seq]

        -- now dump the results:
        dump
            ------------------------------------------
            |context> => |Global context>

            seq |one> => |A> . |B> . |C> . |D> . |E> . |F>
            new-seq |one> => |A> . |scompress: 0> . |E> . |F>

            seq |two> => |G> . |B> . |C> . |H> . |B> . |C> . |D> . |X> . |Y>
            new-seq |two> => |G> . |scompress: 1> . |H> . |scompress: 0> . |X> . |Y>

            new-seq |scompress: 1> => |B> . |C>

            new-seq |scompress: 0> => |scompress: 1> . |D>

            new-seq |*> #=> |_self>
            ------------------------------------------

        -- We can then recover the original sequences using: 'dest-op^k'
        -- where k is in some sense a measure of the depth of the hierarchy of the system.

        -- Let's demonstrate:
        new-seq |one>
            |A> . |scompress: 0> . |E> . |F>

        new-seq^2 |one>
            |A> . |scompress: 1> . |D> . |E> . |F>

        new-seq^3 |one>
            |A> . |B> . |C> . |D> . |E> . |F>


        new-seq |two>
            |G> . |scompress: 1> . |H> . |scompress: 0> . |X> . |Y>

        new-seq^2 |two>
            |G> . |B> . |C> . |H> . |scompress: 1> . |D> . |X> . |Y>

        new-seq^3 |two>
            |G> . |B> . |C> . |H> . |B> . |C> . |D> . |X> . |Y>

        -- And in this case we see we recover the original sequences when k is 3.
        -- So that is the hierarchical depth of this system.

    see also:

Home