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

[hide private]
[frames] | no frames]

# Class LanguageIdentifier

source code

Instance Methods | [hide private]

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

_lang_result_to_list(self, lang_result) Converts a text result of '[lang][lang]' into a Python list of language codes | source code

identify(self, text, sample_length=None) Identify the language in text by sampling sample_length | source code

identify_store(self, store, sample_length=None) Identify the language of a translation store | source code

__del__(self) | source code

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

Class Variables | [hide private]

| lang_list_re = `re.compile("\[(.+?)\]+")`

Properties | [hide private]

Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, config, model_dir)
(Constructor)

source code

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

Parameters:
  - `config` (String) - path to .conf for textcat
  - `model_dir` (String) - path to language models
Overrides: object.__init__

### identify(self, text, sample_length=None)

source code

Identify the language in text by sampling sample_length

Parameters:
  - `text` (String) - Text to be identified
  - `sample_length` (Int) - The amount of text to be analysed
Returns:
  list of language codes

### identify_store(self, store, sample_length=None)

source code

Identify the language of a translation store

Parameters:
  - `store` (TranslationStore) - Store to be identified
  - `sample_length` (Int) - The amount of text to be analysed
Returns:
  list of language codes