I have got two lists in python with elements. I want to perform some checks in those two lists. My lists are the following:
list_A = [["'EASY'", "'LEVEL_C'", "'4'", '0.714', '\n'], ["'EASY'", "'LEVEL_D'", "'5'", '0.778', '\n'], ["'EASY'", "'LEVEL_D'", "'5'", '0.226', '\n'], ["'EASY'", "'LEVEL_D'", "'5'", '0.222', '\n'], ...]
list_B = [["'EASY'", "'LEVEL_B'", "'2'", '1.000', '\n'], ["'EASY'", "'LEVEL_C'", "'3'", '1.000', '\n'], ["'EASY'", "'LEVEL_D'", "'4'", '1.000', '\n'], ["'EASY'", "'LEVEL_D'", "'4'", '0.290', '\n'], ...]
For the variable "EASY" and for the variable level which takes the values (LEVEL_A - LEVEL_F) there is a third variable correspond to score (1-6) and the confidence variable (0-1). What I want to do is to compare the two lists for the variable easy and level and to find in all cases which of the two lists (list_A and list_B) has greater score and with which confidence. How can I do so?
The way that I am constructing my rules, in the beginning I ve got the rows derived from an executable and filter them into lists. A vector example for my lists is the following:
Rule: ('EASY', 'LEVEL_E') ==> ('4') , 0.182
'EASY' 'LEVEL_E' '4' 0.182
["'EASY'", "'LEVEL_E'", , "'4'", '0.182', '\n']
and the code that I am using for creating the vector:
for row in my_lines:
print row
row = re.sub('[()]', "", row)
row = row.replace("Rule: ", "")
row = row.replace(",", "")
row = row.replace("==>", "")
print row
split = re.split(r' +', row)
print split
Then as soon as I have created my lists i sort them with the second element which corresponds to the variable Level:
list_A.sort(key=lambda x: x[1])
list_B.sort(key=lambda x: x[1])
EDIT: I have sorted the lists with the variable level. Now I want to compare the two lists regarding the score for all the variable levels. When a level does not exist then the score is zero and when the same score exist twice the system should prefer the one with highest confidence. How can I compare all the possibles values for the variable level?