繁体   English   中英

嵌套函数调用和缺少输入参数,python

[英]Nested function calls and missing input parameter, python

我尝试了一些文本分类教程在这里

我不理解第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)

是否不应该使用words的字符串输入值来调用make_full_dict

没有更多的背景信息,很难完全回答您的问题。 似乎evaluate_features方法采用函数作为参数。 在这种情况下,您无需调用作为参数传入的函数。 只有evaluate_features应该这样做。 如果调用该函数,则该函数的返回值将是evaluate_features _功能将获得的值,而不是该函数本身

如果要查看该函数的功能,请在make_full_dict方法中添加一些打印语句,以帮助您查看传递给它的单词

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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