blob: 9245304b699631af32eb0ea75adde3ce144a9e39 [file] [log] [blame]
Marc Kupietz28cc53e2017-12-23 17:24:55 +01001#include <typeinfo>
Marc Kupietz4b799e92018-01-02 11:04:56 +01002#define EXPORT __attribute__((visibility("visible")))
3#define IMPORT
Marc Kupietz28cc53e2017-12-23 17:24:55 +01004#include <assert.h>
Marc Kupietz37359b12018-01-09 21:11:37 +01005#include <inttypes.h>
Marc Kupietz28cc53e2017-12-23 17:24:55 +01006#include <memory>
7#include <iostream>
Marc Kupietzc8ddf452018-01-07 21:33:12 +01008#include <algorithm>
9#include <vector>
Marc Kupietz28cc53e2017-12-23 17:24:55 +010010#include <stdint.h>
Marc Kupietzc8ddf452018-01-07 21:33:12 +010011#include <string>
12#include <sstream> // for ostringstream
13#include <math.h>
Marc Kupietzd31254c2018-01-20 21:29:30 +010014#include <rocksdb/cache.h>
Marc Kupietz28cc53e2017-12-23 17:24:55 +010015#include "rocksdb/comparator.h"
16#include "rocksdb/db.h"
17#include "rocksdb/env.h"
Marc Kupietzc8ddf452018-01-07 21:33:12 +010018#include "rocksdb/table.h"
Marc Kupietz28cc53e2017-12-23 17:24:55 +010019#include <rocksdb/merge_operator.h>
Marc Kupietzc8ddf452018-01-07 21:33:12 +010020#include <rocksdb/slice_transform.h>
Marc Kupietz28cc53e2017-12-23 17:24:55 +010021#include "rocksdb/utilities/db_ttl.h"
Marc Kupietzc8ddf452018-01-07 21:33:12 +010022#include "rocksdb/filter_policy.h"
Marc Kupietz28cc53e2017-12-23 17:24:55 +010023#include "merge_operators.h"
24
Marc Kupietz75af60f2019-01-22 22:34:29 +010025#define WINDOW_SIZE 5
Marc Kupietz98cbcdc2019-01-21 17:11:27 +010026#define FREQUENCY_THRESHOLD 5
Marc Kupietz28cc53e2017-12-23 17:24:55 +010027#define IS_BIG_ENDIAN (*(uint16_t *)"\0\xff" < 0x100)
28#define encodeCollocation(w1, w2, dist) (((uint64_t)dist << 56) | ((uint64_t)w2 << 24) | w1)
Marc Kupietz18375e12017-12-24 10:11:18 +010029#define W1(key) (uint64_t)(key & 0xffffff)
30#define W2(key) (uint64_t)((key >> 24) & 0xffffff)
31#define DIST(key) (int8_t)((uint64_t)((key >> 56) & 0xff))
Marc Kupietzc8ddf452018-01-07 21:33:12 +010032
33typedef struct {
34 uint64_t freq;
35 char *word;
36} vocab_entry;
37
38// typedef struct Collocator {
39// uint64_t w2;
40// uint64_t sum;
41// };
42
Marc Kupietz28cc53e2017-12-23 17:24:55 +010043using namespace rocksdb;
Marc Kupietzc8ddf452018-01-07 21:33:12 +010044using namespace std;
Marc Kupietz28cc53e2017-12-23 17:24:55 +010045
Marc Kupietz4b799e92018-01-02 11:04:56 +010046namespace rocksdb {
Marc Kupietz4a5e08a2018-06-05 11:07:11 +020047 class Collocator {
48 public:
Marc Kupietzc8ddf452018-01-07 21:33:12 +010049 uint64_t w2;
Marc Kupietzcc6c4592019-01-23 10:11:23 +010050 uint64_t f2;
Marc Kupietz51f93792018-01-25 08:51:01 +010051 uint64_t raw;
Marc Kupietzc8ddf452018-01-07 21:33:12 +010052 double pmi;
53 double npmi;
54 double llr;
Marc Kupietzc8ddf452018-01-07 21:33:12 +010055 double lfmd;
Marc Kupietz41880452019-01-22 15:29:06 +010056 double md;
Marc Kupietz8e0ebea2018-01-24 09:53:26 +010057 double left_lfmd;
58 double right_lfmd;
59 double left_npmi;
60 double right_npmi;
Marc Kupietz41880452019-01-22 15:29:06 +010061 double dice;
62 double logdice;
Marc Kupietz75af60f2019-01-22 22:34:29 +010063 double af;
64 int window;
Marc Kupietze9f58932019-01-24 15:12:59 +010065 int af_window;
Marc Kupietzc8ddf452018-01-07 21:33:12 +010066 };
67
Marc Kupietz28cc53e2017-12-23 17:24:55 +010068 size_t num_merge_operator_calls;
69 void resetNumMergeOperatorCalls() { num_merge_operator_calls = 0; }
Marc Kupietzc8ddf452018-01-07 21:33:12 +010070
Marc Kupietz28cc53e2017-12-23 17:24:55 +010071 size_t num_partial_merge_calls;
72 void resetNumPartialMergeCalls() { num_partial_merge_calls = 0; }
Marc Kupietz28cc53e2017-12-23 17:24:55 +010073
74
Marc Kupietz4b799e92018-01-02 11:04:56 +010075 inline void EncodeFixed64(char* buf, uint64_t value) {
76 if (! IS_BIG_ENDIAN) {
77 memcpy(buf, &value, sizeof(value));
78 } else {
79 buf[0] = value & 0xff;
80 buf[1] = (value >> 8) & 0xff;
81 buf[2] = (value >> 16) & 0xff;
82 buf[3] = (value >> 24) & 0xff;
83 buf[4] = (value >> 32) & 0xff;
84 buf[5] = (value >> 40) & 0xff;
85 buf[6] = (value >> 48) & 0xff;
86 buf[7] = (value >> 56) & 0xff;
87 }
Marc Kupietz28cc53e2017-12-23 17:24:55 +010088 }
89
Marc Kupietz4b799e92018-01-02 11:04:56 +010090 inline uint32_t DecodeFixed32(const char* ptr) {
91 if (! IS_BIG_ENDIAN) {
92 // Load the raw bytes
93 uint32_t result;
94 memcpy(&result, ptr, sizeof(result)); // gcc optimizes this to a plain load
95 return result;
96 } else {
97 return ((static_cast<uint32_t>(static_cast<unsigned char>(ptr[0])))
98 | (static_cast<uint32_t>(static_cast<unsigned char>(ptr[1])) << 8)
99 | (static_cast<uint32_t>(static_cast<unsigned char>(ptr[2])) << 16)
100 | (static_cast<uint32_t>(static_cast<unsigned char>(ptr[3])) << 24));
101 }
102 }
103
104 inline uint64_t DecodeFixed64(const char* ptr) {
105 if (! IS_BIG_ENDIAN) {
106 // Load the raw bytes
107 uint64_t result;
108 memcpy(&result, ptr, sizeof(result)); // gcc optimizes this to a plain load
109 return result;
110 } else {
111 uint64_t lo = DecodeFixed32(ptr);
112 uint64_t hi = DecodeFixed32(ptr + 4);
113 return (hi << 32) | lo;
114 }
115 }
116
Marc Kupietz8e0ebea2018-01-24 09:53:26 +0100117 static inline double ca_pmi(uint64_t f1, uint64_t f2, uint64_t f12, uint64_t total, double window_size) {
Marc Kupietz1335dd72019-01-22 15:35:21 +0100118 double
119 r1 = f1 * window_size,
120 c1 = f2,
121 e = r1 * c1 / total,
122 o = f12;
123 return log2(o/e);
Marc Kupietz8e0ebea2018-01-24 09:53:26 +0100124 }
125
Marc Kupietzce0b8b02018-06-05 11:06:39 +0200126 // Bouma, Gerlof (2009): <a href="https://svn.spraakdata.gu.se/repos/gerlof/pub/www/Docs/npmi-pfd.pdf">
127 // Normalized (pointwise) mutual information in collocation extraction</a>. In Proceedings of GSCL.
Marc Kupietz8e0ebea2018-01-24 09:53:26 +0100128 static inline double ca_npmi(uint64_t f1, uint64_t f2, uint64_t f12, uint64_t total, double window_size) {
Marc Kupietz1335dd72019-01-22 15:35:21 +0100129 double
130 r1 = f1 * window_size,
131 c1 = f2,
132 e = r1 * c1 / total,
133 o = f12;
134 if(f12 < FREQUENCY_THRESHOLD)
Marc Kupietz8caf9912018-06-05 10:51:18 +0200135 return -1.0;
136 else
Marc Kupietz1335dd72019-01-22 15:35:21 +0100137 return log2(o/e) / (-log2(o/total/window_size));
Marc Kupietz8e0ebea2018-01-24 09:53:26 +0100138 }
139
140 // Thanopoulos, A., Fakotakis, N., Kokkinakis, G.: Comparative evaluation of collocation extraction metrics.
141 // In: International Conference on Language Resources and Evaluation (LREC-2002). (2002) 620–625
142 // double md = log2(pow((double)max * window_size / total, 2) / (window_size * ((double)_vocab[w1].freq/total) * ((double)_vocab[last_w2].freq/total)));
143 static inline double ca_md(uint64_t f1, uint64_t f2, uint64_t f12, uint64_t total, double window_size) {
Marc Kupietz1335dd72019-01-22 15:35:21 +0100144 double
145 r1 = f1 * window_size,
146 c1 = f2,
147 e = r1 * c1 / total,
148 o = f12;
149 return log2(o*o/e);
Marc Kupietz8e0ebea2018-01-24 09:53:26 +0100150 }
151
152 static inline double ca_lfmd(uint64_t f1, uint64_t f2, uint64_t f12, uint64_t total, double window_size) {
Marc Kupietz1335dd72019-01-22 15:35:21 +0100153 double
154 r1 = f1 * window_size,
155 c1 = f2,
156 e = r1 * c1 / total,
157 o = f12;
Marc Kupietz8caf9912018-06-05 10:51:18 +0200158 if(f12 == 0)
159 return 0;
160 else
Marc Kupietz1335dd72019-01-22 15:35:21 +0100161 return log2(o*o*o/e);
Marc Kupietz8e0ebea2018-01-24 09:53:26 +0100162 }
163
Marc Kupietzbbd236e2019-01-21 16:50:19 +0100164 // Evert, Stefan (2004): The Statistics of Word Cooccurrences: Word Pairs and Collocations. PhD dissertation, IMS, University of Stuttgart. Published in 2005, URN urn:nbn:de:bsz:93-opus-23714.
165 // Free PDF available from http://purl.org/stefan.evert/PUB/Evert2004phd.pdf
166 static inline double ca_ll(uint64_t w1, uint64_t w2, uint64_t w12, uint64_t n, uint64_t window_size) {
167 double
168 r1 = (double) w1 * window_size,
169 r2 = (double) n - r1,
170 c1 = w2,
171 c2 = n - c1,
172 o11 = w12, o12 = r1 - o11,
173 o21 = c1 - w12, o22 = r2 - o21,
174 e11 = r1 * c1 / n, e12 = r1 * c2 / n,
175 e21 = r2 * c1 / n, e22 = r2 * c2 / n;
176 return (2 * ( (o11>0? o11 * log(o11/e11):0) + (o12>0? o12 * log(o12/e12):0) + (o21>0? o21 * log(o21/e21):0) + (o22>0? o22 * log(o22/e22):0)));
177 }
Marc Kupietz4b799e92018-01-02 11:04:56 +0100178
Marc Kupietz41880452019-01-22 15:29:06 +0100179
180 static inline double ca_dice(uint64_t w1, uint64_t w2, uint64_t w12, uint64_t n, uint64_t window_size) {
181 double
182 r1 = (double) w1 * window_size,
183 c1 = w2;
184 return 2 * w12 / (c1+r1);
185 }
186
187 // Rychlý, Pavel (2008): <a href="http://www.fi.muni.cz/usr/sojka/download/raslan2008/13.pdf">A lexicographer-friendly association score.</a> In Proceedings of Recent Advances in Slavonic Natural Language Processing, RASLAN, 6–9.
188 static inline double ca_logdice(uint64_t w1, uint64_t w2, uint64_t w12, uint64_t n, uint64_t window_size) {
189 double
190 e = 0.5,
191 r1 = (double) w1 * window_size,
192 c1 = w2;
193 return 14 + log2(2 * (w12+e) / (c1+e+r1+e));
194 }
195
Marc Kupietz4b799e92018-01-02 11:04:56 +0100196 class CountMergeOperator : public AssociativeMergeOperator {
197 public:
198 CountMergeOperator() {
199 mergeOperator_ = MergeOperators::CreateUInt64AddOperator();
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100200 }
201
Marc Kupietz4b799e92018-01-02 11:04:56 +0100202 virtual bool Merge(const Slice& key,
203 const Slice* existing_value,
204 const Slice& value,
205 std::string* new_value,
206 Logger* logger) const override {
207 assert(new_value->empty());
208 ++num_merge_operator_calls;
209 if (existing_value == nullptr) {
210 new_value->assign(value.data(), value.size());
211 return true;
212 }
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100213
Marc Kupietz4b799e92018-01-02 11:04:56 +0100214 return mergeOperator_->PartialMerge(
215 key,
216 *existing_value,
217 value,
218 new_value,
219 logger);
220 }
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100221
Marc Kupietz4b799e92018-01-02 11:04:56 +0100222 virtual const char* Name() const override {
223 return "UInt64AddOperator";
224 }
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100225
Marc Kupietz4b799e92018-01-02 11:04:56 +0100226 private:
227 std::shared_ptr<MergeOperator> mergeOperator_;
228 };
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100229
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100230
Marc Kupietz4b799e92018-01-02 11:04:56 +0100231 class CollocatorIterator : public Iterator {
232 private:
233 char prefixc[sizeof(uint64_t)];
234 Iterator *base_iterator_;
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100235
236
Marc Kupietz4b799e92018-01-02 11:04:56 +0100237 public:
238 CollocatorIterator(Iterator* base_iterator)
239 : base_iterator_(base_iterator)
240 {}
241
Marc Kupietz4b799e92018-01-02 11:04:56 +0100242 void setPrefix(char *prefix) {
243 memcpy(prefixc, prefix, sizeof(uint64_t));
244 }
245
246 virtual void SeekToFirst() { base_iterator_->SeekToFirst(); }
247 virtual void SeekToLast() { base_iterator_->SeekToLast(); }
248 virtual void Seek(const rocksdb::Slice& s) { base_iterator_->Seek(s); }
249 virtual void Prev() { base_iterator_->Prev(); }
250 virtual void Next() { base_iterator_->Next(); }
251 virtual Slice key() const;
252 virtual Slice value() const;
253 virtual Status status() const;
254 virtual bool Valid() const;
255 bool isValid();
256 uint64_t intValue();
257 uint64_t intKey();
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100258
Marc Kupietz4b799e92018-01-02 11:04:56 +0100259 };
Marc Kupietz18375e12017-12-24 10:11:18 +0100260
Marc Kupietz4b799e92018-01-02 11:04:56 +0100261 // rocksdb::CollocatorIterator::CollocatorIterator(Iterator* base_iterator) {}
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100262
Marc Kupietz4b799e92018-01-02 11:04:56 +0100263 bool rocksdb::CollocatorIterator::Valid() const {
Marc Kupietz18375e12017-12-24 10:11:18 +0100264 return base_iterator_->Valid() && key().starts_with(std::string(prefixc,3));
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100265 }
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100266
Marc Kupietz4b799e92018-01-02 11:04:56 +0100267 bool rocksdb::CollocatorIterator::isValid() {
268 return base_iterator_->Valid() && key().starts_with(std::string(prefixc,3));
Marc Kupietzd31254c2018-01-20 21:29:30 +0100269 // return key().starts_with(std::string(prefixc,3));
Marc Kupietz4b799e92018-01-02 11:04:56 +0100270 }
Marc Kupietz18375e12017-12-24 10:11:18 +0100271
Marc Kupietz4b799e92018-01-02 11:04:56 +0100272 uint64_t rocksdb::CollocatorIterator::intKey() {
273 return DecodeFixed64(base_iterator_->key().data());
274 }
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100275
Marc Kupietz4b799e92018-01-02 11:04:56 +0100276 uint64_t rocksdb::CollocatorIterator::intValue() {
277 return DecodeFixed64(base_iterator_->value().data());
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100278 }
279
Marc Kupietz37359b12018-01-09 21:11:37 +0100280 class VocabEntry {
281 public:
282 string word;
283 uint64_t freq;
284 };
285
Marc Kupietz6aec7682018-01-10 09:47:48 +0100286 class CollocatorDB {
Marc Kupietz4b799e92018-01-02 11:04:56 +0100287 private:
288 WriteOptions merge_option_; // for merge
289 char _one[sizeof(uint64_t)];
290 Slice _one_slice;
Marc Kupietz37359b12018-01-09 21:11:37 +0100291 vector<VocabEntry> _vocab;
Marc Kupietz4ec51c12019-01-21 11:06:39 +0100292 uint64_t total = 0;
293 uint64_t sentences = 0;
Marc Kupietz8cf7e912019-01-21 17:05:23 +0100294 float avg_window_size = 8.0;
Marc Kupietz37359b12018-01-09 21:11:37 +0100295
Marc Kupietz4b799e92018-01-02 11:04:56 +0100296 protected:
297 std::shared_ptr<DB> db_;
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100298
Marc Kupietz4b799e92018-01-02 11:04:56 +0100299 WriteOptions put_option_;
300 ReadOptions get_option_;
301 WriteOptions delete_option_;
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100302
Marc Kupietz4b799e92018-01-02 11:04:56 +0100303 uint64_t default_;
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100304
Marc Kupietz4b799e92018-01-02 11:04:56 +0100305 std::shared_ptr<DB> OpenDb(const char *dbname);
Marc Kupietz6bb27762018-01-09 17:53:01 +0100306 std::shared_ptr<DB> OpenDbForRead(const char *dbname);
Marc Kupietz37359b12018-01-09 21:11:37 +0100307 void read_vocab(string fname);
308
Marc Kupietz4b799e92018-01-02 11:04:56 +0100309 public:
Marc Kupietz4a5e08a2018-06-05 11:07:11 +0200310 string getWord(uint32_t w1);
Marc Kupietz6aec7682018-01-10 09:47:48 +0100311 CollocatorDB(const char *db_name, bool read_only);
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100312
Marc Kupietz6aec7682018-01-10 09:47:48 +0100313 // public interface of CollocatorDB.
Marc Kupietz4b799e92018-01-02 11:04:56 +0100314 // All four functions return false
315 // if the underlying level db operation failed.
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100316
Marc Kupietz4b799e92018-01-02 11:04:56 +0100317 // mapped to a levedb Put
318 bool set(const std::string& key, uint64_t value) {
319 // just treat the internal rep of int64 as the string
320 char buf[sizeof(value)];
321 EncodeFixed64(buf, value);
322 Slice slice(buf, sizeof(value));
323 auto s = db_->Put(put_option_, key, slice);
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100324
Marc Kupietz4b799e92018-01-02 11:04:56 +0100325 if (s.ok()) {
326 return true;
327 } else {
328 std::cerr << s.ToString() << std::endl;
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100329 return false;
330 }
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100331 }
Marc Kupietz4b799e92018-01-02 11:04:56 +0100332
333 DB *getDb() {
334 return db_.get();
335 }
336
337 // mapped to a rocksdb Delete
338 bool remove(const std::string& key) {
339 auto s = db_->Delete(delete_option_, key);
340
341 if (s.ok()) {
342 return true;
343 } else {
344 std::cerr << s.ToString() << std::endl;
345 return false;
346 }
347 }
348
349 // mapped to a rocksdb Get
350 bool get(const std::string& key, uint64_t* value) {
351 std::string str;
352 auto s = db_->Get(get_option_, key, &str);
353
354 if (s.IsNotFound()) {
355 // return default value if not found;
356 *value = default_;
357 return true;
358 } else if (s.ok()) {
359 // deserialization
360 if (str.size() != sizeof(uint64_t)) {
361 std::cerr << "value corruption\n";
362 return false;
363 }
364 *value = DecodeFixed64(&str[0]);
365 return true;
366 } else {
367 std::cerr << s.ToString() << std::endl;
368 return false;
369 }
370 }
371
372
373 uint64_t get(const uint32_t w1, const uint32_t w2, const int8_t dist) {
374 char encoded_key[sizeof(uint64_t)];
375 EncodeFixed64(encoded_key, encodeCollocation(w1,w2,dist));
376 uint64_t value = default_;
377 get(std::string(encoded_key, 8), &value);
378 return value;
379 }
380
381 virtual void inc(const std::string& key) {
382 db_->Merge(merge_option_, key, _one_slice);
383 }
384
385 void inc(const uint64_t key) {
386 char encoded_key[sizeof(uint64_t)];
387 EncodeFixed64(encoded_key, key);
388 db_->Merge(merge_option_, std::string(encoded_key, 8), _one_slice);
389 }
390
391 virtual void inc(const uint32_t w1, const uint32_t w2, const uint8_t dist);
Marc Kupietz06c9a9f2018-01-02 16:56:43 +0100392 void dump(uint32_t w1, uint32_t w2, int8_t dist);
Marc Kupietz37359b12018-01-09 21:11:37 +0100393 vector<Collocator> get_collocators(uint32_t w1);
Marc Kupietzbd966192018-10-13 14:14:37 +0200394 vector<Collocator> get_collocators(uint32_t w1, uint32_t max_w2);
Marc Kupietz3400aa52018-06-05 10:28:55 +0200395 void dumpSparseLlr(uint32_t w1, uint32_t min_cooccur);
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100396 string collocators2json(vector<Collocator> collocators);
Marc Kupietz4b799e92018-01-02 11:04:56 +0100397
Marc Kupietz4b799e92018-01-02 11:04:56 +0100398 // mapped to a rocksdb Merge operation
399 virtual bool add(const std::string& key, uint64_t value) {
400 char encoded[sizeof(uint64_t)];
401 EncodeFixed64(encoded, value);
402 Slice slice(encoded, sizeof(uint64_t));
403 auto s = db_->Merge(merge_option_, key, slice);
404
405 if (s.ok()) {
406 return true;
407 } else {
408 std::cerr << s.ToString() << std::endl;
409 return false;
410 }
411 }
412
413 CollocatorIterator* SeekIterator(uint64_t w1, uint64_t w2, int8_t dist);
414 };
415
Marc Kupietz6aec7682018-01-10 09:47:48 +0100416 rocksdb::CollocatorDB::CollocatorDB(const char *db_name, bool read_only = false) {
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100417 // merge_option_.sync = true;
Marc Kupietz6bb27762018-01-09 17:53:01 +0100418 if(read_only)
419 db_ = OpenDbForRead(db_name);
420 else
421 db_ = OpenDb(db_name);
Marc Kupietz4b799e92018-01-02 11:04:56 +0100422 assert(db_);
423 uint64_t one = 1;
424 EncodeFixed64(_one, one);
425 _one_slice = Slice(_one, sizeof(uint64_t));
426 }
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100427
Marc Kupietz6aec7682018-01-10 09:47:48 +0100428 void rocksdb::CollocatorDB::inc(const uint32_t w1, const uint32_t w2, const uint8_t dist) {
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100429 inc(encodeCollocation(w1, w2, dist));
430 }
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100431
Marc Kupietz6aec7682018-01-10 09:47:48 +0100432 void rocksdb::CollocatorDB::read_vocab(string fname) {
Marc Kupietz37359b12018-01-09 21:11:37 +0100433 char strbuf[2048];
434 uint64_t freq;
435 FILE *fin = fopen(fname.c_str(), "rb");
436 if (fin == NULL) {
437 cout << "Vocabulary file " << fname <<" not found\n";
438 exit(1);
439 }
440 uint64_t i = 0;
441 while(!feof(fin)) {
Marc Kupietzd31254c2018-01-20 21:29:30 +0100442 fscanf(fin, "%s %lu", strbuf, &freq);
Marc Kupietz37359b12018-01-09 21:11:37 +0100443 _vocab.push_back({strbuf, freq});
444 total += freq;
445 i++;
446 }
447 fclose(fin);
Marc Kupietz4ec51c12019-01-21 11:06:39 +0100448
449 char size_fname[256];
450 strcpy(size_fname, fname.c_str());
451 char *pos = strstr(size_fname, ".vocab");
452 if(pos) {
453 *pos=0;
454 strcat(size_fname, ".size");
455 FILE *fp = fopen(size_fname, "r");
456 if (fp != NULL) {
457 fscanf(fp, "%lu", &sentences);
458 fscanf(fp, "%lu", &total);
459 float sl = (float)total/(float)sentences;
460 float w = WINDOW_SIZE;
461 avg_window_size = ((sl > 2*w? (sl-2*w)*2*w: 0) + (double) w * (3*w -1)) / sl;
462 fprintf(stdout, "Size corrections found: corpus size: %lu tokens in %lu sentences, avg. sentence size: %f, avg. window size: %f\n", total, sentences, sl, avg_window_size);
463 fclose(fp);
464 } else {
465 std::cout << "size file " << size_fname << " not found\n";
466 }
467 } else {
468 std::cout << "cannot determine size file " << size_fname << "\n";
469 }
Marc Kupietz37359b12018-01-09 21:11:37 +0100470 }
471
Marc Kupietz6aec7682018-01-10 09:47:48 +0100472 std::shared_ptr<DB> rocksdb::CollocatorDB::OpenDbForRead(const char *name) {
Marc Kupietz6bb27762018-01-09 17:53:01 +0100473 DB* db;
474 Options options;
Marc Kupietz0dd86ef2018-01-11 22:23:17 +0100475 options.env->SetBackgroundThreads(4);
476 options.create_if_missing = true;
477 options.merge_operator = std::make_shared<CountMergeOperator>();
478 options.max_successive_merges = 0;
479 // options.prefix_extractor.reset(NewFixedPrefixTransform(8));
480 options.IncreaseParallelism();
481 options.OptimizeLevelStyleCompaction();
482 options.prefix_extractor.reset(NewFixedPrefixTransform(3));
Marc Kupietz37359b12018-01-09 21:11:37 +0100483 ostringstream dbname, vocabname;
Marc Kupietz6bb27762018-01-09 17:53:01 +0100484 dbname << name << ".rocksdb";
485 auto s = DB::OpenForReadOnly(options, dbname.str(), &db);
486 if (!s.ok()) {
487 std::cerr << s.ToString() << std::endl;
488 assert(false);
489 }
Marc Kupietz37359b12018-01-09 21:11:37 +0100490 vocabname << name << ".vocab";
491 read_vocab(vocabname.str());
Marc Kupietz6bb27762018-01-09 17:53:01 +0100492 return std::shared_ptr<DB>(db);
493 }
494
Marc Kupietz6aec7682018-01-10 09:47:48 +0100495 std::shared_ptr<DB> rocksdb::CollocatorDB::OpenDb(const char *dbname) {
Marc Kupietz4b799e92018-01-02 11:04:56 +0100496 DB* db;
497 Options options;
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100498
499
500 options.env->SetBackgroundThreads(4);
Marc Kupietz4b799e92018-01-02 11:04:56 +0100501 options.create_if_missing = true;
502 options.merge_operator = std::make_shared<CountMergeOperator>();
503 options.max_successive_merges = 0;
Marc Kupietz0dd86ef2018-01-11 22:23:17 +0100504 // options.prefix_extractor.reset(NewFixedPrefixTransform(8));
505 options.IncreaseParallelism();
506 options.OptimizeLevelStyleCompaction();
507 // options.max_write_buffer_number = 48;
508 // options.max_background_jobs = 48;
509 // options.allow_concurrent_memtable_write=true;
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100510 // options.memtable_factory.reset(rocksdb::NewHashLinkListRepFactory(200000));
511 // options.enable_write_thread_adaptive_yield = 1;
512 // options.allow_concurrent_memtable_write = 1;
513 // options.memtable_factory.reset(new rocksdb::SkipListFactory);
514 // options.write_buffer_size = 1 << 22;
515 // options.allow_mmap_reads = true;
516 // options.allow_mmap_writes = true;
Marc Kupietz0dd86ef2018-01-11 22:23:17 +0100517 // options.max_background_compactions = 40;
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100518 // BlockBasedTableOptions table_options;
519 // table_options.filter_policy.reset(NewBloomFilterPolicy(24, false));
520 // options.bloom_locality = 1;
521 // std::shared_ptr<Cache> cache = NewLRUCache(512 * 1024 * 1024);
522 // table_options.block_cache = cache;
523 // options.table_factory.reset(NewBlockBasedTableFactory(table_options));
Marc Kupietz4b799e92018-01-02 11:04:56 +0100524 Status s;
525 // DestroyDB(dbname, Options());
526 s = DB::Open(options, dbname, &db);
527 if (!s.ok()) {
528 std::cerr << s.ToString() << std::endl;
529 assert(false);
530 }
531 return std::shared_ptr<DB>(db);
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100532 }
533
Marc Kupietz6aec7682018-01-10 09:47:48 +0100534 CollocatorIterator* rocksdb::CollocatorDB::SeekIterator(uint64_t w1, uint64_t w2, int8_t dist) {
Marc Kupietz18375e12017-12-24 10:11:18 +0100535 ReadOptions options;
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100536 options.prefix_same_as_start = true;
Marc Kupietz18375e12017-12-24 10:11:18 +0100537 char prefixc[sizeof(uint64_t)];
538 EncodeFixed64(prefixc, encodeCollocation(w1, w2, dist));
539 Iterator *it = db_->NewIterator(options);
540 CollocatorIterator *cit = new CollocatorIterator(it);
541 cit->Seek(std::string(prefixc,3));// it->Valid() && it->key().starts_with(std::string(prefixc,3)); it->Next()) {
542 cit->setPrefix(prefixc);
543 return cit;
544 }
545
Marc Kupietz6aec7682018-01-10 09:47:48 +0100546 void rocksdb::CollocatorDB::dump(uint32_t w1, uint32_t w2, int8_t dist) {
Marc Kupietz06c9a9f2018-01-02 16:56:43 +0100547 auto it = std::unique_ptr<CollocatorIterator>(SeekIterator(w1, w2, dist));
548 for (; it->isValid(); it->Next()) {
549 uint64_t value = it->intValue();
550 uint64_t key = it->intKey();
551 std::cout << "w1:" << W1(key) << ", w2:" << W2(key) << ", dist:" << (int32_t) DIST(key) << " - count:" << value << std::endl;
552 }
553 std::cout << "ready dumping\n";
554 }
555
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100556 bool sortByNpmi(const Collocator &lhs, const Collocator &rhs) { return lhs.npmi > rhs.npmi; }
557 bool sortByLfmd(const Collocator &lhs, const Collocator &rhs) { return lhs.lfmd > rhs.lfmd; }
Marc Kupietzd31254c2018-01-20 21:29:30 +0100558 bool sortByLlr(const Collocator &lhs, const Collocator &rhs) { return lhs.llr > rhs.llr; }
Marc Kupietz7e3dfde2019-01-22 16:27:33 +0100559 bool sortByLogDice(const Collocator &lhs, const Collocator &rhs) { return lhs.logdice > rhs.logdice; }
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100560
Marc Kupietz75af60f2019-01-22 22:34:29 +0100561 std::vector<Collocator> rocksdb::CollocatorDB::get_collocators(uint32_t w1, uint32_t max_w2) {
562 std::vector<Collocator> collocators;
Marc Kupietzd31254c2018-01-20 21:29:30 +0100563 uint64_t w2, last_w2 = 0xffffffffffffffff;
Marc Kupietz98cbcdc2019-01-21 17:11:27 +0100564 uint64_t maxv = 0, sum = 0, left = 0, right = 0;
Marc Kupietz75af60f2019-01-22 22:34:29 +0100565 uint64_t sumWindow[2*WINDOW_SIZE+1] = {};
Marc Kupietzade33222019-01-22 22:52:44 +0100566 int true_window_size = 1;
Marc Kupietz39a4fd02019-01-23 10:18:43 +0100567 int usedPositions=0;
Marc Kupietz98cbcdc2019-01-21 17:11:27 +0100568
Marc Kupietzd31254c2018-01-20 21:29:30 +0100569 for ( auto it = std::unique_ptr<CollocatorIterator>(SeekIterator(w1, 0, 0)); it->isValid(); it->Next()) {
570 uint64_t value = it->intValue(),
571 key = it->intKey();
Marc Kupietzbd966192018-10-13 14:14:37 +0200572 if((w2 = W2(key)) > max_w2)
573 continue;
Marc Kupietzd31254c2018-01-20 21:29:30 +0100574 if(last_w2 == 0xffffffffffffffff) last_w2 = w2;
575 if (w2 != last_w2) {
Marc Kupietz75af60f2019-01-22 22:34:29 +0100576 if (sum >= FREQUENCY_THRESHOLD) {
577 uint64_t f1 = _vocab[w1].freq, f2 = _vocab[last_w2].freq;
Marc Kupietz98cbcdc2019-01-21 17:11:27 +0100578 double o = sum,
Marc Kupietzade33222019-01-22 22:52:44 +0100579 r1 = (double)_vocab[w1].freq * true_window_size,
Marc Kupietz98cbcdc2019-01-21 17:11:27 +0100580 c1 = (double)_vocab[last_w2].freq,
581 e = r1 * c1 / total,
582 pmi = log2(o/e),
583 md = log2(o*o/e),
584 lfmd = log2(o*o*o/e),
Marc Kupietzade33222019-01-22 22:52:44 +0100585 llr = ca_ll(f1, f2, sum, total, true_window_size);
Marc Kupietz75af60f2019-01-22 22:34:29 +0100586 double left_lfmd = ca_lfmd(f1, f2, left, total, 1);
587 double right_lfmd = ca_lfmd(f1, f2, right, total, 1);
588 double left_npmi = ca_npmi(f1, f2, left, total, 1);
589 double right_npmi = ca_npmi(f1, f2, right, total, 1);
Marc Kupietze9f58932019-01-24 15:12:59 +0100590 double ld = ca_logdice(f1, f2, sum, total, true_window_size);
Marc Kupietz75af60f2019-01-22 22:34:29 +0100591
Marc Kupietze9f58932019-01-24 15:12:59 +0100592 int bestWindow = usedPositions;
593 double bestAF = ld;
Marc Kupietz75af60f2019-01-22 22:34:29 +0100594 double currentAF;
Marc Kupietz39a4fd02019-01-23 10:18:43 +0100595 if(f1<75000000)
Marc Kupietz75af60f2019-01-22 22:34:29 +0100596 for (int bitmask=1; bitmask < (1 << (2*WINDOW_SIZE)); bitmask++) {
Marc Kupietz39a4fd02019-01-23 10:18:43 +0100597 if((bitmask & usedPositions) == 0 || (bitmask & ~usedPositions) > 0) continue;
Marc Kupietz75af60f2019-01-22 22:34:29 +0100598 uint64_t currentWindowSum=0;
599 for (int pos=0; pos < 2*WINDOW_SIZE; pos++) {
Marc Kupietz39a4fd02019-01-23 10:18:43 +0100600 if (((1<<pos) & bitmask & usedPositions) != 0)
Marc Kupietz75af60f2019-01-22 22:34:29 +0100601 currentWindowSum+=sumWindow[pos];
602 }
603 currentAF = ca_logdice(f1, f2, currentWindowSum, total, __builtin_popcount(bitmask));
604 if(currentAF > bestAF) {
605 bestAF = currentAF;
606 bestWindow = bitmask;
607 }
608 }
Marc Kupietzcc6c4592019-01-23 10:11:23 +0100609 collocators.push_back ( {last_w2, f2, sum,
610 pmi, pmi / (-log2(o/total/true_window_size)), /* normalize to [-1,1] */
Marc Kupietz98cbcdc2019-01-21 17:11:27 +0100611 llr, lfmd, md,
612 left_lfmd,
613 right_lfmd,
614 left_npmi,
Marc Kupietz41880452019-01-22 15:29:06 +0100615 right_npmi,
Marc Kupietzade33222019-01-22 22:52:44 +0100616 ca_dice(f1, f2, sum, total, true_window_size),
Marc Kupietze9f58932019-01-24 15:12:59 +0100617 ld,
Marc Kupietz75af60f2019-01-22 22:34:29 +0100618 bestAF,
Marc Kupietze9f58932019-01-24 15:12:59 +0100619 usedPositions,
Marc Kupietz75af60f2019-01-22 22:34:29 +0100620 bestWindow
Marc Kupietz41880452019-01-22 15:29:06 +0100621 }
Marc Kupietz98cbcdc2019-01-21 17:11:27 +0100622 );
623 }
Marc Kupietz75af60f2019-01-22 22:34:29 +0100624 memset(sumWindow, 0, 2*WINDOW_SIZE * sizeof(uint64_t));
Marc Kupietz39a4fd02019-01-23 10:18:43 +0100625 usedPositions = 1 << (-DIST(key)+WINDOW_SIZE-(DIST(key)<0?1:0));
Marc Kupietz75af60f2019-01-22 22:34:29 +0100626 sumWindow[-DIST(key)+WINDOW_SIZE-(DIST(key)<0?1:0)] = value;
Marc Kupietzd31254c2018-01-20 21:29:30 +0100627 last_w2 = w2;
Marc Kupietz8e0ebea2018-01-24 09:53:26 +0100628 maxv = value;
Marc Kupietz98cbcdc2019-01-21 17:11:27 +0100629 sum = value;
Marc Kupietzade33222019-01-22 22:52:44 +0100630 true_window_size = 1;
Marc Kupietzd31254c2018-01-20 21:29:30 +0100631 } else {
Marc Kupietz98cbcdc2019-01-21 17:11:27 +0100632 sum += value;
Marc Kupietz8e0ebea2018-01-24 09:53:26 +0100633 if(value > maxv)
634 maxv = value;
Marc Kupietz39a4fd02019-01-23 10:18:43 +0100635 usedPositions |= 1 << (-DIST(key)+WINDOW_SIZE-(DIST(key)<0?1:0));
Marc Kupietz75af60f2019-01-22 22:34:29 +0100636 sumWindow[-DIST(key)+WINDOW_SIZE-(DIST(key)<0?1:0)] = value;
Marc Kupietzade33222019-01-22 22:52:44 +0100637 true_window_size++;
Marc Kupietzd31254c2018-01-20 21:29:30 +0100638 }
Marc Kupietz8e0ebea2018-01-24 09:53:26 +0100639 if(DIST(key) == -1)
640 left = value;
641 else if(DIST(key) == 1)
642 right = value;
Marc Kupietzd31254c2018-01-20 21:29:30 +0100643 }
644
Marc Kupietzd91e1d42019-01-22 16:18:32 +0100645 sort(collocators.begin(), collocators.end(), sortByLogDice);
Marc Kupietzd31254c2018-01-20 21:29:30 +0100646
Marc Kupietz0779a202018-06-05 11:13:35 +0200647 /*
Marc Kupietzd31254c2018-01-20 21:29:30 +0100648 int i=0;
649 for (Collocator c : collocators) {
650 if(i++>10) break;
651 std::cout << "w1:" << _vocab[w1].word << ", w2:" << _vocab[c.w2].word
652 << "\t f(w1):" << _vocab[w1].freq
653 << "\t f(w2):" << _vocab[c.w2].freq
654 << "\t f(w1, x):" << total_w1
Marc Kupietz51f93792018-01-25 08:51:01 +0100655 << "\t f(w1, w2):" << c.raw
Marc Kupietzd31254c2018-01-20 21:29:30 +0100656 << "\t pmi:" << c.pmi
657 << "\t npmi:" << c.npmi
658 << "\t llr:" << c.llr
Marc Kupietzd31254c2018-01-20 21:29:30 +0100659 << "\t lfmd:" << c.lfmd
660 << "\t fpmi:" << c.fpmi
661 << "\t total:" << total
662 << std::endl;
663 }
Marc Kupietz0779a202018-06-05 11:13:35 +0200664 */
Marc Kupietzd31254c2018-01-20 21:29:30 +0100665 return collocators;
666 }
667
Marc Kupietzbd966192018-10-13 14:14:37 +0200668 std::vector<Collocator> rocksdb::CollocatorDB::get_collocators(uint32_t w1) {
669 return get_collocators(w1, UINT32_MAX);
670 }
671
Marc Kupietz3400aa52018-06-05 10:28:55 +0200672 void rocksdb::CollocatorDB::dumpSparseLlr(uint32_t w1, uint32_t min_cooccur) {
673 std::vector<Collocator> collocators;
674 std::stringstream stream;
675 uint64_t w2, last_w2 = 0xffffffffffffffff;
676 uint64_t maxv = 0, total_w1 = 0;
677 bool first = true;
678 for ( auto it = std::unique_ptr<CollocatorIterator>(SeekIterator(w1, 0, 0)); it->isValid(); it->Next()) {
679 uint64_t value = it->intValue(),
680 key = it->intKey();
681 w2 = W2(key);
682 total_w1 += value;
683 if(last_w2 == 0xffffffffffffffff) last_w2 = w2;
684 if (w2 != last_w2) {
685 if(maxv >= min_cooccur) {
Marc Kupietzbbd236e2019-01-21 16:50:19 +0100686 double llr = ca_ll(_vocab[w1].freq, _vocab[last_w2].freq, maxv, total, 1);
Marc Kupietz3400aa52018-06-05 10:28:55 +0200687 if(first)
688 first = false;
689 else
690 stream << " ";
691 stream << w2 << " " << llr;
692 }
693 last_w2 = w2;
694 maxv = value;
695 } else {
696 if(value > maxv)
697 maxv = value;
698 }
699 }
700 if(first)
701 stream << "1 0.0";
702 stream << "\n";
703 std::cout << stream.str();
704 }
705
Marc Kupietz4b799e92018-01-02 11:04:56 +0100706 rocksdb::Slice rocksdb::CollocatorIterator::key() const { return base_iterator_->key(); }
707 rocksdb::Slice rocksdb::CollocatorIterator::value() const { return base_iterator_->value(); }
708 rocksdb::Status rocksdb::CollocatorIterator::status() const { return base_iterator_->status(); }
709
Marc Kupietz28cc53e2017-12-23 17:24:55 +0100710};
Marc Kupietz06c9a9f2018-01-02 16:56:43 +0100711
Marc Kupietz4a5e08a2018-06-05 11:07:11 +0200712string rocksdb::CollocatorDB::getWord(uint32_t w1) {
713 return _vocab[w1].word;
714}
715
Marc Kupietz6aec7682018-01-10 09:47:48 +0100716string rocksdb::CollocatorDB::collocators2json(vector<Collocator> collocators) {
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100717 ostringstream s;
Marc Kupietz0dd86ef2018-01-11 22:23:17 +0100718 int i = 0;
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100719 s << "[";
720 bool first = true;
721 for (Collocator c : collocators) {
Marc Kupietzb999ec52018-06-05 11:20:46 +0200722 if(strncmp(_vocab[c.w2].word.c_str(), "quot", 4) == 0) continue;
Marc Kupietz0dd86ef2018-01-11 22:23:17 +0100723 if (i++ > 200)
724 break;
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100725 if(!first)
726 s << ",\n";
727 else
728 first = false;
729 s << "{"
Marc Kupietz7d9558f2019-01-22 16:26:50 +0100730 "\"word\":\"" << (string(_vocab[c.w2].word).compare("<num>") == 0? string("###") : string(_vocab[c.w2].word)) << "\"," <<
Marc Kupietzcc6c4592019-01-23 10:11:23 +0100731 "\"f2\":" << c.f2 << "," <<
Marc Kupietz51f93792018-01-25 08:51:01 +0100732 "\"f\":" << c.raw << "," <<
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100733 "\"npmi\":" << c.npmi << "," <<
Marc Kupietz41880452019-01-22 15:29:06 +0100734 "\"pmi\":" << c.pmi << "," <<
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100735 "\"llr\":" << c.llr << "," <<
736 "\"lfmd\":" << c.lfmd << "," <<
Marc Kupietz41880452019-01-22 15:29:06 +0100737 "\"md\":" << c.md << "," <<
738 "\"dice\":" << c.dice << "," <<
739 "\"ld\":" << c.logdice << "," <<
Marc Kupietz8e0ebea2018-01-24 09:53:26 +0100740 "\"llfmd\":" << c.left_lfmd << "," <<
741 "\"rlfmd\":" << c.right_lfmd << "," <<
742 "\"lnpmi\":" << c.left_npmi << "," <<
Marc Kupietz75af60f2019-01-22 22:34:29 +0100743 "\"rnpmi\":" << c.right_npmi << "," <<
Marc Kupietze9f58932019-01-24 15:12:59 +0100744 "\"af\":" << c.af << "," <<
745 "\"win\":" << c.window << "," <<
746 "\"afwin\":" << c.af_window <<
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100747 "}";
748 }
749 s << "]\n";
Marc Kupietz8e0ebea2018-01-24 09:53:26 +0100750 // cout << s.str();
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100751 return s.str();
752}
753
Marc Kupietz6aec7682018-01-10 09:47:48 +0100754typedef rocksdb::CollocatorDB COLLOCATORS;
Marc Kupietz06c9a9f2018-01-02 16:56:43 +0100755
756extern "C" {
Marc Kupietz6aec7682018-01-10 09:47:48 +0100757 COLLOCATORS *open_collocatordb_for_write(char *dbname) {
758 return new rocksdb::CollocatorDB(dbname, false);
Marc Kupietz06c9a9f2018-01-02 16:56:43 +0100759 }
760
Marc Kupietz6aec7682018-01-10 09:47:48 +0100761 COLLOCATORS *open_collocatordb(char *dbname) {
762 return new rocksdb::CollocatorDB(dbname, true);
Marc Kupietz6bb27762018-01-09 17:53:01 +0100763 }
764
Marc Kupietz6aec7682018-01-10 09:47:48 +0100765 void inc_collocator(COLLOCATORS *db, uint32_t w1, uint32_t w2, int8_t dist) {
Marc Kupietz06c9a9f2018-01-02 16:56:43 +0100766 db->inc(w1, w2, dist);
767 }
768
769 void dump_collocators(COLLOCATORS *db, uint32_t w1, uint32_t w2, int8_t dist) {
770 db->dump(w1, w2, dist);
771 }
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100772
Marc Kupietz37359b12018-01-09 21:11:37 +0100773 void get_collocators(COLLOCATORS *db, uint32_t w1) {
774 db->get_collocators(w1);
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100775 }
776
Marc Kupietzca3a52e2018-06-05 14:16:23 +0200777 const char *get_word(COLLOCATORS *db, uint32_t w) {
778 return db->getWord(w).c_str();
779 }
780
Marc Kupietz37359b12018-01-09 21:11:37 +0100781 const char *get_collocators_as_json(COLLOCATORS *db, uint32_t w1) {
782 return strdup(db->collocators2json(db->get_collocators(w1)).c_str());
Marc Kupietzc8ddf452018-01-07 21:33:12 +0100783 }
Marc Kupietz06c9a9f2018-01-02 16:56:43 +0100784}