mirror of
https://github.com/browsermt/bergamot-translator.git
synced 2024-09-11 05:35:33 +03:00
Handle empty translation requests
Fixes https://github.com/browsermt/bergamot-translator/issues/101. ResponseBuilder is called with empty histories to trigger a valid but mostly-empty response.
This commit is contained in:
parent
fa2003e70d
commit
4be96a97d7
@ -20,6 +20,13 @@ Request::Request(size_t Id, Segments &&segments,
|
||||
|
||||
counter_ = segments_.size();
|
||||
histories_.resize(segments_.size(), nullptr);
|
||||
|
||||
// If there are no segments_, we are never able to trigger the responseBuilder
|
||||
// calls from a different thread. However, in this case we want an empty valid
|
||||
// response.
|
||||
if (segments_.size() == 0) {
|
||||
responseBuilder_(std::move(histories_));
|
||||
}
|
||||
}
|
||||
|
||||
size_t Request::numSegments() const { return segments_.size(); }
|
||||
|
Loading…
Reference in New Issue
Block a user