def set_know_word_prob(): zeeguu.app.test_request_context().push() zeeguu.db.session.commit() enc_probs = EncounterBasedProbability.find_all() ex_probs = ExerciseBasedProbability.find_all() for prob in enc_probs: user = prob.user word = prob.ranked_word.word language = prob.ranked_word.language user_word = None if UserWord.exists(word, language): user_word = UserWord.find(word, language) if ExerciseBasedProbability.exists(user, user_word): ex_prob = ExerciseBasedProbability.find(user, user_word) known_word_prob = KnownWordProbability.calculateKnownWordProb(ex_prob.probability, prob.probability) known_word_probability_obj = KnownWordProbability.find(user, user_word, prob.ranked_word, known_word_prob) else: known_word_probability_obj = KnownWordProbability.find(user, None, prob.ranked_word, prob.probability) zeeguu.db.session.add(known_word_probability_obj) zeeguu.db.session.commit() for prob in ex_probs: user = prob.user language = prob.user_word.language word = prob.user_word.word ranked_word = None if RankedWord.exists(word, language): ranked_word = RankedWord.find(word, language) if not EncounterBasedProbability.exists(user, ranked_word): if UserWord.exists(word, language): user_word = UserWord.find(word, language) known_word_probability_obj = KnownWordProbability(user, user_word, ranked_word, prob.probability) zeeguu.db.session.add(known_word_probability_obj) zeeguu.db.session.commit() print "job3"
def set_know_word_prob(): zeeguu.app.test_request_context().push() zeeguu.db.session.commit() enc_probs = EncounterBasedProbability.find_all() ex_probs = ExerciseBasedProbability.find_all() for prob in enc_probs: user = prob.user word = prob.ranked_word.word language = prob.ranked_word.language user_word = None if UserWord.exists(word, language): user_word = UserWord.find(word, language) if ExerciseBasedProbability.exists(user, user_word): ex_prob = ExerciseBasedProbability.find(user, user_word) known_word_prob = KnownWordProbability.calculateKnownWordProb( ex_prob.probability, prob.probability) known_word_probability_obj = KnownWordProbability.find( user, user_word, prob.ranked_word, known_word_prob) else: known_word_probability_obj = KnownWordProbability.find( user, None, prob.ranked_word, prob.probability) zeeguu.db.session.add(known_word_probability_obj) zeeguu.db.session.commit() for prob in ex_probs: user = prob.user language = prob.user_word.language word = prob.user_word.word ranked_word = None if RankedWord.exists(word, language): ranked_word = RankedWord.find(word, language) if not EncounterBasedProbability.exists(user, ranked_word): if UserWord.exists(word, language): user_word = UserWord.find(word, language) known_word_probability_obj = KnownWordProbability( user, user_word, ranked_word, prob.probability) zeeguu.db.session.add(known_word_probability_obj) zeeguu.db.session.commit() print 'job3'