-
Notifications
You must be signed in to change notification settings - Fork 1
/
entity.h
51 lines (49 loc) · 1.43 KB
/
entity.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
#include <iostream>
#include <set>
using namespace std;
#define clusterPrefixW (10)
#define clusterSameDocW (10)
class clusterPrefixF {
public:
bool same_prfeix;
set<int>prefixSet;
int prefix[256];
clusterPrefixF(){
memset(prefix,0, sizeof(prefix) * sizeof(int));
}
void add(int char_ascii){
prefixSet.insert(char_ascii);
prefix[char_ascii]++;
}
void remove(int char_ascii){
prefix[char_ascii]--;
if(prefix[char_ascii]==0) prefixSet.erase(char_ascii);
}
int clusterPrefixScore(){
return prefixSet.size()==1 ? clusterPrefixW : 0;
}
};
class clusterSameDocF {
public:
map<int,int> docMap;
void add(int doc_id){
docMap[doc_id]=docMap[doc_id]+1;
}
void remove(int doc_id){
docMap[doc_id]=docMap[doc_id]-1;
if(docMap[doc_id]==0) docMap.erase(doc_id);
}
int clusterSameDocScore(){
return docMap.size()==1 ? clusterSameDocW : 0;
}
};
class entity {
public:
int id; // An unique identifier for the entity (in consequential)
set<int> mentionSet; // all the mentions belong to the entity
clusterPrefixF clusterPrefixf;
clusterSameDocF clusterSameDocf;
int clusterScore(){
return clusterPrefixf.clusterPrefixScore()+clusterSameDocf.clusterSameDocScore();
}
};