amir22010 commited on
Commit
f633cbf
·
1 Parent(s): abccac8

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -30,7 +30,6 @@ except:
30
 
31
  '''
32
  def perform_asde_inference(text, dataset, model_id):
33
- print(text)
34
  if not text:
35
  if model_id == "PyABSA_Hospital_English_allenai/tk-instruct-base-def-pos_FinedTuned_Model":
36
  df = pd.read_csv('pyabsa_english.csv')#validation dataset
@@ -39,7 +38,6 @@ def perform_asde_inference(text, dataset, model_id):
39
  text = selected_df['clean_text']
40
  true_aspect = selected_df['actual_aspects']
41
  true_sentiment = selected_df['actual_sentiments']
42
-
43
 
44
  bos_instruction = """Definition: The output will be the aspects (both implicit and explicit) and the aspects sentiment polarity. In cases where there are no aspects the output should be noaspectterm:none.
45
  Positive example 1-
@@ -67,11 +65,15 @@ def perform_asde_inference(text, dataset, model_id):
67
  output = double_keybert_generator.generate(tokenized_text.input_ids,max_length=512)
68
  result = tokenizer_keybert.decode(output[0], skip_special_tokens=True)
69
  '''
70
- pred_asp = [i.split(':')[0] for i in model_generated.split(',')]
71
- pred_sent = [i.split(':')[1] for i in model_generated.split(',')]
72
 
73
- pred_doubles = pd.DataFrame(list(map(list, zip(pred_asp, pred_sent))),columns=['Aspect','Sentiment'])
74
- true_doubles = pd.DataFrame(list(map(list, zip(ast.literal_eval(true_aspect), ast.literal_eval(true_sentiment)))),columns=['Aspect','Sentiment'])
 
 
 
 
75
 
76
  return pred_doubles, true_doubles, text, model_generated
77
 
 
30
 
31
  '''
32
  def perform_asde_inference(text, dataset, model_id):
 
33
  if not text:
34
  if model_id == "PyABSA_Hospital_English_allenai/tk-instruct-base-def-pos_FinedTuned_Model":
35
  df = pd.read_csv('pyabsa_english.csv')#validation dataset
 
38
  text = selected_df['clean_text']
39
  true_aspect = selected_df['actual_aspects']
40
  true_sentiment = selected_df['actual_sentiments']
 
41
 
42
  bos_instruction = """Definition: The output will be the aspects (both implicit and explicit) and the aspects sentiment polarity. In cases where there are no aspects the output should be noaspectterm:none.
43
  Positive example 1-
 
65
  output = double_keybert_generator.generate(tokenized_text.input_ids,max_length=512)
66
  result = tokenizer_keybert.decode(output[0], skip_special_tokens=True)
67
  '''
68
+ pred_asp = [i.split(':')[0] for i in model_generated.split(',')]
69
+ pred_sent = [i.split(':')[1] for i in model_generated.split(',')]
70
 
71
+ pred_doubles = pd.DataFrame(list(map(list, zip(pred_asp, pred_sent))),columns=['Aspect','Sentiment'])
72
+
73
+ if not text:
74
+ true_doubles = pd.DataFrame(list(map(list, zip(ast.literal_eval(true_aspect), ast.literal_eval(true_sentiment)))),columns=['Aspect','Sentiment'])
75
+ else:
76
+ true_doubles = pd.DataFrame()
77
 
78
  return pred_doubles, true_doubles, text, model_generated
79