Spaces:
Sleeping
Sleeping
File size: 1,433 Bytes
daea7f9 |
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 |
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include "hash_table.h"
#include "bloom_filter.h"
#include "min_hash.h"
#include "sim_hash.h"
namespace py = pybind11;
PYBIND11_MODULE(MyHash, m)
{
py::class_<HashTable>(m, "HashTable")
.def(py::init<size_t, size_t>(), py::arg("numPlanes") = 32, py::arg("dimension") = 2048)
.def("hashFunction", &HashTable::hashFunction, py::arg("featureVector"));
py::class_<BloomFilter>(m, "BloomFilter")
.def(py::init<size_t, size_t, size_t>(),
py::arg("numPlanes") = 64,
py::arg("dimension") = 2048,
py::arg("k") = 4)
.def("hashFunction", &BloomFilter::hashFunction,
py::arg("featureVector"));
py::class_<MinHash>(m, "MinHash")
.def(py::init<size_t,size_t>(), py::arg("num_planes") = 128,py::arg("dimension") = 2048)
.def("computeSignatures", &MinHash::computeSignatures,
py::arg("matrix"), py::arg("useMedianThreshold") = false)
.def("hashFunction", &MinHash::hashFunction,
py::arg("vec"), py::arg("useMedianThreshold") = false);
py::class_<SimHash>(m, "SimHash")
.def(py::init<size_t>(), py::arg("bit") = HASH_BITS)
.def("IDF", &SimHash::IDF,
py::arg("allFeatures"))
.def("hashFunction", &SimHash::hashFunction,
py::arg("featureVector"));
} |