C++文本搜索引擎

本文档详细介绍了使用C++编程语言设计和实现一个文本搜索引擎的过程,涉及到数据结构和哈希技术的应用,旨在提高搜索效率和准确性。
摘要由CSDN通过智能技术生成
##实验题目
Complete a text searching engine using hash table.
完成一个文本搜索引擎,使用哈希表

----------
##实验目的
练习哈希算法的使用,对数据结构有一定的概念Age has reached the end of the beginning of a word. May be guilty in his seems to passing a lot of different life became the appearance of the same day. May be back in the past, to oneself the paranoid weird belief disillusionment. These days, my mind has been very messy, in my mind constantly. Always feel oneself should go to do something, or write something. Twenty years of life trajectory deeply shallow, suddenly feel something, do it. 
The end of our life, and can meet many things really do? 
During my childhood, think lucky money and new clothes are necessary for New Year. But as the advance of the age, will be more and more found that those things are optional. Junior high school, thought to have a crush on just means that the real growth. But over the past three years later, his writing of alumni in peace, suddenly found that isn't really grow up, it seems is not so important. Then in high school, think don't want to give vent to out your inner voice can be in the high school children of the feelings in a period. But was eventually infarction when graduation party in the throat, later again stood on the pitch he has sweat profusely, looked at his thrown a basketball hoops, suddenly found himself has already can't remember his appearance. 
Originally, this world, can produce a chemical reaction to an event, in addition to resolutely, have to do, and time.
A person's time, your ideas are always special to clear. Want, want, line is clear, as if nothing could shake his. Also once seemed to be determined to do something, but more often is he backed out at last. Dislike his cowardice, finally found that there are a lot of love, there are a lot of miss, like shadow really have been doomed. Those who do, just green years oneself give oneself an arm injection, or is a self-righteous spiritual. 
At the moment, the sky is dark, the air is fresh factor after just rained. Suddenly thought of blue plaid shirt. Those were broken into various shapes of stationery. From the corner at the beginning of deep friendship. Have declared the end of the encounter that haven't start planning... Those years, those days of do, finally, like youth, will end in our life.

----------
##程序设计
####程序流程图
<img src="https://img-blog.csdn.net/20141130155857906?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxNDQ3MTU1Nw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="" />
####程序代码
#####程序变量
    const int HASH_SIZE=100;
    vector<string> container;
    struct hash_node{
     int number;
     string key;
     hash_node* next;
     hash_node(string a="",int b=0,hash_node* c=NULL);
    };
    hash_node* hash_chain=NULL;
    string word;
#####初始化
方法是从文件流单个读取字符,遇到句号,问号,感叹号和省略号都视为断句标志,利用了char和string之间的转换,出现bug的情况是句子字符长度超过1024,这个概率太小。程序兼顾了去除前导空格的功能。
    bool ReadFile(string source){//读取文件并存储 
     ifstream fin;
     fin.open(source.c_str());
     if(!fin){//打开文件失败 
      cout<<"Unable to open "<<source<<"."<<endl;
      return false;
     }
     //cout<<"open success"<<endl;
     container.clear();
     char buffer[1024]={0};
     int k=0;
     string temp;
     while(!fin.eof()){
      buffer[k++]=fin.get();
      //断句符有三个 
      if(buffer[k-1]=='.'||buffer[k-1]=='?'||buffer[k-1]=='!'){
       temp=buffer;
       con
  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值