Return the probability of pw under the Weir PCFG model.
        P[{S -> L2D1Y3, L2 -> 'ab', D1 -> '1', Y3 -> '!@#'}]

def prob(self, pw):
        """
        Return the probability of pw under the Weir PCFG model.
        P[{S -> L2D1Y3, L2 -> 'ab', D1 -> '1', Y3 -> '!@#'}]
        """

        tokens = self.pcfgtokensofw(pw)
        S, tokens = tokens[0], tokens[1:]
        l = len(tokens)
        assert l % 2 == 0, "Expecting even number of tokens!. got {}".format(tokens)

        p = float(self._T.get(S, 0.0)) / sum(v for k, v in self._T.items('__S__'))
        for i, t in enumerate(tokens):
            f = self._T.get(t, 0.0)
            if f == 0:
                return 0.0
            if i < l / 2:
                p /= f
            else:
                p *= f
                # print pw, p, t, self._T.get(t)
        return p