def add_bookmark(user, original_language, original_word, translation_language, translation_word, date, the_context, the_url, the_url_title): url = Url.find(the_url, the_url_title) text = Text(the_context, translation_language, url) if RankedWord.exists(original_word.lower(), original_language): rank1 = UserWord.find_rank(original_word.lower(), original_language) w1 = UserWord(original_word, original_language, rank1) else: w1 = UserWord(original_word, original_language, None) if RankedWord.exists(translation_word.lower(), translation_language): rank2 = UserWord.find_rank(translation_word.lower(), translation_language) w2 = UserWord(translation_word, translation_language, rank2) else: w2 = UserWord(translation_word, translation_language, None) zeeguu.db.session.add(url) zeeguu.db.session.add(text) zeeguu.db.session.add(w1) zeeguu.db.session.add(w2) t1 = Bookmark(w1, w2, user, text, date) zeeguu.db.session.add(t1) zeeguu.db.session.commit() add_probability_to_existing_words_of_user(user, t1, original_language)
def add_bookmark(user, original_language, original_word, translation_language, translation_word, date, the_context, the_url, the_url_title): url = Url.find (the_url, the_url_title) text = Text(the_context, translation_language, url) if RankedWord.exists(original_word.lower(), original_language): rank1 = UserWord.find_rank(original_word.lower(), original_language) w1 = UserWord(original_word, original_language,rank1) else: w1 = UserWord(original_word, original_language,None) if RankedWord.exists(translation_word.lower(), translation_language): rank2 = UserWord.find_rank(translation_word.lower(), translation_language) w2 = UserWord(translation_word, translation_language,rank2) else: w2 = UserWord(translation_word, translation_language,None) zeeguu.db.session.add(url) zeeguu.db.session.add(text) zeeguu.db.session.add(w1) zeeguu.db.session.add(w2) t1= Bookmark(w1,w2, user, text, date) zeeguu.db.session.add(t1) zeeguu.db.session.commit() add_probability_to_existing_words_of_user(user,t1,original_language)
def lookup(from_lang, term, to_lang): """ Used to log a given search. TODO: See what's the relation between this and goslate, that is, /goslate should already log the search... also, this requires both from and to_lang, but goslate does not. :param from_lang: :param term: :param to_lang: :return: """ from_lang = Language.find(from_lang) if not isinstance(to_lang, Language): to_lang = Language.find(to_lang) user = flask.g.user content = flask.request.form.get("text") if content is not None: text = Text.find(content, from_lang) user.read(text) else: text = None word = decode_word(term) rank = UserWord.find_rank(word, to_lang) user.searches.append( Search(user, UserWord.find(word, from_lang), to_lang, text)) zeeguu.db.session.commit() return "OK"
def lookup(from_lang, term, to_lang): """ Used to log a given search. TODO: See what's the relation between this and goslate, that is, /goslate should already log the search... also, this requires both from and to_lang, but goslate does not. :param from_lang: :param term: :param to_lang: :return: """ from_lang = Language.find(from_lang) if not isinstance(to_lang, Language): to_lang = Language.find(to_lang) user = flask.g.user content = flask.request.form.get("text") if content is not None: text = Text.find(content, from_lang) user.read(text) else: text = None word = decode_word(term) rank = UserWord.find_rank(word, to_lang) user.searches.append( Search(user, UserWord.find(word, from_lang), to_lang, text) ) zeeguu.db.session.commit() return "OK"