Add get_corpus_size function
Change-Id: Ie95b0f14bb8784006e9dc788d02042b6b5b9485a
diff --git a/src/collocatordb.cc b/src/collocatordb.cc
index 87d9dbd..444a030 100644
--- a/src/collocatordb.cc
+++ b/src/collocatordb.cc
@@ -309,6 +309,8 @@
uint64_t getWordId(const char *word) const;
+ uint64_t getCorpusSize() const;
+
CollocatorDB(const char *db_name, bool read_only);
// public interface of CollocatorDB.
@@ -807,6 +809,10 @@
return 0;
}
+uint64_t CollocatorDB::getCorpusSize() const {
+ return total;
+}
+
string CollocatorDB::collocators2json(uint32_t w1,
const vector<Collocator>& collocators) {
ostringstream s;
@@ -915,6 +921,8 @@
DLL_EXPORT const char *get_version() { return PROJECT_VERSION; }
+DLL_EXPORT uint64_t get_corpus_size(COLLOCATORS *db) { return db->getCorpusSize(); };
+
#ifdef __clang__
#pragma clang diagnostic push
#endif
diff --git a/src/collocatordb.h b/src/collocatordb.h
index 7803cd1..8bb3402 100644
--- a/src/collocatordb.h
+++ b/src/collocatordb.h
@@ -130,5 +130,6 @@
extern void read_vocab(COLLOCATORDB *db, char *fname);
extern char *get_version();
extern uint64_t get_word_id(COLLOCATORDB *db, const char *word);
+extern uint64_t get_corpus_size(COLLOCATORDB *db);
#endif