A score for each language corresponding to the probability that
        the text is written in the given language.
        The score is a `float` value between 0.0 and 1.0

        :param text: source code.
        :return: language to score dictionary
545751
def scores(self, text: str) -> Dict[str, float]:
        
        values = extract(text)
        input_fn = _to_func(([values], []))
        prediction = self._classifier.predict_proba(input_fn=input_fn)
        probabilities = next(prediction).tolist()
        sorted_languages = sorted(self.languages)
        return dict(zip(sorted_languages, probabilities))
1147392
def choose_locale(self, locale: Text) -> Text:
        

        if locale not in self._choice_cache:
            locales = self.list_locales()

            best_choice = locales[0]
            best_level = 0

            for candidate in locales:
                cmp = compare_locales(locale, candidate)

                if cmp > best_level:
                    best_choice = candidate
                    best_level = cmp

            self._choice_cache[locale] = best_choice

        return self._choice_cache[locale]
126543
def say(self, txt, lang=None):
        '''
        
        '''
        lang = lang or self.classify(txt)
        self.get_engine_for_lang(lang).say(txt, language=lang)
196885
def _number(text):
    '''
    
    '''
    if text.isdigit():
        return int(text)
    try:
        return float(text)
    except ValueError:
        return text
134239
def language(s):
    
    s = decode_utf8(s)
    s = set(w.strip(PUNCTUATION) for w in s.replace("'", "' ").split())
    n = float(len(s) or 1)
    p = {}
    for xx in LANGUAGES:
        lexicon = _module(xx).__dict__["lexicon"]
        p[xx] = sum(1 for w in s if w in lexicon) / n
    return max(p.items(), key=lambda kv: (kv[1], int(kv[0] == "en")))
927240
def detect(self, text, proxies=None, format="plain"):
    
    data = {
      "text": text,
      "format": format,
      "key": self.api_key,
    }
    try:
      response = requests.post(self.url("detect"), data=data, proxies=proxies)
    except ConnectionError:
      raise YandexTranslateException(self.error_codes[503])
    except ValueError:
      raise YandexTranslateException(response)
    else:
      response = response.json()
    language = response.get("lang", None)
    status_code = response.get("code", 200)
    if status_code != 200:
      raise YandexTranslateException(status_code)
    elif not language:
      raise YandexTranslateException(501)
    return language
1271608
def valueFromText( self, text ):
        
        value, currency = projex.money.fromString(text)
        
        return value
1372903
def guess_encoding(text, default=DEFAULT_ENCODING):
    
    result = chardet.detect(text)
    return normalize_result(result, default=default)
562069
def text(self, text):
        
        tc = self._tc
        tc.clear_content()
        p = tc.add_p()
        r = p.add_r()
        r.text = text
851199
def from_text(text):
        
        number = int(filter(unicode.isdigit, unicode(text)))
        return Phone(number=number)
298460
def of_text(self, text, encoding="utf-8"):
        
        m = self.hash_algo()
        m.update(text.encode(encoding))
        if self.return_int:
            return int(m.hexdigest(), 16)
        else:
            return m.hexdigest()
1302906
static private function languageScore( $mask )
    {
        $prioritizedLanguages = eZContentLanguage::prioritizedLanguages();
        $scores = array();
        $score = 1;
        $mask   = (int)$mask;
        krsort( $prioritizedLanguages );
        foreach ( $prioritizedLanguages as $prioritizedLanguage )
        {
            $id = (int)$prioritizedLanguage->attribute( 'id' );
            if ( $id & $mask )
            {
                $scores[] = $score;
            }
            ++$score;
        }
        if ( count( $scores ) > 0 )
        {
            return max( $scores );
        }
        else
        {
            return 0;
        }
    }
850806
def score(self, X, y):
        
        predictions = self.predict(X)
        true = 0.0
        total = 0.0
        for i in range(len(predictions)):
            total += 1
            if predictions[i] == y[i]:
                true += 1
        return true/total
95950
def language(self, value):
        

        if value is not None:
            assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
                "language", value)
        self.__language = value
754381
def Text(text):
    
    if not is_unicode(text):
        text = text.decode("utf-8")
    text = unicodedata.normalize("NFC", text)
    return text
1367900
def classify(self, text):
        
        text_features = self.extract_features(text)
        return self.classifier.classify(text_features)
1193617
def polarity(self):
    
    scores = [w.polarity for w in self.words if w.polarity != 0]
    if not scores:
      return 0.0
    return sum(scores) / float(len(scores))