简体   繁体   English

TF-IDF矢量化器搜索查询Python

[英]TF-IDF Vectorizer Search Query Python

I have converted some documents to create a TF-IDF Vectorizer. 我已经转换了一些文档来创建TF-IDF Vectorizer。 Now I want to handle search queries and return list of pages in decreasing order of TF-IDF value. 现在,我想处理搜索查询并以TF-IDF值的降序返回页面列表。 I am able to get the position of the query term in the 'vocabulary_'. 我能够获取查询词在“ vocabulary_”中的位置。 However as it is a sparse matrix, I am not able to read the tf-idf value at that index. 但是,由于它是一个稀疏矩阵,因此我无法读取该索引处的tf-idf值。 Any help would be much appreciated. 任何帮助将非常感激。 Regards 问候

You need to call todense() on the element before you read it. 在阅读元素之前,需要在元素上调用todense()

Reference: scipy.sparse.lil_matrix.todense 参考: scipy.sparse.lil_matrix.todense

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

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