File size: 1,697 Bytes
1f05644
 
 
8a495ab
 
 
08096d0
 
 
 
 
 
 
 
1f05644
 
 
8a495ab
1f05644
 
 
 
 
 
b0355df
 
6117e08
1f05644
 
 
4c02ba8
 
be240c1
08096d0
be240c1
08096d0
 
 
be240c1
08096d0
4c02ba8
08096d0
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
from src.services.utils import *
from src.services.processor import *

global_tech, global_tech_embeddings = load_technologies()


def process_input(data, global_tech, global_tech_embeddings, data_type):
    if data_type == "problem":
        prompt = set_prompt(data.problem)
        constraints = retrieve_constraints(prompt)
    
    elif data_type == "constraints":
        constraints = data
        
    constraints_stemmed = stem(constraints, "constraints")
    
    save_dataframe(constraints_stemmed, "constraints_stemmed.xlsx")
        
    save_dataframe(global_tech, "global_tech.xlsx")
    
    result_similarities, matrix = get_contrastive_similarities(constraints_stemmed, global_tech, global_tech_embeddings, )
    
    save_to_pickle(result_similarities)
    
    print(f"Matrix : {matrix} \n Constraints : {constraints_stemmed} \n Gloabl tech : {global_tech}")
    
    best_combinations = find_best_list_combinations(constraints_stemmed, global_tech, matrix)
    best_technologies_id = select_technologies(best_combinations)
    best_technologies = get_technologies_by_id(best_technologies_id,global_tech)
    
    return best_technologies

def process_prior_art(technologies, data, data_type, techno_type):
    try:
        prior_art_reponse = search_prior_art(technologies, data, data_type, techno_type)
        prior_art_search = add_citations_and_collect_uris(prior_art_reponse)
    except Exception as e:
        print(f"An error occured during the process, trying again : {e}")
        prior_art_reponse = search_prior_art(technologies, data, data_type, techno_type)
        prior_art_search = add_citations_and_collect_uris(prior_art_reponse)

    return prior_art_search