File size: 1,174 Bytes
eaec485
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
33
34
35
36
37
38
39
40
41
42
import re



def get_json(text):
    match = re.search(r'\{.*\}', text, re.DOTALL)
    
    if match:
        json_str = match.group()  
        return json_str     
    else:
        return {"error":"No JSON found"}


def get_all(json_data,key):
    type_of_data=type(json_data[0][key])
    if type_of_data== str:
        data=""
        for item in json_data:
            data=item[key]+"\n"
        data=data.strip()
    if type_of_data== list:
        data=[]
        for item in json_data:
            data=data+item[key]
    return data

def print_match_category(score):
    if score >= 0.8:
        category = "Very high match (Strong fit for the role)"
    elif score >= 0.6:
        category = "Good match (Resume is relevant but might need improvements)"
    elif score >= 0.4:
        category = "Moderate match (Some skills match, but gaps exist)"
    else:
        category = "Low match (Not suitable for the role)"
    
    print(f"Match Score: {score:.2f}{category}") 

def truncate_text(text,tokenizer, max_tokens=5000):
    tokens = tokenizer.tokenize(text)
    return tokenizer.convert_tokens_to_string(tokens)