简体   繁体   中英

Nested function calls and missing input parameter, python

I'm trying out some Text Classification tutorials here :

I don't understand the function calls in line 59 -- 65:

#creates a feature selection mechanism that uses all words
def make_full_dict(words):
    return dict([(word, True) for word in words])

#tries using all words as the feature selection mechanism
print 'using all words as features'
evaluate_features(make_full_dict)

Shouldn't make_full_dict be called with a string input value for words ?

Without further context, it is a bit difficult to give a complete answer to your question. It seems that the evaluate_features method takes a function as parameter; in that case, you don't need to call the function which was passed in as a parameter. Only evaluate_features should do that. If you call the function, then the return value of the function is what evaluate_features will get, rather than the function itself

If you want to see what that function is doing, add some print statements in the make_full_dict method which will help you see what words were passed to it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM