Advertisement

信息检索与数据挖掘——基于倒排索引的算法设计

阅读量:

信息检索实验报告

实验题目

排序检索模型

实验内容概述

  • 在 Homework 1.1 的基础上构建最基础的 Ranked retrieval 模型;
    • 采用 SMART 标注方式:lnc.ltc;
    • 在 Dictionary 及 posting list 中记录每个 term 的 DF 值;

实验过程概述

  • tf与df的存储方式

引入额外的数据结构以分别保存DF信息:

复制代码
    postings = defaultdict(dict)
    document_frequency = defaultdict(int)
    
    
      
      
    

在对tweets进行逐条扫描的过程中,同步记录对应的tf值

复制代码
    unique_terms = set(line)
    for term in unique_terms:
    postings[term][tweetid] = line.count(term)
    
    
      
      
      
    

完成tf处理后生成的输出文件记录如下:

![在这里插入图片描述](https://ad.itadn.com/c/weblog/blog-img/imag

全部评论 (0)

还没有任何评论哟~