信息检索:如何计算多个搜索词的tf-idf?
Information Retrieval: How to calculate tf-idf for multiple search terms?
我有以下 4 个文档的语料库:
<1> This is the first document.
<2> And this is the second document.
<3> The third document is longer than the first and second one.
<4> This is the last document.
并使用搜索队列"first OR last",我该如何计算 tf-idf?
目前我正在使用这个:
tf(x, D) = raw frequency of term x in document D / raw frequency of most occurring term in D
idf(x) = log(1 + total number of documents / number of documents containing x)
所以对于队列我得到
<1> = (1 / 1) * log(1 + 4/3)
<3> = (1 / 2) * log(1 + 4/3)
<4> = (1 / 1) * log(1 + 4/3)
这是正确的吗?你如何正确地做到这一点?我是否分别计算所有搜索词的价值然后相加?相乘?
假设当你说 "search queue" 时你的意思是 "search query" 并且你的查询是用逻辑运算符 OR 构造的,你可以构造一个递增的流遇到其中一个术语时的频率。这实际上就是您在上面所做的。
正如您在 post 中所说,另一种方法是在分别计算项向量之后计算项向量的和。但是,乘法不是您正在寻找的选项。
因此,无论哪种方式,您都可以通过这种方式计算从多个术语中构造一个抽象术语。
我有以下 4 个文档的语料库:
<1> This is the first document.
<2> And this is the second document.
<3> The third document is longer than the first and second one.
<4> This is the last document.
并使用搜索队列"first OR last",我该如何计算 tf-idf?
目前我正在使用这个:
tf(x, D) = raw frequency of term x in document D / raw frequency of most occurring term in D
idf(x) = log(1 + total number of documents / number of documents containing x)
所以对于队列我得到
<1> = (1 / 1) * log(1 + 4/3)
<3> = (1 / 2) * log(1 + 4/3)
<4> = (1 / 1) * log(1 + 4/3)
这是正确的吗?你如何正确地做到这一点?我是否分别计算所有搜索词的价值然后相加?相乘?
假设当你说 "search queue" 时你的意思是 "search query" 并且你的查询是用逻辑运算符 OR 构造的,你可以构造一个递增的流遇到其中一个术语时的频率。这实际上就是您在上面所做的。
正如您在 post 中所说,另一种方法是在分别计算项向量之后计算项向量的和。但是,乘法不是您正在寻找的选项。
因此,无论哪种方式,您都可以通过这种方式计算从多个术语中构造一个抽象术语。