polyglot.detect package

Submodules

polyglot.detect.base module

Detecting languages

class polyglot.detect.base.Detector(text, quiet=False)[source]

Bases: object

Detect the language used in a snippet of text.

detect(text)[source]

Decide which language is used to write the text.

The method tries first to detect the language with high reliability. If that is not possible, the method switches to best effort strategy.

Parameters:text (string) – A snippet of text, the longer it is the more reliable we can detect the language used to write the text.
quiet = None

If true, exceptions will be silenced.

reliable = None

False if the detector used Best Effort strategy in detection.

static supported_languages()[source]

Returns a list of the languages that can be detected by pycld2.

exception polyglot.detect.base.Error[source]

Bases: exceptions.Exception

Base exception class for this class.

class polyglot.detect.base.Language(choice)[source]

Bases: object

code
static from_code(code)[source]
name
exception polyglot.detect.base.UnknownLanguage[source]

Bases: polyglot.detect.base.Error

Raised if we can not detect the language of a text snippet.

polyglot.detect.langids module

Module contents

class polyglot.detect.Detector(text, quiet=False)[source]

Bases: object

Detect the language used in a snippet of text.

detect(text)[source]

Decide which language is used to write the text.

The method tries first to detect the language with high reliability. If that is not possible, the method switches to best effort strategy.

Parameters:text (string) – A snippet of text, the longer it is the more reliable we can detect the language used to write the text.
static supported_languages()[source]

Returns a list of the languages that can be detected by pycld2.

class polyglot.detect.Language(choice)[source]

Bases: object

code
static from_code(code)[source]
name