imamnurby commited on
Commit
6875f38
1 Parent(s): bdd7795

Update backend_utils.py

Browse files
Files changed (1) hide show
  1. backend_utils.py +9 -5
backend_utils.py CHANGED
@@ -242,7 +242,7 @@ def generate_api_usage_patterns(generative_model, tokenizer, model_input, num_be
242
 
243
  def add_params(api_usage_patterns, db_params, library_id):
244
  patterns_cp = api_usage_patterns.copy()
245
- valid = True
246
  processed_sequences = []
247
  for sequence in patterns_cp:
248
  sequence_list = sequence.split()
@@ -251,10 +251,15 @@ def add_params(api_usage_patterns, db_params, library_id):
251
  continue
252
 
253
  temp_list = []
 
 
254
  for api in sequence_list:
255
  temp_db = db_params[(db_params.id==library_id) & (db_params.methods==api.split(".")[-1])]
256
-
257
- if len(temp_db) > 0:
 
 
 
258
  param = temp_db.iloc[0].params
259
  new_api = api + param
260
  temp_list.append(new_api)
@@ -264,8 +269,7 @@ def add_params(api_usage_patterns, db_params, library_id):
264
 
265
  if valid:
266
  processed_sequences.append("[API-SEP]".join(temp_list))
267
- else:
268
- valid = True
269
  return processed_sequences
270
 
271
 
 
242
 
243
  def add_params(api_usage_patterns, db_params, library_id):
244
  patterns_cp = api_usage_patterns.copy()
245
+
246
  processed_sequences = []
247
  for sequence in patterns_cp:
248
  sequence_list = sequence.split()
 
251
  continue
252
 
253
  temp_list = []
254
+ ref_obj = ''
255
+ valid = True
256
  for api in sequence_list:
257
  temp_db = db_params[(db_params.id==library_id) & (db_params.methods==api.split(".")[-1])]
258
+
259
+ if ref_obj == '':
260
+ ref_obj = api.split(".")[0]
261
+
262
+ if len(temp_db) > 0 and ref_obj == api.split(".")[0]:
263
  param = temp_db.iloc[0].params
264
  new_api = api + param
265
  temp_list.append(new_api)
 
269
 
270
  if valid:
271
  processed_sequences.append("[API-SEP]".join(temp_list))
272
+
 
273
  return processed_sequences
274
 
275