-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
352 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
188 changes: 90 additions & 98 deletions
188
tracex/extraction/content/outputs/single_trace_event_type.xes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
from .module_patient_journey_generator import PatientJourneyGenerator | ||
from .module_activity_labeler import ActivityLabeler | ||
from .module_time_extractor import TimeExtractor | ||
from .module_location_extractor import LocationExtractor |
48 changes: 48 additions & 0 deletions
48
tracex/extraction/logic/modules/module_activity_labeler.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from ..module import Module | ||
from .. import utils as u | ||
from .. import prompts as p | ||
|
||
from pandas import DataFrame | ||
|
||
|
||
class ActivityLabeler(Module): | ||
# Remove this, only for test purposes | ||
def __init__(self, name, description): | ||
super().__init__(name, description) | ||
print("ActivityLabeler module is ready") | ||
|
||
def execute(self, _input, patient_journey=None): | ||
super().execute(_input, patient_journey) | ||
self.result = self.extract_activities() | ||
|
||
# TODO: Convert to dataframes | ||
def extract_activities(self): | ||
"""Converts the input text to activity_labels.""" | ||
messages = [ | ||
{"role": "system", "content": p.TXT_TO_BULLETPOINTS_CONTEXT}, | ||
{ | ||
"role": "user", | ||
"content": p.TXT_TO_BULLETPOINTS_PROMPT + self.patient_journey, | ||
}, | ||
{"role": "assistant", "content": p.TXT_TO_BULLETPOINTS_ANSWER}, | ||
] | ||
activity_labels = u.query_gpt(messages) | ||
activity_labels = self._remove_commas(activity_labels) | ||
activity_labels = self._add_ending_commas(activity_labels) | ||
with open((u.output_path / "intermediates/1_bulletpoints.txt"), "w") as f: | ||
f.write(activity_labels) | ||
return activity_labels | ||
|
||
@staticmethod | ||
def _remove_commas(activity_labels): | ||
"""Removes commas from within the activity_labels.""" | ||
activity_labels = activity_labels.replace(", ", "/") | ||
activity_labels = activity_labels.replace(",", "/") | ||
return activity_labels | ||
|
||
@staticmethod | ||
def _add_ending_commas(activity_labels): | ||
"""Adds commas at the end of each line.""" | ||
activity_labels = activity_labels.replace("\n", ",\n") | ||
activity_labels = activity_labels + "," | ||
return activity_labels |
Oops, something went wrong.