Skip to content

Commit

Permalink
❇️ Add hooks to MelusineRegex
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoPerrier committed Oct 4, 2024
1 parent bdacb74 commit 223ff6b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions melusine/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,9 @@ def __call__(self, text: str) -> dict[str, Any]:
Returns:
_: Regex match results.
"""
# Apply pre match hook
text = self.pre_match_hook(text)

match_dict = {
self.MATCH_RESULT: False,
self.NEUTRAL_MATCH_FIELD: {},
Expand All @@ -513,6 +516,9 @@ def __call__(self, text: str) -> dict[str, Any]:

match_dict[self.MATCH_RESULT] = positive_match and not negative_match

# Apply post match hook
match_dict = self.post_match_hook(match_dict)

return match_dict

def describe(self, text: str, position: bool = False) -> None:
Expand Down

0 comments on commit 223ff6b

Please sign in to comment.