资源简介
可直接运行,利用空间向量模型建立简单的布尔检索,内含源代码与用于搜索的TXT文本,可以替换

代码片段和文件信息
#include
#include
#include
#include
#include
using namespace std;
const int total=20;
class node
{
friend class suoyin;
public:
char * name;
node * next;
int d[total]; //记录name在第几个文档中出现了几次
int df;
int tf;//记录词项在查询向量中的tf
node()
{ for (int i=0;i {
d[i]=0;
}//初始化d设为不存在
df=0;
tf=0;
};
node(char *a); //初始化,将外部字符串设为name
};
node::node(char *a)
{//初始化,将外部字符串设为name
name = new char [];
name = a;
}
class suoyin
{//倒排索引类
public:
float lenth[total];
float score[total];
node * root ;//记录根节点,创建链表记录倒排索引
suoyin(){root = NULL;}//初始化 root
suoyin & addnode(int knode & a);//将外部节点加入倒排索引
suoyin & delenode();//删除重复名字的节点,并且将记录表合并
int * find(char * x);//按名字查找记录,并且返回记录表(为一个int数组)
void output1();//打印在屏幕上
void output2();//打印在“il.txt“中
suoyin & cosine(char * q);
suoyin & Lenth();
};
suoyin & suoyin::addnode(int knode & a)
{//将外部节点加入倒排索引
node * p=root;
for(int i=1;i p=p->next;//寻找到最后一个节点
node * y =new node;//新建节点y作为桥梁,将新节点加入
y->name=a.name;
for (int ir=0;ir {
y->d[ir]=a.d[ir];
}
if(k!=0)//加入的不是首节点
{
y->next=p->next;
p->next=y;
}
if(k==0)//加入的是首节点
{
y->next=root;
root=y;
}
return * this;//返回新的倒排索引
}
suoyin & suoyin::delenode()
{//删除重复名字的节点,并且将记录表合并
node * p = root;
while (p->next)//遍历倒排索引
{
if (!strcmp(p->next->namep->name))//当名字相同时
{//合并记录表,并将第二个节点删除
for(int i=0;i {
p->d[i]=p->d[i]+p->next->d[i];
}
p->next=p->next->next;
}
else p=p->next;//名字不同时,放过
}
return * this;//返回新的倒排索引
}
int * suoyin::find(char * a)
{//按名字查找记录,并且返回记录表(为一个int数组)
int results[total];//记录查询结果
for(int i=0;i {
results[i]=-1;//先初始化为-1
}
node * current=root;
while(strcmp(current->namea)!=0)
{
current=current->next;
}
if(current)//找到对应的名字
{//返回相应的记录表
for (int i=0;i {
results[i]=current->d[i];
}
return results;
}
return results; //没找到对应的名字,返回值为-1的记录表
}
void suoyin::output1()
{//打印在屏幕上
node * current;
for(current=root;current;current=current->next)
{
int fre=0;
for (int i=0;i {
fre=fre+current->d[i];
}
cout<name<<“ fre:“< for (int iw=0;iw if (current->d[iw])cout<<“ ->“<d[iw]<<“)“;
cout< }
}
void change (node & xnode & y)
{//外部函数,按名字排列时,交换两个词项的顺序
char * temp=new char [strlen(x.name)+1];//交换名字
strcpy(tempx.name);
strcpy(x.namey.name);
strcpy(y.nametemp);
for (int i=0;i {
int dtemp=x.d[i];//交换记录表
x.d[i]=y.d[i];
y.d[i]=dtemp;
}
};
void copy(char * achar * bint iint j)
{//外部函数,将a字符串的第i位到第j位复制到b字符串中,处理布尔查询表达式时用
int count;
for(count=0;count {
b[count]=a[i+count];
}
b[count]=‘\0‘;
};
///////////////////////////////////////////////////////////////////////////////
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 75 2013-09-24 21:35 1.txt
文件 141 2013-11-04 20:34 10.txt
文件 153 2013-11-04 20:34 11.txt
文件 192 2013-11-04 20:37 12.txt
文件 141 2013-11-04 20:36 13.txt
文件 135 2013-11-04 20:35 14.txt
文件 78 2013-11-08 23:16 15.txt
文件 139 2013-11-04 20:35 16.txt
文件 133 2013-11-04 20:37 17.txt
文件 129 2013-11-04 20:35 18.txt
文件 179 2013-11-04 21:49 19.txt
文件 80 2013-09-24 21:35 2.txt
文件 128 2013-11-04 20:36 20.txt
文件 132 2013-11-04 20:29 3.txt
文件 93 2013-11-04 20:30 4.txt
文件 139 2013-11-04 20:31 5.txt
文件 93 2013-11-04 20:32 6.txt
文件 129 2013-11-04 20:32 7.txt
文件 135 2013-11-08 23:04 8.txt
文件 131 2013-11-04 20:34 9.txt
文件 10003 2013-11-08 23:15 ddd.cpp
文件 103424 2013-11-08 23:23 信息检索3_实验报告.dot
目录 0 2014-01-14 20:10 空间向量模型\
文件 75 2013-09-24 21:35 空间向量模型\1.txt
文件 141 2013-11-04 20:34 空间向量模型\10.txt
文件 153 2013-11-04 20:34 空间向量模型\11.txt
文件 192 2013-11-04 20:37 空间向量模型\12.txt
文件 141 2013-11-04 20:36 空间向量模型\13.txt
文件 135 2013-11-04 20:35 空间向量模型\14.txt
文件 78 2013-11-08 23:16 空间向量模型\15.txt
文件 139 2013-11-04 20:35 空间向量模型\16.txt
............此处省略26个文件信息
- 上一篇:ESP8266一键烧写工具
- 下一篇:fragstat4.2
相关资源
- VisualStudioUninstaller vs卸载工具
- 组态王驱动开发包3.0.0.7(中文)
- 多窗口后台鼠标连点器
- 使用选择性重传协议实现UDP可靠通信
- VC 获得文件属性 获取文件的创建时
- 读者写者问题(读者优先,写者优先
- 用VC 编写的仿QQ聊天室程序源代码
- 外点法程序
- 外罚函数程序
- qt-电子点菜系统
- 推箱子及人工智能寻路C 源代码
- 自己写的航空订票系统c 版--数据结构
- 数据结构实验魔王语言
- MUSIC算法c 实现
- C 餐厅叫号系统(QT平)
- 国际象棋c 完整版
-
ob
jectARX给Auto CAD加工具条 - 画图程序MFC/VC/VC CRectTracker 串行化
- MFC网络编程实例
- c 课程设计 职工信息管理系统
- VC 游戏编程—附源代码
- IpHlpApi.h&IpHlpApi.lib
- 清华大学 c 郑莉 ppt课件
- c 程序判断离散数学中命题公式
- 多项式求和(数据结构C 版)
- vc 6.0开发的流程图编辑器
- VC 天空盒(skyBox)实现(附源代码)
- c MFC 画多边形
- 用C 实现的对网络上的ARP数据包进行
- Microsoft基本类库 (MFC)(C 库)
评论
共有 条评论