heymenn commited on
Commit
08096d0
·
verified ·
1 Parent(s): 02f1abf

Update src/core.py

Browse files
Files changed (1) hide show
  1. src/core.py +17 -27
src/core.py CHANGED
@@ -4,16 +4,18 @@ from src.services.processor import *
4
  global_tech, global_tech_embeddings = load_technologies()
5
 
6
 
7
- def process_input(data, global_tech, global_tech_embeddings):
8
- prompt = set_prompt(data.problem)
9
-
10
- constraints = retrieve_constraints(prompt)
 
 
 
 
11
  constraints_stemmed = stem(constraints, "constraints")
12
 
13
  save_dataframe(constraints_stemmed, "constraints_stemmed.xlsx")
14
 
15
- #global_tech, keys, original_tech = preprocess_tech_data(df)
16
-
17
  save_dataframe(global_tech, "global_tech.xlsx")
18
 
19
  result_similarities, matrix = get_contrastive_similarities(constraints_stemmed, global_tech, global_tech_embeddings, )
@@ -28,25 +30,13 @@ def process_input(data, global_tech, global_tech_embeddings):
28
 
29
  return best_technologies
30
 
 
 
 
 
 
 
 
 
31
 
32
- def process_input_from_constraints(constraints, global_tech, global_tech_embeddings):
33
-
34
- constraints_stemmed = stem(constraints, "constraints")
35
-
36
- save_dataframe(constraints_stemmed, "constraints_stemmed.xlsx")
37
-
38
- #global_tech, keys, original_tech = preprocess_tech_data(df)
39
-
40
- save_dataframe(global_tech, "global_tech.xlsx")
41
-
42
- result_similarities, matrix = get_contrastive_similarities(constraints_stemmed, global_tech, global_tech_embeddings, )
43
-
44
- save_to_pickle(result_similarities)
45
-
46
- print(f"Matrix : {matrix} \n Constraints : {constraints_stemmed} \n Gloabl tech : {global_tech}")
47
-
48
- best_combinations = find_best_list_combinations(constraints_stemmed, global_tech, matrix)
49
- best_technologies_id = select_technologies(best_combinations)
50
- best_technologies = get_technologies_by_id(best_technologies_id,global_tech)
51
-
52
- return best_technologies
 
4
  global_tech, global_tech_embeddings = load_technologies()
5
 
6
 
7
+ def process_input(data, global_tech, global_tech_embeddings, data_type):
8
+ if data_type == "problem":
9
+ prompt = set_prompt(data.problem)
10
+ constraints = retrieve_constraints(prompt)
11
+
12
+ elif data_type == "constraints":
13
+ constraints = data
14
+
15
  constraints_stemmed = stem(constraints, "constraints")
16
 
17
  save_dataframe(constraints_stemmed, "constraints_stemmed.xlsx")
18
 
 
 
19
  save_dataframe(global_tech, "global_tech.xlsx")
20
 
21
  result_similarities, matrix = get_contrastive_similarities(constraints_stemmed, global_tech, global_tech_embeddings, )
 
30
 
31
  return best_technologies
32
 
33
+ def process_prior_art(technologies, data, data_type):
34
+ try:
35
+ prior_art_reponse = search_prior_art(technologies, data, data_type)
36
+ prior_art_search = add_citations_and_collect_uris(prior_art_reponse)
37
+ except Exception as e:
38
+ print(f"An error occured during the process, trying again : {e}")
39
+ prior_art_reponse = search_prior_art(technologies, data, data_type)
40
+ prior_art_search = add_citations_and_collect_uris(prior_art_reponse)
41
 
42
+ return prior_art_search