Hi Yaser, I can't get it compiled since the statement is not defined. Can you include few more lines of code so that it compiles?
And what is ``k`` here? Is it a number or a symbol? Regards, Thilina. On Mon, Sep 9, 2013 at 10:02 PM, Mahmoud Yaser <[email protected]>wrote: > I am implementing the general `N-Grams` using `SymPy` > > the equation is: > p(w1, w2, .... wn) = ∏ p(wi | wi-k, .... wi-1) > > the input words is tuple tuple([w1, w2, w3, ... wn]) > > I tried to use `sympy.concrete.product.Product` with custom function that > calculates the probability as first argument > > ``` > class Estimator(Function): > @classmethod > def eval(cls, token, history): > return "whatever" > > class _Segment(Function): > @classmethod > def eval(cls, statement, i, k): > return (statement[i], statement[i - k:i - 1]) > > Product(Estimator(_Segment(statement, i, self._k)), (i, 1, len(statement))) > ``` > > and I am getting error `indices must be integers, not Symbol` > k=1m > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sympy. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. For more options, visit https://groups.google.com/groups/opt_out.
