Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/OpenNMT/CTranslate2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Klein <guillaume.klein@systrangroup.com>2018-09-27 17:00:24 +0300
committerGuillaume Klein <guillaume.klein@systrangroup.com>2018-09-27 17:00:24 +0300
commite7ba95d4869f5fded5a191572ad49fcf4fc9266a (patch)
treec2677aba5faee4874670ab6fbd5bc702c2f238af
parentc72135adb174fe84b797b5c94958af8bd3d9bc8d (diff)
Return scores and hypotheses from the Python APIv0.6.0
-rw-r--r--python/Python.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/python/Python.cc b/python/Python.cc
index 0c1ab368..cc4d7646 100644
--- a/python/Python.cc
+++ b/python/Python.cc
@@ -88,10 +88,14 @@ public:
py::list py_results;
for (const auto& result : results) {
- py::list temp;
- for (const auto& token : result.output())
- temp.append(token);
- py_results.append(temp);
+ py::list batch;
+ for (size_t i = 0; i < result.num_hypotheses(); ++i) {
+ py::list hyp;
+ for (const auto& token : result.hypotheses()[i])
+ hyp.append(token);
+ batch.append(py::make_tuple(result.scores()[i], hyp));
+ }
+ py_results.append(batch);
}
return py_results;