File size: 973 Bytes
a1372cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import json


def get_intersection(a: list, b: list) -> list:
    a = [i.lower() for i in a]
    b = [i.lower() for i in b]
    return sorted(set(a).intersection(set(b)))


def not_in_intersection(a: list, b: list) -> list:
    return sorted(set(a).union(set(b)).difference(set(a).intersection(b)))


def get_score(true_values: list, predicted_values: list) -> float:
    intersection_list = get_intersection(true_values, predicted_values)
    return len(intersection_list) / len(true_values) if len(true_values) else 0


def match(present_features, not_present_features):
    relevant_skills = len(present_features)
    total_skills = len(present_features + not_present_features)
    match = round(100.0 * (relevant_skills / total_skills), 2)
    return match


def get_json_list_from_result(result: dict, key: str) -> list:
    try:
        return json.loads(result[key].strip())
    except json.decoder.JSONDecodeError:
        print(key, result[key])
        return []