随笔分类 -  tse

pagerank 算法入门
摘要:http://blog.csdn.net/midgard/article/details/7061721这篇文章很不错。 1 #include <vector> 2 #include <set> 3 #include <string> 4 #include <iostream> 5 6 using namespace std; 7 8 // use graph store webpage, weight representlink times 9 class Node {10 public:11 explicit Node(string name 阅读全文

posted @ 2012-08-24 15:11 kakamilan 阅读(350) 评论(0) 推荐(0)

修改网页排名
摘要:很久以前就听说过“竞价排名”,今天基于TSE也写了一个自己理解的竞价排名雏形,满有意思的。现在必须手动加入排名靠前的url。要在CQuery模块中加入一个方法 1 bool CQuery::Get_url_weight(set<string>& weight_set) const { 2 ifstream ifs(Url_Weight_NAME.c_str(), ios::binary); 3 if (!ifs) { 4 cerr << "Cannot open " << Url_Weight_NAME << &quo 阅读全文

posted @ 2012-08-19 14:32 kakamilan 阅读(271) 评论(0) 推荐(0)

TSE中关于分词的算法的改写--最少切分
摘要:今天比较闲,想到以前也看了好多tse的代码,还没有上手改过呢,一时也不知从何入手,后来在书上看到了分词的算法,TSE用的是正向最大匹配,其中貌似有个好玩的算法-----最少切分,捣鼓了一下午,终于把代码弄出来了。如果有人有兴趣的话,在HzSeg中修改SegmentSentenceMM函数的代码,将s2+=SegmentHzStrMM(dict, s1.substr(0,i));改成s2+=SegmentHzStr_min_cut(dict, s1.substr(0,i));就OK了。代码显得还是有些冗余,还是有优化的余地的,有时间再改吧。 1 string get_res(map<int 阅读全文

posted @ 2012-08-04 22:20 kakamilan 阅读(1539) 评论(0) 推荐(0)

CrtInvertedIdx
摘要:1 // ./CrtInvertedIdx moon.fidx.sort > sun.iidx 2 #include <iostream> 3 #include <fstream> 4 5 using namespace std; 6 7 int main(int argc, char* argv[]) 8 { 9 ifstream ifsImgInfo(argv[1]);//打开输入流10 if (!ifsImgInfo) {11 cerr << "Cannot open " << argv[1] << & 阅读全文

posted @ 2012-07-15 15:08 kakamilan 阅读(184) 评论(0) 推荐(0)

Crtforwardidx
摘要:1 //./ForwardDocIdx Tianwang.raw.2559638448.seg > moon.fdx 2 #include <iostream> 3 #include <fstream> 4 5 using namespace std; 6 7 const string SEPARATOR("/ "); //词间分割符 8 int main(int argc, char* argv[]) 9 {10 ifstream ifsImgInfo(argv[1]);//打开输入流11 if (!ifsImgInfo) {12 ce... 阅读全文

posted @ 2012-07-15 14:50 kakamilan 阅读(152) 评论(0) 推荐(0)

CHzSeg
摘要:1 #ifndef _HZSEG_H_040415_ 2 #define _HZSEG_H_040415_ 3 4 #include <iostream> 5 #include <string> 6 #include <cstring> 7 #include <cstdlib> 8 #include <fstream> 9 #include "Dict.h"10 11 using namespace std;12 13 class CHzSeg14 {15 public:16 CHzSeg();17 ~CHzSeg 阅读全文

posted @ 2012-07-14 20:59 kakamilan 阅读(222) 评论(0) 推荐(0)

CDocument
摘要:1 #ifndef _Document_H_040410_ 2 #define _Document_H_040410_ 3 4 #include <string> 5 6 typedef struct{ 7 int docid; 8 int offset; 9 }DocIdx;10 11 using namespace std;12 13 class CDocument14 {15 public:16 17 int m_nDocId;18 int m_nPos;19 int m_nLength;20 string m_sCh... 阅读全文

posted @ 2012-07-14 13:55 kakamilan 阅读(308) 评论(0) 推荐(0)

DocSegment.cpp
摘要:1 /* 2 * DocSegment.cpp 3 * Created on: 2011-11-10 4 * function:分析网页算法的实现 5 * 将原始网页库中存储的网页转化为 6 * 一组词的集合. 7 */ 8 #include <algorithm> 9 #include <fstream> 10 #include <iostream> 11 #include <map> 12 #include <vector> 13 14 #include "Md5.h" 15 #include "Ur 阅读全文

posted @ 2012-07-14 13:37 kakamilan 阅读(337) 评论(0) 推荐(0)

DocIndex
摘要:1 #include <iostream> 2 #include <fstream> 3 #include <cstring> 4 #include "Md5.h" 5 #include "Url.h" 6 #include "Document.h" 7 8 using namespace std; 9 10 int main(int argc, char* argv[]) {/* 11 * DocIndex.cpp 12 * Created on: 2011-11-9 13 * function: 阅读全文

posted @ 2012-07-08 10:56 kakamilan 阅读(229) 评论(0) 推荐(0)

CTianwangFile
摘要:1 #ifndef _TIANWANG_FILE_H_031104_ 2 #define _TIANWANG_FILE_H_031104_ 3 4 #include "Tse.h" 5 #include "Url.h" 6 #include "Page.h" 7 #include "FileEngine.h" 8 9 class CTianwangFile : public CFileEngine10 {11 public:12 CTianwangFile(string str);13 CTianwangFile( 阅读全文

posted @ 2012-07-07 16:54 kakamilan 阅读(236) 评论(0) 推荐(0)

CLink4SEFile
摘要:1 #ifndef _LINK4SE_FILE_H_031208_ 2 #define _LINK4SE_FILE_H_031208_ 3 4 #include "Tse.h" 5 #include "Url.h" 6 #include "Page.h" 7 #include "FileEngine.h" 8 9 class CLink4SEFile : public CFileEngine10 {11 public:12 CLink4SEFile(string str);13 CLink4SEFile();14 阅读全文

posted @ 2012-07-07 16:47 kakamilan 阅读(256) 评论(0) 推荐(0)

CIsamFile
摘要:1 #ifndef _ISAM_FILE_H_031105_ 2 #define _ISAM_FILE_H_031105_ 3 4 #include "FileEngine.h" 5 6 class CIsamFile : public CFileEngine 7 { 8 public: 9 string m_sIndexFileName;10 FILE *fpDataFile;11 FILE *fpIdxFile;12 13 public:14 CIsamFile();15 CIsamFile(string str);16 CIsamFi... 阅读全文

posted @ 2012-07-07 16:37 kakamilan 阅读(209) 评论(0) 推荐(0)

CDatabaseEngine
摘要:1 #ifndef _DATABASE_ENGINE_H_031104_ 2 #define _DATABASE_ENGINE_H_031104_ 3 4 #include "DataEngine.h" 5 6 class CDatabaseEngine : public CDataEngine 7 { 8 public: 9 CDatabaseEngine(string str);10 virtual ~CDatabaseEngine();11 12 int GetEngineType() { return DATABASE_ENGINE; }13 14 };1... 阅读全文

posted @ 2012-07-07 16:32 kakamilan 阅读(178) 评论(0) 推荐(0)

CFileEngine
摘要:1 #ifndef _FILE_ENGINE_H_031104_ 2 #define _FILE_ENGINE_H_031104_ 3 4 #include "DataEngine.h" 5 6 enum fileengine_type 7 { 8 ISAM, 9 TIANWANG,10 LINK4SE11 };12 13 class CUrl;14 class CPage;15 16 struct file_arg17 {18 CUrl *pUrl;19 CPage *pPage;20 };21 22 class CFileEngine : pu... 阅读全文

posted @ 2012-07-07 16:27 kakamilan 阅读(166) 评论(0) 推荐(0)

CDataEngine
摘要:1 #ifndef _DATA_ENGINE_H_031104 2 #define _DATA_ENGINE_H_031104 3 4 #include "Tse.h" 5 6 enum dataengine_type 7 { 8 FILE_ENGINE, 9 DATABASE_ENGINE10 };11 12 class CDataEngine13 {14 public:15 string m_str; // database engine ---connecting string16 // file engine ---file path & name... 阅读全文

posted @ 2012-07-07 16:21 kakamilan 阅读(162) 评论(0) 推荐(0)

CCrawl
摘要:1 #ifndef _Crawl_H_031104_ 2 #define _Crawl_H_031104_ 3 4 //#include <openssl/md5.h> 5 #include <zlib.h> 6 7 #include "Tse.h" 8 #include "Http.h" 9 #include "StrFun.h"10 #include "Url.h"11 #include "Page.h"12 #include "TianwangFile.h 阅读全文

posted @ 2012-07-06 15:38 kakamilan 阅读(804) 评论(0) 推荐(0)

CHttp
摘要:1 #ifndef _HTTP_H_031105_ 2 #define _HTTP_H_031105_ 3 4 #include <map> 5 6 using namespace std; 7 8 class CHttp 9 {10 private:11 string m_strUrl; // url12 int *m_sock; // socket13 14 public:15 CHttp();16 virtual ~CHttp();17 18 19 //strUrl: 待抓取的网页对应的URL20 //file... 阅读全文

posted @ 2012-07-06 09:41 kakamilan 阅读(3225) 评论(0) 推荐(0)

CUrl
摘要:1 #ifndef _URL_H_030728_ 2 #define _URL_H_030728_ 3 4 #include <string> 5 6 const unsigned int URL_LEN = 256; 7 const unsigned int HOST_LEN = 256; 8 9 using namespace std;10 11 12 enum url_scheme {13 SCHEME_HTTP,14 SCHEME_FTP,15 SCHEME_INVALID16 };17 18 const int DEFAULT_HTTP_P... 阅读全文

posted @ 2012-07-05 21:09 kakamilan 阅读(740) 评论(0) 推荐(0)

CPage
摘要:1 #ifndef _Page_H_030728_ 2 #define _Page_H_030728_ 3 4 #include <string> 5 #include <map> 6 #include <vector> 7 #include <list> 8 #include "Url.h" 9 #include "list.h" 10 #include "uri.h" 11 #include "hlink.h" 12 13 14 //large enough to 阅读全文

posted @ 2012-07-05 15:00 kakamilan 阅读(2573) 评论(0) 推荐(0)

半年学习tse的总结
摘要:从今年2月开学以后就一直在业余时间看与tse相关的东西,终于到了放假的时间了,所以决定总结一下,主要是以代码为主,太理论的东西不适合我,所以接下来我要贴上我阅读过程中的tse的所有代码,以及各种渠道获得的注释,由于有一段时间不看了,我争取每天更新一个模块。源代码http://net.pku.edu.cn/~webg/src/TSE/下面是所有的模块,会逐步完善。模块名称文件链接CStrFunstrfun.h strfun.cpphttp://www.cnblogs.com/kakamilan/archive/2012/07/01/2571973.htmlCPagepage.h page.cpp 阅读全文

posted @ 2012-07-01 15:59 kakamilan 阅读(408) 评论(0) 推荐(0)

导航