forked from berthubert/tkconv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtkdisco.cc
70 lines (66 loc) · 2.27 KB
/
tkdisco.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
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <fmt/format.h>
#include <fmt/printf.h>
#include <fmt/ranges.h>
#include <iostream>
#include "httplib.h"
#include "sqlwriter.hh"
#include "pugixml.hpp"
using namespace std;
int main(int argc, char** argv)
{
vector<string> categories=
{"Activiteit", "ActiviteitActor", "Agendapunt", "Besluit", "Commissie",
"CommissieContactinformatie", "CommissieZetel", "CommissieZetelVastPersoon",
"CommissieZetelVastVacature", "CommissieZetelVervangerPersoon",
"CommissieZetelVervangerVacature", "Document", "DocumentActor",
"DocumentVersie", "Fractie", "FractieZetel", "FractieZetelPersoon",
"FractieZetelVacature", "Kamerstukdossier", "Persoon",
"PersoonContactinformatie", "PersoonGeschenk", "PersoonLoopbaan",
"PersoonNevenfunctie", "PersoonNevenfunctieInkomsten", "PersoonOnderwijs",
"PersoonReis", "Reservering", "Stemming", "Toezegging", "Vergadering",
"Verslag", "Zaak", "ZaakActor", "Zaal"};
if(argc > 1) {
categories.clear();
for(int n = 1 ; n < argc; ++n)
categories.push_back(argv[n]);
}
SQLiteWriter xmlstore("xml.sqlite3");
for(const auto& category: categories) {
int skiptoken = -1;
int numentries=0;
auto entries = xmlstore.queryT("select * from "+category+" where skiptoken > ?", {skiptoken});
map<string, int> fields;
set<string> multis, hasref;
for(auto& exml : entries) {
pugi::xml_document pnode;
if (!pnode.load_string( (get<string>(exml["xml"])).c_str())) {
cout<<"Could not load"<<endl;
return -1;
}
pugi::xml_node node = pnode.child("entry");
string id = node.child("title").child_value();
auto child2 = *node.child("content").begin();
numentries++;
// cout << child2.name() << endl;
map<string, int> perentry;
for(const auto&c : child2) {
// cout << c.name() <<"='"<<c.child_value()<<"' ";
if(!string(c.child_value()).empty())
fields[c.name()]++;
perentry[c.name()]++;
string ref = c.attribute("ref").value();
if(!ref.empty())
hasref.insert(c.name());
}
for(const auto& p : perentry) {
if(p.second > 1)
multis.insert(p.first);
}
}
for(auto& f : fields)
f.second = 100.0*f.second/numentries;
fmt::print("{}: \n{}\n", category, fields);
fmt::print("Multi: {}\n", multis);
fmt::print("Hasref: {}\n\n", hasref);
}
}