bergamot-translator/app/bergamot-translator-app.cpp
Jerin Philip 36b3c7291a
WASM Bindings collapse (#87)
* Safe transfer of bindings through typedefs

* Removing Translation* files and bringing in counterparts

* Remove previously commented out code

* Removing commented out include

* Absorb Translation* documentation

Co-authored-by: abhi-agg <66322306+abhi-agg@users.noreply.github.com>
2021-05-03 13:41:37 +01:00

42 lines
1.1 KiB
C++

/*
* main.cpp
*
* An application which accepts line separated texts in stdin and returns
* translated ones in stdout. It is convenient for batch processing and can be
* used with tools like SacreBLEU.
*
*/
#include <iostream>
#include <string>
#include "translator/parser.h"
#include "translator/service.h"
int main(int argc, char **argv) {
// Create a configParser and load command line parameters into a YAML config
// string.
auto configParser = marian::bergamot::createConfigParser();
auto options = configParser.parseOptions(argc, argv, true);
std::string config = options->asYamlString();
// Route the config string to construct marian model through TranslationModel
marian::bergamot::Service model(config);
TranslationRequest translationRequest;
std::vector<std::string> texts;
for (std::string line; std::getline(std::cin, line);) {
texts.emplace_back(line);
}
auto results = model.translateMultiple(std::move(texts), translationRequest);
for (auto &result : results) {
std::cout << result.getTranslatedText() << std::endl;
}
return 0;
}