def is_language(self, s, expected_lang):
    ' Check if the language of the segment cannot be reliably identified\n        as another language. If another than the expected language is\n        detected return False '
    expected_lang = expected_lang.lower()
    if self.valid_languages:
        assert (expected_lang in self.valid_languages)
    if self.use_cld2:
        (reliable, _text_bytes, details) = cld2.detect(s.encode('utf-8'), isPlainText=True, useFullLangTables=True, bestEffort=True)
        if reliable:
            for (_lang, langcode, confidence, score) in details:
                if ((langcode == expected_lang) and (confidence >= 10)):
                    return True
            return False
        else:
            return True
    else:
        (lang, confidence) = langid.classify(source.lower())
        if ((lang != expected_lang) and (confidence > 0.9)):
            return False
        else:
            return True
Check if the language of the segment cannot be reliably identified
as another language. If another than the expected language is
detected return False
def is_language(self, s, expected_lang):
    ' Check if the language of the segment cannot be reliably identified\n        as another language. If another than the expected language is\n        detected return False '
    expected_lang = expected_lang.lower()
    if self.valid_languages:
        assert (expected_lang in self.valid_languages)
    if self.use_cld2:
        (reliable, _text_bytes, details) = cld2.detect(s.encode('utf-8'), isPlainText=True, useFullLangTables=True, bestEffort=True)
        if reliable:
            for (_lang, langcode, confidence, score) in details:
                if ((langcode == expected_lang) and (confidence >= 10)):
                    return True
            return False
        else:
            return True
    else:
        (lang, confidence) = langid.classify(source.lower())
        if ((lang != expected_lang) and (confidence > 0.9)):
            return False
        else:
            return True