Class: ABBYY::Cloud::Namespaces::MachineTranslations
- Defined in:
- lib/abbyy/cloud/namespaces/machine_translations.rb
Overview
Namespace for operations with machine translations
Instance Method Summary collapse
-
#default_engine ⇒ ABBYY::Cloud::Models::Engine
Returns engine object for the default engine.
-
#engine(name) ⇒ ABBYY::Cloud::Models::Engine
Returns engine object selected by its name.
-
#engines ⇒ Array<ABBYY::Cloud::Models::Engine>
Returns list of all available engines.
-
#translate(text, from:, to:, **opts) ⇒ ABBYY::Cloud::Models::Translation
Instantly (synchronously) translates the text.
-
#translate_segments(texts, from:, to:, **opts) ⇒ ABBYY::Cloud::Models::Translation
Instantly (synchronously) translates array of texts.
Instance Method Details
#default_engine ⇒ ABBYY::Cloud::Models::Engine
Returns engine object for the default engine
22 23 24 |
# File 'lib/abbyy/cloud/namespaces/machine_translations.rb', line 22 def default_engine engine(settings.engine) end |
#engine(name) ⇒ ABBYY::Cloud::Models::Engine
Returns engine object selected by its name
16 17 18 |
# File 'lib/abbyy/cloud/namespaces/machine_translations.rb', line 16 def engine(name) engines.find { |engine| engine.name == name } end |
#engines ⇒ Array<ABBYY::Cloud::Models::Engine>
Returns list of all available engines
10 11 12 |
# File 'lib/abbyy/cloud/namespaces/machine_translations.rb', line 10 def engines Operations::Engines.new(settings).call end |
#translate(text, from:, to:, **opts) ⇒ ABBYY::Cloud::Models::Translation
Instantly (synchronously) translates the text
36 37 38 39 40 41 42 |
# File 'lib/abbyy/cloud/namespaces/machine_translations.rb', line 36 def translate(text, from:, to:, **opts) Operations::Translate.new(settings).call source_text: text, source_language: from, target_language: to, engine: settings.engine, **opts end |
#translate_segments(texts, from:, to:, **opts) ⇒ ABBYY::Cloud::Models::Translation
Instantly (synchronously) translates array of texts
54 55 56 57 58 59 60 |
# File 'lib/abbyy/cloud/namespaces/machine_translations.rb', line 54 def translate_segments(texts, from:, to:, **opts) sources = texts.map { |text| { text: text } } Operations::TranslateSegments .new(settings) .call sources: sources, from: from, to: to, engine: settings.engine, **opts end |