Add get_word_frequency function
Change-Id: Idef55f5a8f84c4bcba0a1bfdbe563eb74f26857a
diff --git a/src/collocatordb.cc b/src/collocatordb.cc
index 444a030..57a01d9 100644
--- a/src/collocatordb.cc
+++ b/src/collocatordb.cc
@@ -311,6 +311,8 @@
uint64_t getCorpusSize() const;
+ uint64_t getWordFrequency(uint64_t w1);
+
CollocatorDB(const char *db_name, bool read_only);
// public interface of CollocatorDB.
@@ -813,6 +815,10 @@
return total;
}
+uint64_t CollocatorDB::getWordFrequency(uint64_t w1) {
+ return _vocab[w1].freq;
+}
+
string CollocatorDB::collocators2json(uint32_t w1,
const vector<Collocator>& collocators) {
ostringstream s;
@@ -923,6 +929,10 @@
DLL_EXPORT uint64_t get_corpus_size(COLLOCATORS *db) { return db->getCorpusSize(); };
+DLL_EXPORT uint64_t get_word_frequency(COLLOCATORS *db, uint64_t w1) {
+ return db->getWordFrequency(w1);
+}
+
#ifdef __clang__
#pragma clang diagnostic push
#endif