Module: Translator

Included in:
AwsEngine
Defined in:
lib/engines/translator.rb

Overview

A Module that kind of acts as an interface where the methods expected out of each vendor is encapsulated into

To use for a new vendor, simply include this module and provide caption specific implementations

Defined Under Namespace

Classes: EngineInitializationException

Constant Summary collapse

ENGINE_AWS =

Constants For Engines

1
ENGINE_GCP =
2
AWS_KEYS =

Keys for each Engine

[:access_key_id, :secret_access_key, :profile]
GCP_KEYS =
[:api_key, :project_id, :creds_path]
ENGINE_KEYS =
{ENGINE_AWS => AWS_KEYS, ENGINE_GCP => GCP_KEYS}

Instance Method Summary collapse

Instance Method Details

#infer_language(text) ⇒ Object

Method to infer the language by inspecting the text passed as argument

:args: text

  • text - String whose language needs to be inferred

Returns

  • The ISO 639-1 Letter Language code



42
43
44
# File 'lib/engines/translator.rb', line 42

def infer_language(text)
  raise "Not Implemented. Class #{self.class.name} doesn't implement infer_language"
end

#translate(input_text, src_lang, target_lang) ⇒ Object

Method to translate from given language to another

:args: input_text, src_lang, target_lang, output_file

  • input_text - Text which needs to be translated

  • src_lang - can be inferred using #infer_language method

  • target_lang - Target 2 letter ISO language code to which the source needs to be translated in to.



55
56
57
# File 'lib/engines/translator.rb', line 55

def translate(input_text, src_lang, target_lang)
  raise "Not Implemented. Class #{self.class.name} doesn't implement translate"
end