mirror of
https://github.com/browsermt/bergamot-translator.git
synced 2024-10-26 05:43:59 +03:00
36b3c7291a
* 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>
42 lines
1.1 KiB
C++
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;
|
|
}
|