Default / 默认 · September 1, 2021

小内存使用gensim 的 tfidf

Table of Content

gensim 的 tfidf 实现,它更有效,并且不需要像这篇文章解释的那样将整个语料库保存在内存中。

https://radimrehurek.com/gensim/models/tfidfmodel.html

“`python

    res = es.search(index=ES_INDEX, body={"query":
    {

    "bool": {
        "should": [
            # { "match": { "code_type": str(code_type) }},

            { "match": { "relatedwords":str(keyword) }},

            # { "match": { "title.shingles": "quick brown fox" }}
        ],
        "must":[
              { "term" : {"code_type" : str(code_type)}},
        ]
        }


    }})

“`

%d bloggers like this: