Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/hotfixes' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
fit-alessandro-berti committed Aug 31, 2023
2 parents b322646 + fa44ac6 commit 81675e6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
22 changes: 17 additions & 5 deletions pm4py/algo/querying/llm/abstractions/ocel_fea_descr.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
from pm4py.util import exec_utils, constants, xes_constants
from enum import Enum
import numpy as np
import pandas as pd


class Parameters(Enum):
INCLUDE_HEADER = "include_header"
MAX_LEN = "max_len"
DEBUG = "debug"
ENABLE_OBJECT_LIFECYCLE_PATHS = "enable_object_lifecycle_paths"


def __transform_to_string(stru: str) -> str:
Expand Down Expand Up @@ -67,17 +70,13 @@ def __transform_to_string(stru: str) -> str:
return stru


def apply(ocel: OCEL, obj_type: str, parameters: Optional[Dict[Any, Any]] = None) -> str:
def textual_abstraction_from_fea_df(fea_df: pd.DataFrame, parameters: Optional[Dict[Any, Any]] = None) -> str:
if parameters is None:
parameters = {}

include_header = exec_utils.get_param_value(Parameters.INCLUDE_HEADER, parameters, True)
max_len = exec_utils.get_param_value(Parameters.MAX_LEN, parameters, constants.OPENAI_MAX_LEN)

import pm4py

fea_df = pm4py.extract_ocel_features(ocel, obj_type, include_obj_id=False)

cols = []

for c in fea_df.columns:
Expand Down Expand Up @@ -115,3 +114,16 @@ def apply(ocel: OCEL, obj_type: str, parameters: Optional[Dict[Any, Any]] = None

return ret


def apply(ocel: OCEL, obj_type: str, parameters: Optional[Dict[Any, Any]] = None) -> str:
if parameters is None:
parameters = {}

debug = exec_utils.get_param_value(Parameters.DEBUG, parameters, True)
enable_object_lifecycle_paths = exec_utils.get_param_value(Parameters.ENABLE_OBJECT_LIFECYCLE_PATHS, parameters, False)

import pm4py

fea_df = pm4py.extract_ocel_features(ocel, obj_type, include_obj_id=False, debug=debug, enable_object_lifecycle_paths=enable_object_lifecycle_paths)

return textual_abstraction_from_fea_df(fea_df, parameters=parameters)
6 changes: 5 additions & 1 deletion pm4py/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,16 @@ def abstract_ocel_ocdfg(ocel: OCEL, include_header: bool = True, include_timesta
return ocel_ocdfg_descr.apply(ocel, parameters=parameters)


def abstract_ocel_features(ocel: OCEL, obj_type: str, include_header: bool = True, max_len: int = constants.OPENAI_MAX_LEN) -> str:
def abstract_ocel_features(ocel: OCEL, obj_type: str, include_header: bool = True, max_len: int = constants.OPENAI_MAX_LEN, debug: bool = False, enable_object_lifecycle_paths: bool = True) -> str:
"""
Obtains the abstraction of an object-centric event log, representing in text the features and their values.
:param ocel: object-centric event log
:param obj_type: the object type that should be considered in the feature extraction
:param include_header: (boolean) includes the header in the abstraction
:param max_len: maximum length of the abstraction
:param debug: enables debugging mode (telling at which point of the feature extraction you are)
:param enable_object_lifecycle_paths: enables the "lifecycle paths" feature
:rtype: ``str``
.. code-block:: python3
Expand All @@ -189,6 +191,8 @@ def abstract_ocel_features(ocel: OCEL, obj_type: str, include_header: bool = Tru
parameters = {}
parameters["include_header"] = include_header
parameters["max_len"] = max_len
parameters["debug"] = debug
parameters["enable_object_lifecycle_paths"] = enable_object_lifecycle_paths

from pm4py.algo.querying.llm.abstractions import ocel_fea_descr
return ocel_fea_descr.apply(ocel, obj_type, parameters=parameters)
Expand Down
2 changes: 1 addition & 1 deletion pm4py/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
along with PM4Py. If not, see <https://www.gnu.org/licenses/>.
'''
__name__ = 'pm4py'
VERSION = '2.7.5.2'
VERSION = '2.7.5.3'
__version__ = VERSION
__doc__ = 'Process mining for Python'
__author__ = 'Fraunhofer Institute for Applied Technology'
Expand Down

0 comments on commit 81675e6

Please sign in to comment.