惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
P
Privacy International News Feed
T
Tenable Blog
L
Lohrmann on Cybersecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threat Research - Cisco Blogs
S
Securelist
C
CXSECURITY Database RSS Feed - CXSecurity.com
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
S
Schneier on Security
P
Privacy & Cybersecurity Law Blog
Vercel News
Vercel News
Cyberwarzone
Cyberwarzone
月光博客
月光博客
T
The Blog of Author Tim Ferriss
Scott Helme
Scott Helme
爱范儿
爱范儿
Stack Overflow Blog
Stack Overflow Blog
C
Cisco Blogs
aimingoo的专栏
aimingoo的专栏
博客园 - 司徒正美
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
P
Proofpoint News Feed
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
LangChain Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
阮一峰的网络日志
阮一峰的网络日志
Simon Willison's Weblog
Simon Willison's Weblog
T
Tor Project blog
Security Latest
Security Latest
Blog — PlanetScale
Blog — PlanetScale
G
GRAHAM CLULEY
V
Vulnerabilities – Threatpost
博客园 - 三生石上(FineUI控件)
I
InfoQ
Spread Privacy
Spread Privacy
B
Blog RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
S
SegmentFault 最新的问题
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
MongoDB | Blog
MongoDB | Blog
C
CERT Recently Published Vulnerability Notes
A
About on SuperTechFans
博客园_首页
Engineering at Meta
Engineering at Meta
Project Zero
Project Zero
Latest news
Latest news

博客园 - AI产品观察

公式截图怎么转LaTeX代码?这个免费工具一键搞定 免费白嫖Google顶尖算力?深度揭秘这个满血版Gemini 3 Pro体验入口 深度解析 VoGen:2026 年最强免费 AI 语音合成与情感克隆技术方案 分享一个网站,Crealens.ai - 可以免费体验 AI图像/视频 生成-编辑-创作 WriteRightly 这个AI 可以像教授一样批改论文 免费、快速、可靠:揭秘IsGPT如何精准检测AI内容 Crealens.ai 免费体验GPT-4o 生图+吉卜力风格化 目标检测-基于Pytorch实现Yolov3(1)- 搭建模型 openpose模型在AI challenge人体骨骼关键点检测的表现 隐马尔可夫模型(HMM) 概率生成模型 卷积神经网络经验-CS231n笔记 双显卡笔记本安装CUDA+theano、tensorflow环境 Exynos 4412 Uboot源码解析 隐马尔可夫模型 基于WDF的PCI/PCIe接口卡Windows驱动程序(5)-如何为硬件移植驱动程序 进程详解(1)——可能是最深入浅出的进程学习笔记 贪吃蛇游戏C语言源代码学习 经典功率谱估计及Matlab仿真 CAN总线(一)
01布尔模型&倒排索引
AI产品观察 · 2018-01-30 · via 博客园 - AI产品观察

原文链接: http://www.cnblogs.com/jacklu/p/8379726.html

博士一年级选了这门课 SEEM 5680 Text Mining Models and Applications,记下来以便以后查阅。

1. 信息检索的布尔模型

用0和1表示某个词是否出现在文档中。如下图例子,要回答“Brutus AND Caesar but NOT Calpurnia”,我们需要对词的向量做布尔运算,即110100 AND 110111 AND 101111=100100 对应的文档是Antony and Cleopatra和Hamlet

然而这种方法随着数据的增大是非常耗费空间的。比如我们有100万个文档,每个文档平均有1000字,总共有50万个不同的词语,那么矩阵将是500 000 x 1 000 000。这个矩阵是稀疏的,1的个数一般不会超过1亿个。

2. 倒排索引

倒排索引是为了解决上述布尔模型的问题。具体来说,每个词用链表顺序存储文档编号。如下图所示:

建立索引的核心是将词按字母顺序排列,合并重复词,但是要记录词频。

3. 倒排索引模型中对查询语句(AND)的处理

1、求Brutus AND Calpurnia,即求两个链表的交集。

算法思路是如果文档号不同就移动较小的指针,伪代码 INTERSECTION(p1, p2):

answer<-()
while p1 != NIL and p2 != NIL
do if docID(p1) = docID(p2)
     then ADD(answer, docID(p1))
         p1 <-next(p1)
         p2 <-next(p2)
     else if docID(p1) < docID(p2)
         p1 <-next(p1)
     else p2<-next(p2)
return answer

思考题,有两个词项A,B,其文档编号链表长度分别为3和5,那么对A,B求交集,最少的访问次数和最多的访问次数分别是多少?各举一个例子

最少访问次数是4,比如A:1-2-3,B:3-4-5-6-7;最多访问次数是8,比如A:1-7-8, B:3-4-5-7-9

2、思考题:求Brutus OR Calpurnia,即求两个链表的并集。伪代码 UNION(p1,p2):

answer<-()
while p1 != NIL and p2 != NIL
do if docID(p1) = docID(p2)
    then ADD(answer, docID(p1))
        p1 <-next(p1)
        p2 <-next(p2)
    else if docID(p1) < docID(p2)
    then ADD(answer, docID(p1))
        p1<-next(p1)
    else ADD(answer, docID(p2))
        p2<-next(p2)
return answer

3、思考题:求Brutus AND NOT Calpurnia。伪代码 INTERSECTION(p1,p2, AND NOT):

answer<-()
while p1 != NIL and p2 != NIL
do if docID(p1) = docID(p2)
        p1 <-next(p1)
        p2 <-next(p2)
    else if docID(p1) < docID(p2)
    then ADD(answer, docID(p1))
        p1<-next(p1)
    else p2<-next(p2)
    
    if p1 != NIL and P2 = NIL
    then ADD(answer, docID(p1))
        p1<-next(p1)
return answer

参考资料:http://www1.se.cuhk.edu.hk/~seem5680/