You are not logged in.

Change Language:

Freelancer? Consultant? Check out: WorkTrail - Time Tracking made easy
Board » Django » Python Programming » problem in returning the value

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.





Powered by Sphene Community Tools