diff --git a/src/cpp_string_metric.hpp b/src/cpp_string_metric.hpp index acee291..6084639 100644 --- a/src/cpp_string_metric.hpp +++ b/src/cpp_string_metric.hpp @@ -1,6 +1,56 @@ #pragma once #include "cpp_common.hpp" + +template +static inline bool legacy_scorer_func_wrapper_f64(const RF_ScorerFunc* self, const RF_String* str, double score_cutoff, double* result) +{ + CachedScorer& scorer = *(CachedScorer*)self->context; + try { + *result = visit(*str, [&](auto s){ + return scorer.ratio(s, score_cutoff); + }) * 100; + } catch(...) { + PyGILState_STATE gilstate_save = PyGILState_Ensure(); + CppExn2PyErr(); + PyGILState_Release(gilstate_save); + return false; + } + return true; +} + +template