Created
February 17, 2022 08:44
-
-
Save thunder775/6b50a4c07cfe4ca2427e304b287c6e37 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from src.nextPairs.dictionaryDao import dictionary_dao | |
from src.nextPairs.optimalItemGenerator import get_next_item_id | |
corpus = dictionary_dao.retrieve_whole_dictionary() | |
def get_ranked_next_pair(ids_array, responses_array): | |
latest_pair_id = get_next_item_id(sum(responses_array), corpus, ids_array) | |
second_latest_pair_id = get_next_item_id(sum(responses_array[:-1]), corpus, ids_array[:-1]) | |
third_latest_pair_id = get_next_item_id(sum(responses_array[:-2]), corpus, ids_array[:-2]) | |
latest_pair = dictionary_dao.get(latest_pair_id) | |
second_latest_pair = dictionary_dao.get(second_latest_pair_id) | |
third_latest_pair = dictionary_dao.get(third_latest_pair_id) | |
latest_percent_change = (abs(latest_pair['difficulty'] - second_latest_pair['difficulty']) / second_latest_pair['difficulty']) * 100 | |
second_latest_percent_change = (abs(second_latest_pair['difficulty'] - third_latest_pair['difficulty']) / third_latest_pair['difficulty']) * 100 | |
if latest_percent_change <= 5 and second_latest_percent_change < 5: | |
latest_pair['ranking'] = latest_pair['difficulty'] | |
return latest_pair | |
return latest_pair |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment