Debian Codegraph @

data/0.12-dev/src/RatioStats.cpp

raw
1 #include "Meanings.h"
2 #include <algorithm>
3 #include <iostream>
4 #include <fstream>
5 #include <string>
6 using namespace std;
7
8 int main()
9 {
10 cout << "Enter Meaning-Ratio File (e.g. m-r.#): " << flush;
11 string file; cin >> file;
12
13 ifstream fin(file.c_str());
14 vector<double> dlrs;
15 vector<double> rlrs;
16 vector<MeaningSet> meanings;
17 extractMeaningFamily(fin, meanings, dlrs, rlrs);
18
19 int n = 0;
20
21 do
22 {
23 double avg_dlr = 0;
24 double min_dlr = 2;
25 double max_dlr = -1;
26
27 unsigned int over_n_count = 0;
28
29 vector<double> cp;
30
31 for(unsigned int i = 0;i < meanings.size();++i)
32 {
33 if (meanings[i].size() >= static_cast<unsigned int>(n))
34 {
35 over_n_count++;
36 cp.push_back(dlrs[i]);
37 }
38 }
39
40 for(unsigned int i = 0;i < meanings.size();++i)
41 {
42 if (meanings[i].size() >= static_cast<unsigned int>(n))
43 {
44 avg_dlr += dlrs[i] / over_n_count;
45 min_dlr = min(dlrs[i], min_dlr);
46 max_dlr = max(dlrs[i], max_dlr);
47 }
48 }
49
50 sort(cp.begin(), cp.end());
51
52
53 cout << "sets with more than " << n << " elements: "
54 << over_n_count << endl;
55
56 cout << "average link ratio: " << avg_dlr << endl;
57 cout << "minimum link ratio: " << min_dlr << endl;
58 cout << "maximum link ratio: " << max_dlr << endl;
59 cout << "median link raito: " << cp[cp.size() / 2] << endl;
60
61 cout << "\nYou can refine results to only include sets with \n"
62 << "above a certain number of results (n).\n"
63 << "Input n (-1 to quit): " << flush;
64
65 cin >> n;
66
67 } while(n >= 0);
68
69 while(1)
70 {
71 double pct;
72
73 cout << "\nYou can now query to find the number of sets with \n"
74 << "mdlr < pct. For example, entering .1 would give you \n"
75 << "count of all sets with less than 10\% dlr.\n"
76 << "Input pct (-1 to quit): " << flush;
77
78 cin >> pct;
79
80 if (pct < 0)
81 break;
82
83 int result = 0;
84 for(unsigned int i = 0;i < meanings.size();++i)
85 {
86 if (dlrs[i] < pct)
87 result++;
88 }
89
90 cout << "Number of sets: " << result << endl;
91 }
92
93 return 0;
94 }