-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexperiment_falsos_positius.cc
57 lines (46 loc) · 1.66 KB
/
experiment_falsos_positius.cc
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
#include "./Filtre Bloom/diccBloomFilter.hh"
#include <iostream>
#include <fstream>
using namespace std;
int main () {
vector<string> paths = {"./diccionaris/mare-balena-vocabulary-3.txt",
"./diccionaris/dracula-vocabulary-4.txt",
"./diccionaris/quijote-vocabulary-6.txt"};
for (string path : paths) {
cout << "Fitxer: " << path << endl;
BloomFilterDictionary b;
vector<string> totes;
ifstream fp_in;
string a;
fp_in.open(path);
while (fp_in >> a) {
totes.push_back(a);
}
fp_in.close();
int mida = totes.size();
cout << "Mida: " << mida << endl;
int encerts = 0, comprovacions = 0;
int fPositius = 0, fNegatius = 0;
for (int i = 0; i < mida; ++i) {
string w = totes[i];
b.afegir(w);
//ha de sortir positiu
for (int j = 0; j <= i; ++j) {
++comprovacions;
if (not b.comprovar(totes[j])) ++fNegatius;
else ++encerts;
}
//ha de sortit negatiu
for (int j = i+1; j < mida; ++j) {
++comprovacions;
if (b.comprovar(totes[j])) ++fPositius;
else ++encerts;
}
}
cout << "Falsos negatius: " << fNegatius << endl;
cout << "Falsos positius: " << fPositius << endl;
cout << "Errors totals: " << fNegatius+fPositius << endl;
cout << "Encerts: " << encerts << endl;
cout << "Comprovacions totals: " << comprovacions << endl;
}
}