# Path: languages/utils.py
# def word_score(word, triple_scores):
#     triples = list(word_triples(word))
#     result = 0.0
#     for triple in triples:
#         result += triple_scores.get(triple, 0.0)
#     return result / len(triples)


from datetime import datetime
from google.appengine.ext import db
from django.core.urlresolvers import reverse
from languages.utils import word_score
        from languages import english, spanish, german, french
        from prefixes.popular import prefix_score, suffix_score
        of the software.
        """
        for attr in OBSOLETE_ATTRIBUTES:
            if hasattr(self, attr):
                delattr(self, attr)

    def update_counts(self):
        """
        Count digits and dashes.
        """
        name = self.key().name()
        self.length = len(name)
        self.digits = self.dashes = 0
        for char in name:
            if '0' <= char <= '9':
                self.digits += 1
            elif char == '-':
                self.dashes += 1

    def language_scores_need_update(self):
        for lang in 'english spanish french german'.split():
            if not hasattr(self, lang):
                return True
            score = getattr(self, lang)
            if score is None or score < 0.0 or score >= 1.0:
                return True
        return False

    def update_language_scores(self):
        self.english = word_score(self.key().name(), english.TRIPLE_SCORES)

# Path: languages/utils.py
# def word_score(word, triple_scores):
#     triples = list(word_triples(word))
#     result = 0.0
#     for triple in triples:
#         result += triple_scores.get(triple, 0.0)
#     return result / len(triples)


# Path: domains/models.py
from datetime import datetime
from google.appengine.ext import db
from django.core.urlresolvers import reverse
from languages.utils import word_score
        from languages import english, spanish, german, french
        from prefixes.popular import prefix_score, suffix_score

        of the software.
        """
        for attr in OBSOLETE_ATTRIBUTES:
            if hasattr(self, attr):
                delattr(self, attr)

    def update_counts(self):
        """
        Count digits and dashes.
        """
        name = self.key().name()
        self.length = len(name)
        self.digits = self.dashes = 0
        for char in name:
            if '0' <= char <= '9':
                self.digits += 1
            elif char == '-':
                self.dashes += 1

    def language_scores_need_update(self):
        for lang in 'english spanish french german'.split():
            if not hasattr(self, lang):
                return True
            score = getattr(self, lang)
            if score is None or score < 0.0 or score >= 1.0:
                return True
        return False

    def update_language_scores(self):
        self.english = word_score(self.key().name(), english.TRIPLE_SCORES)

        self.spanish = word_score(self.key().name(), spanish.TRIPLE_SCORES)