zeeguu/core/language/strategies/cognacy_difficulty_estimator.py
def cognacyRatio(cls, language: 'model.Language', user: 'model.User'):
        """
                This estimator computes the ratio of new words for a given user and language
                :param language: language of the text that needs to be estimated
                :param user: the user for which the difficulty estimation needs to be done
                :rtype: WordHistoryDifficultyEstimator
                :return: WordHistoryDifficultyEstimator with initialized user, language and word => score map
                        which can be used for determining scores for multiple articles for the same user and language
        """

        estimator = cls(language, user)

        # fetch cognates
        cognate_info = CognateEvaluation.load_cached(language.code, user.native_language.code, EditDistance)

        # stem cognates, assign difficulty of 0
        cognates = cognate_info.whitelist.keys()
        stemmer = SnowballStemmer(language.name.lower())

        cognates = list(set([stemmer.stem(c.lower()) for c in cognates]))
        words_score = [0 for e in cognates]

        estimator.score_map = dict(zip(cognates, words_score))

        return estimator

                This estimator computes the ratio of new words for a given user and language
                :param language: language of the text that needs to be estimated
                :param user: the user for which the difficulty estimation needs to be done
                :rtype: WordHistoryDifficultyEstimator
                :return: WordHistoryDifficultyEstimator with initialized user, language and word => score map
                        which can be used for determining scores for multiple articles for the same user and language
        
This estimator computes the ratio of new words for a given user and language
This estimator computes the ratio of new words for a given user and language
def cognacyRatio(cls, language: 'model.Language', user: 'model.User'):
        estimator = cls(language, user)
        cognate_info = CognateEvaluation.load_cached(language.code, user.native_language.code, EditDistance)
        cognates = cognate_info.whitelist.keys()
        stemmer = SnowballStemmer(language.name.lower())
        cognates = list(set([stemmer.stem(c.lower()) for c in cognates]))
        words_score = [0 for e in cognates]
        estimator.score_map = dict(zip(cognates, words_score))
        return estimator
def cognacyRatio ( cls , language : 'model.Language' , user : 'model.User' ) : estimator = cls ( language , user ) cognate_info = CognateEvaluation . load_cached ( language . code , user . native_language . code , EditDistance ) cognates = cognate_info . whitelist . keys ( ) stemmer = SnowballStemmer ( language . name . lower ( ) ) cognates = list ( set ( [ stemmer . stem ( c . lower ( ) ) for c in cognates ] ) ) words_score = [ 0 for e in cognates ] estimator . score_map = dict ( zip ( cognates , words_score ) ) return estimator
This estimator computes the ratio of new words for a given user and language
This estimator computes the ratio of new words for a given user and language
"""
                This estimator computes the ratio of new words for a given user and language
                :param language: language of the text that needs to be estimated
                :param user: the user for which the difficulty estimation needs to be done
                :rtype: WordHistoryDifficultyEstimator
                :return: WordHistoryDifficultyEstimator with initialized user, language and word => score map
                        which can be used for determining scores for multiple articles for the same user and language
        """ # fetch cognates # stem cognates, assign difficulty of 0
WordHistoryDifficultyEstimator with initialized user, language and word => score map
which can be used for determining scores for multiple articles for the same user and language
WordHistoryDifficultyEstimator with initialized user language and word = > score map which can be used for determining scores for multiple articles for the same user and language
WordHistoryDifficultyEstimator
cls
language
'model.Language'
language of the text that needs to be estimated
language of the text that needs to be estimated
user
'model.User'
the user for which the difficulty estimation needs to be done
the user for which the difficulty estimation needs to be done