@staticmethod
    def match(digram, matching):        
        global num_rules
        if isinstance(matching.p, Guard) and isinstance(matching.n.n, Guard):
            r = matching.p.r
            digram.substitute(r)
        else:
            r = Rule(num_rules)
            num_rules += 1
            first = digram.clone()
            second = digram.n.clone()
            r.guard.n = first
            first.p = r.guard
            first.n = second
            second.p = first
            second.n = r.guard
            r.guard.p = second
            matching.substitute(r)
            digram.substitute(r)
            digrams[str(first.value)+str(first.n.value)] = first
        if isinstance(r.first(), NonTerminal) and r.first().r.count == 1:
            r.first().expand()
Figure out what to do with a matching digram.
dataset/ETHPy150Open ResilientScience/wot/wot/sequitur.py/Symbol.match