没有合适的资源?快使用搜索试试~ 我知道了~
《信息检索导论》课后习题答案1
需积分: 0 76 下载量 43 浏览量
2022-08-04
16:45:00
上传
评论 10
收藏 168KB PDF 举报
温馨提示
试读
13页
第一章布尔检索习题 1-2考虑如下几篇文档:文档 1breakthrough drug for schizophrenia文档 2new schizophren
资源详情
资源评论
资源推荐
《信息组织与检索》作业答案
第一章 布尔检索
习题 1-2
考虑如下几篇文档:
文档 1 breakthrough drug for schizophrenia
文档 2 new schizophrenia drug
文档 3 new approach for treatment of schizophrenia
文档 4 new hopes for schizophrenia patients
a. 画出文档集对应的词项—文档矩阵;
b. 画出该文档集的倒排索引(参考图 1-3 中的例子)。
Term-Documentmatrix:
1 2 3 4
approach 0 0 1 0
breakthrough 1 0 0 0
drug 1 1 0 0
for 1 0 1 1
hopes 0 0 0 1
new 0 1 1 1
of 0 0 1 0
patients 0 0 0 1
schizophrenia 1 1 1 1
treatment 0 0 1 0
Inverted Index:
approach -> 3
breakthrough ->1
drug ->1->2
for ->1->3->4
hopes ->4
new ->2->3->4
of ->3
patients ->4
schizophrenia ->1->2->3->4
treatment >3
注意:倒排索引中的词表( dictionary )和每个词项的倒排列表( posting list )需要排序,便
于查找。这里我们暂不考虑词的正规化处理(如 hopes->hope)。
补充习题 1
写出 AND 查询的伪代码
面向过程风格的伪代码:
给定两个指针 p1 和 p2,分别指向两倒排列表 list1 和 list2(链表实现) 的首元素; 令 docId(p1)
表示 p1 所指向的元素的 docId 查询结果存放在 answer 列表里。
这里应用了“化归”思想(将新问题转化归为旧问题来解决) 。这里,比较两排序列表的首
元素,排除较小的 docId(不可能有匹配)后,我们构造出新的剩余列表,再次进行两列表
的首元素的比较。
While p1 != null AND p2 != null
If p1->docId==p2->docId // 对两(剩余)列表的首元素进行比较
insert(answer, p1) ;
p1=p1->next; // 构造新的剩余列表,迭代执行
p2=p2->next; //
Else if p1->docId < p2->docId
p1=p1->next; //p1->docId 不可能有匹配;构造新的剩余列表
Else
p2=p2->next; //p2->docId 不可能有匹配;构造新的剩余列表
End
面向对象风格的伪代码:
注:为一个数据结构(对象)定义方法,通过方法操作自己的内部数据( List 对象里隐
含包含了一个成员变量,它是真正的链表或变长数组) 。
While list1.currentItem() != null AND list2.currentItem() != null
If list1.currentItem().getDocId() == list2.currentItem().getDocId()
answer.insert(list1.currentItem());
list1.moveToNext();
list2.moveToNext();
Else if list1.currentItem().getDocId() < list2.currentItem().getDocId()
list1.moveToNext();
Else
list2.moveToNext();
End
习题 1-10
写出 OR 查询的伪代码
面向过程风格的伪代码:
给定两个指针 p1 和 p2,分别指向两倒排列表 list1 和 list2(链表实现) 的首元素; 令 docId(p1)
表示 p1 所指向的元素的 docId;查询结果存放在 answer 列表里。
While p1 != null AND p2 != null
If p1->docId == p2->docId
insert(answer, p1) ;
p1=p1->next;
p2=p2->next; // 构造新的剩余列表,迭代执行
Else if p1->docId < p2->docId
insert(answer, p1) ;
p1=p1->next; // 构造新的剩余列表,迭代执行
Else
insert(answer, p2) ;
p2=p2->next; // 构造新的剩余列表,迭代执行
End
While p1 != null// 条件为真时,加入 list1 的剩余元素(此时 list2 已遍历到结尾)
insert(answer, p1) ;
p1=p1->next;
END
While p2 != null// 条件为真时,加入 list2 的剩余元素(此时 list1 已遍历到结尾)
insert(answer, p2) ;
p2=p1->next;
END
面向对象风格的伪代码:
While list1.currentItem() != null AND list2.currentItem() != null
If list1.currentItem().getDocId() == list2.currentItem().getDocId()
answer.insert(list1.currentItem());
list1.moveToNext();
list2.moveToNext();
Else if list1.currentItem().getDocId() < list2.currentItem().getDocId()
answer.insert(list1.currentItem());
list1.moveToNext();
剩余12页未读,继续阅读
士多霹雳酱
- 粉丝: 22
- 资源: 299
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0