varshakolanu commited on
Commit
4a64264
·
verified ·
1 Parent(s): f2adc87

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -32,14 +32,16 @@ def calculate_scores(work_completion, delay_reports, incident_logs):
32
  quality_score += work_completion.lower().count(keyword) * 5
33
  for keyword in quality_keywords_negative:
34
  quality_score -= work_completion.lower().count(keyword) * 10
 
35
 
36
  # --- Timeliness Score ---
37
  timeliness_keywords_positive = ["on time", "punctual", "early", "ahead of schedule"]
38
  timeliness_keywords_negative = ["late", "delayed", "behind schedule"]
39
  for keyword in timeliness_keywords_positive:
40
  timeliness_score += work_completion.lower().count(keyword) * 5 + delay_reports.lower().count(keyword) * 5
41
- for keyword in timeliness_keywords_negative:
42
  timeliness_score -= delay_reports.lower().count(keyword) * 10
 
43
 
44
  # --- Safety Score ---
45
  safety_keywords_positive = ["safe", "safety protocol", "no accidents", "precaution"]
@@ -48,6 +50,7 @@ def calculate_scores(work_completion, delay_reports, incident_logs):
48
  safety_score += work_completion.lower().count(keyword) * 5 + incident_logs.lower().count(keyword) * 5
49
  for keyword in safety_keywords_negative:
50
  safety_score -= incident_logs.lower().count(keyword) * 15
 
51
 
52
  # --- Communication Score ---
53
  communication_keywords_positive = ["clear communication", "responsive", "proactive", "helpful"]
@@ -62,15 +65,11 @@ def calculate_scores(work_completion, delay_reports, incident_logs):
62
  vs = analyzer.polarity_scores(work_completion + " " + delay_reports + " " + incident_logs)
63
  sentiment_score = vs['compound']
64
  communication_score += sentiment_score * 10 # Adjust weight as needed
65
-
66
- # Ensure scores are within 0-100 range
67
- quality_score = max(0, min(quality_score, 100))
68
- timeliness_score = max(0, min(timeliness_score, 100))
69
- safety_score = max(0, min(safety_score, 100))
70
  communication_score = max(0, min(communication_score, 100))
71
 
72
  # Calculate Final Score (as per Salesforce formula)
73
  final_score = (0.4 * quality_score + 0.3 * timeliness_score + 0.15 * safety_score + 0.15 * communication_score)
 
74
 
75
  return {
76
  "Quality Score": round(quality_score, 2),
@@ -92,4 +91,4 @@ if __name__ == "__main__":
92
  title="Vendor Performance Scoring",
93
  description="Enter vendor logs to calculate performance scores."
94
  )
95
- iface.launch()
 
32
  quality_score += work_completion.lower().count(keyword) * 5
33
  for keyword in quality_keywords_negative:
34
  quality_score -= work_completion.lower().count(keyword) * 10
35
+ quality_score = max(0, min(quality_score, 100))
36
 
37
  # --- Timeliness Score ---
38
  timeliness_keywords_positive = ["on time", "punctual", "early", "ahead of schedule"]
39
  timeliness_keywords_negative = ["late", "delayed", "behind schedule"]
40
  for keyword in timeliness_keywords_positive:
41
  timeliness_score += work_completion.lower().count(keyword) * 5 + delay_reports.lower().count(keyword) * 5
42
+ for keyword in timeliness_negative:
43
  timeliness_score -= delay_reports.lower().count(keyword) * 10
44
+ timeliness_score = max(0, min(timeliness_score, 100))
45
 
46
  # --- Safety Score ---
47
  safety_keywords_positive = ["safe", "safety protocol", "no accidents", "precaution"]
 
50
  safety_score += work_completion.lower().count(keyword) * 5 + incident_logs.lower().count(keyword) * 5
51
  for keyword in safety_keywords_negative:
52
  safety_score -= incident_logs.lower().count(keyword) * 15
53
+ safety_score = max(0, min(safety_score, 100))
54
 
55
  # --- Communication Score ---
56
  communication_keywords_positive = ["clear communication", "responsive", "proactive", "helpful"]
 
65
  vs = analyzer.polarity_scores(work_completion + " " + delay_reports + " " + incident_logs)
66
  sentiment_score = vs['compound']
67
  communication_score += sentiment_score * 10 # Adjust weight as needed
 
 
 
 
 
68
  communication_score = max(0, min(communication_score, 100))
69
 
70
  # Calculate Final Score (as per Salesforce formula)
71
  final_score = (0.4 * quality_score + 0.3 * timeliness_score + 0.15 * safety_score + 0.15 * communication_score)
72
+ final_score = max(0, min(final_score, 100))
73
 
74
  return {
75
  "Quality Score": round(quality_score, 2),
 
91
  title="Vendor Performance Scoring",
92
  description="Enter vendor logs to calculate performance scores."
93
  )
94
+ iface.launch()