this is the class from models.py-
class NatPar(models.Model):
    @staticmethod
    def handle_review(self):
        try:
            grammar=nltk.parse_cfg("""
            S->VP NP
            PP->P N
            NP->Det N PP
            VP->V Det
            Det ->'me'|'the'
            N->'review'|'DON'
            V->'Give'
            P->'of'
            """)
            sent=['Give','me','the','review','of','DON']
            parser=nltk.ChartParser(grammar)
            trees=parser.nbest_parse(sent)
            for tree in trees:
                print tree
            tokens=find_all_NP(tree)
            print tokens
            return tokens
        except:
            return None



    def find_all_NP(tree):
        if  type(tree)==type('string'):
            return None

        if tree.node=='NP':
            return '-'.join(tree.leaves())

        return [npstr for npstr in [find_all_NP(node) for node in
tree[0:]] if npstr]


and calling function is like this-

response=NatPar.handle_review

        return render_to_response('review1.html',
{'response':response})

and its displays template like this--

<function handle_review at 0x0237D030>

             so what's the problem in handle review..I already checked
the code on python shell n its working there.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to