| 14 | |
| 15 | |
| 16 | def get_final_marks(scores): |
| 17 | pattern = re.compile(r"\d*/\d*") |
| 18 | subj_scores = scores.split("\n") |
| 19 | subj_scores_dict = {} |
| 20 | for subj_score in subj_scores: |
| 21 | try: |
| 22 | if "grammar" in subj_score.lower(): |
| 23 | label = pattern.findall(subj_score) |
| 24 | subj_scores_dict["grammar"] = float(label[0].split("/")[0]) |
| 25 | elif "creativity" in subj_score.lower(): |
| 26 | label = pattern.findall(subj_score) |
| 27 | subj_scores_dict["creativity"] = float(label[0].split("/")[0]) |
| 28 | elif "consistency" in subj_score.lower(): |
| 29 | label = pattern.findall(subj_score) |
| 30 | subj_scores_dict["consistency"] = float(label[0].split("/")[0]) |
| 31 | elif "plot" in subj_score.lower(): |
| 32 | label = pattern.findall(subj_score) |
| 33 | subj_scores_dict["plot"] = float(label[0].split("/")[0]) |
| 34 | except Exception as e: |
| 35 | continue |
| 36 | return subj_scores_dict |
| 37 | |
| 38 | |
| 39 | def get_message_1(story_prompt, generation): |