Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jelmervdl committed Jun 15, 2023
1 parent 7d6f4e5 commit 40e4c1c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions bindings/python/bergamot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <vector>

namespace py = pybind11;

Expand Down Expand Up @@ -118,19 +118,19 @@ class ServicePyAdapter {
return responses;
}

void setTerminology(py::dict terminology, bool forceTerminology=false) {
void setTerminology(py::dict terminology, bool forceTerminology = false) {
// It seems copying is not too bad for performance. Also this should happen rarely and with small objects
// https://github.com/pybind/pybind11/issues/3033
std::unordered_map<std::string, std::string> cppTerminology;
for (std::pair<py::handle, py::handle> item : terminology) {
auto key = item.first.cast<std::string>();
auto value = item.second.cast<std::string>();
cppTerminology[key] = value;
auto key = item.first.cast<std::string>();
auto value = item.second.cast<std::string>();
cppTerminology[key] = value;
}
service_.setTerminology(cppTerminology, forceTerminology);
}

private /*functions*/:
private /*functions*/:
static Service make_service(const Service::Config &config) {
py::scoped_ostream_redirect outstream(std::cout, // std::ostream&
py::module_::import("sys").attr("stdout") // Python output
Expand All @@ -144,7 +144,7 @@ class ServicePyAdapter {
return Service(config);
}

private /*data*/:
private /*data*/:
Service service_;
};

Expand Down Expand Up @@ -213,8 +213,8 @@ PYBIND11_MODULE(_bergamot, m) {
.def("setTerminology", &ServicePyAdapter::setTerminology);

py::class_<Service::Config>(m, "ServiceConfig")
.def(py::init<>([](size_t numWorkers, size_t cacheSize, std::string logging,
std::string pathToTerminologyFile, bool terminologyForce, std::string terminologyForm ) {
.def(py::init<>([](size_t numWorkers, size_t cacheSize, std::string logging, std::string pathToTerminologyFile,
bool terminologyForce, std::string terminologyForm) {
Service::Config config;
config.numWorkers = numWorkers;
config.cacheSize = cacheSize;
Expand Down

0 comments on commit 40e4c1c

Please sign in to comment.