Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions zeeguu/api/endpoints/bookmarks_and_words.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,28 +341,6 @@ def set_user_word_exercise_dislike(bookmark_id):
return "OK"


@api.route("/is_fit_for_study/<bookmark_id>", methods=["POST"])
@cross_domain
@requires_session
def set_is_fit_for_study(bookmark_id):
bookmark = get_bookmark_if_owned(bookmark_id)
bookmark.fit_for_study = True
db_session.commit()
return "OK"


@api.route("/not_fit_for_study/<bookmark_id>", methods=["POST"])
@cross_domain
@requires_session
def set_not_fit_for_study(bookmark_id):
bookmark = get_bookmark_if_owned(bookmark_id)
bookmark.fit_for_study = False

BasicSRSchedule.clear_user_word_schedule(db_session, bookmark)
db_session.commit()
return "OK"


@api.route("/star_bookmark/<bookmark_id>", methods=["POST"])
@cross_domain
@requires_session
Expand Down
10 changes: 0 additions & 10 deletions zeeguu/core/model/bookmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,22 +629,12 @@ def find_or_create(
log(f"[BOOKMARK-TIMING] UserWord.find_or_create took {time.time() - uw_start:.3f}s")

# Log every translation
from zeeguu.core.model.bookmark_user_preference import UserWordExPreference
from zeeguu.core.model.user_word_interaction_history import UserWordInteractionHistory

UserWordInteractionHistory.log(
session, user_word, UserWordInteractionHistory.TRANSLATED
)

# Erode "declared known" confidence on re-translation
if UserWordExPreference.is_declared_known(user_word.user_preference):
# of(): the column is TEXT in prod, and "-6" + 2 raises
user_word.user_preference = UserWordExPreference.of(user_word.user_preference) + 2
if user_word.user_preference >= UserWordExPreference.NO_PREFERENCE:
user_word.user_preference = UserWordExPreference.NO_PREFERENCE
user_word.update_fit_for_study(session)
session.add(user_word)

log(f"[BOOKMARK-TIMING] Getting Source")
source = Source.find_by_id(source_id)

Expand Down
8 changes: 1 addition & 7 deletions zeeguu/core/model/bookmark_user_preference.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class UserWordExPreference(object):
# Defines user preference to use word in exercises
BAD_TRANSLATION = -100 # bad translation - permanent exclusion
DECLARED_KNOWN = -6 # freshly declared known, erodes with re-translations (-6 → -4 → -2 → 0)
DECLARED_KNOWN = -6 # declared known; whether it still is, is word knowledge's call
DONT_USE_IN_EXERCISES = -1 # other reasons - permanent exclusion
NO_PREFERENCE = 0
USE_IN_EXERCISES = 1 # user explicitly opted in (overrides quality checks)
Expand All @@ -16,9 +16,3 @@ def of(cls, preference):
return int(preference or cls.NO_PREFERENCE)
except (ValueError, TypeError):
return cls.NO_PREFERENCE

@classmethod
def is_declared_known(cls, preference):
"""Declared known uses even negative values: -6, -4, -2"""
pref = cls.of(preference)
return pref <= -2 and pref >= -6 and pref % 2 == 0
1 change: 0 additions & 1 deletion zeeguu/core/model/user_word.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ def as_dictionary(self, schedule=None, pre_tokenized_context=None, with_context_
is_about_to_be_learned=is_about_to_be_learned,
fast_track=fast_track,
can_update_schedule=can_update_schedule,
user_preference=self.user_preference,
consecutive_correct_answers=consecutive_correct_answers,
context_in_content=self.preferred_bookmark.text.in_content,
left_ellipsis=self.preferred_bookmark.context.left_ellipsis,
Expand Down
19 changes: 0 additions & 19 deletions zeeguu/core/test/test_user_preference_as_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
from zeeguu.core.bookmark_quality.fit_for_study import fit_for_study
from zeeguu.core.llm_services.translation_validator import ValidationResult
from zeeguu.core.llm_services.validation_service import UserWordValidationService
from zeeguu.core.model.bookmark import Bookmark
from zeeguu.core.model.bookmark_user_preference import UserWordExPreference
from zeeguu.core.model.context_identifier import ContextIdentifier
from zeeguu.core.model.context_type import ContextType
from zeeguu.core.model.meaning import Meaning
from zeeguu.core.model.user_word import UserWord
from zeeguu.core.test.model_test_mixin import ModelTestMixIn
Expand All @@ -29,21 +25,6 @@ def setUp(self):
self.user_word = self.bookmark.user_word
self.meaning = self.user_word.meaning

def test_looking_up_a_word_declared_known_again_erodes_the_text_value(self):
self.user_word.user_preference = "-6" # as prod returns it

Bookmark.find_or_create(
session, self.user,
self.meaning.origin.content, self.meaning.origin.language.code,
self.meaning.translation.content, self.meaning.translation.language.code,
f"Det er {self.meaning.origin.content} her.", None, None,
sentence_i=0, token_i=2, total_tokens=1, c_sentence_i=0, c_token_i=0,
context_identifier=ContextIdentifier(context_type=ContextType.USER_EDITED_TEXT),
translation_source="reading",
)

self.assertEqual(self.user_word.user_preference, UserWordExPreference.DECLARED_KNOWN + 2)

def test_an_audio_lesson_adds_a_word_whose_preference_is_a_text_zero(self):
from zeeguu.core.bookmark_operations.add_word_to_study import add_word_to_study

Expand Down
Loading