Package translate :: Package lang :: Module identify :: Class LanguageIdentifier

[hide private]
[frames] | no frames]

# Class LanguageIdentifier

source code

Instance Methods | [hide private]

__init__(self, model_dir=None, conf_file=None) x.__init__(...) initializes x; see x.__class__.__doc__ for signature | source code

_load_config(self, conf_file) Load the mapping of language names to language codes as given in the configuration file. | source code

identify_lang(self, text) Identify the language of the text in the given string. | source code

identify_source_lang(self, instore) Identify the source language of the given translation store or units. | source code

identify_target_lang(self, instore) Identify the target language of the given translation store or units. | source code

Inherited from `object`: `__delattr__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__str__`

Class Variables | [hide private]

| MODEL_DIR = ``u'``/opt/sf/build_src/translate/misc/../share/langmo``...`` The directory containing the ngram language model files.
| CONF_FILE = ``'``fpdb.conf``'`` The name of the file that contains language name-code pairs (relative to `MODEL_DIR`).

Properties | [hide private]

Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, model_dir=None, conf_file=None)
(Constructor)

source code

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
  (inherited documentation)

### identify_source_lang(self, instore)

source code

Identify the source language of the given translation store or units.

Parameters:
  - `instore` (`TranslationStore` or list or tuple of `TranslationUnit`s.) - The translation store to extract source text from.
Returns:
  The identified language's code or `None` if the language could not be identified.

### identify_target_lang(self, instore)

source code

Identify the target language of the given translation store or units.

Parameters:
  - `instore` (`TranslationStore` or list or tuple of `TranslationUnit`s.) - The translation store to extract target text from.
Returns:
  The identified language's code or `None` if the language could not be identified.

Class Variable Details | [hide private]

### MODEL_DIR

The directory containing the ngram language model files.

Value:

      u'/opt/sf/build_src/translate/misc/../share/langmodels'