-
Notifications
You must be signed in to change notification settings - Fork 1
/
MyFc.h
73 lines (47 loc) · 1.22 KB
/
MyFc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// 中文分词
#ifndef MY_ZWFC
#define MY_ZWFC
#include "stdafx.h"
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<stack>
using namespace std;
const int s1 = 0XB0,s2 = 0XA1,e1 = 0XF8,e2 = 0XFF;
const int maxwordlen = 50;
struct Second
{
string key;
Second *next;
Second(string k = "",Second *n = 0):key(k),next(n){}
};
struct Head
{
int size;
string key;
vector<Second*> W;
Head(string k = "",int s = 0):key(k),size(s){}
};
class Dictiory
{
vector<Head> H; //创建空容器,其对象结构类型为Head
ifstream fin; //词典文件
int hash[e1 - s1][e2 - s2]; //哈希表 (散列表),是根据关键码值(Key value)而直接进行访问的数据结构。若关键字为k,则其值存放在f(k)的存储位置上。
int BinarySearch(string str,int k);
int GetNum();
void LoadDic();
void AddWord(string str,int k);
void InsertWord(string str, int k);
bool IsWord(string str,int k,int t);
void SkipNotChinese(string &str,stack<string> &stk);
bool FC_char_read(string s,char *c,unsigned int *i,unsigned int maxl);//读取字符串中的字符,并记数
public:
bool IsC(char c);
bool IsEc(char c);
void init(string dictiory_filename);
string SegmentWord(string s); //分词
string int2str(int num) ;
};
extern Dictiory D; //加载词典
#endif