Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/tutorials/00_GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ Inspecting the debug data gives a lot of info:
- `text`: Effective text considered for detection.
- `EmergencyRegex`: melusine used an `EmergencyRegex` object to run detection.
- `match_result`: The `EmergencyRegex` did not match the text.
- `positive_match_data`: The `EmergencyRegex` matched **positively** the text pattern "Urgent" (Required condition).
- `negative_match_data`: The `EmergencyRegex` matched **negatively** the text pattern "Mr. Annoying" (Forbidden condition).
- `positive`: The `EmergencyRegex` matched **positively** the text pattern "Urgent" (Required condition).
- `negative`: The `EmergencyRegex` matched **negatively** the text pattern "Mr. Annoying" (Forbidden condition).
- `BLACKLIST`: Detection groups can be defined to easily link a matching pattern to the corresponding regex. DEFAULT is used if no detection group is specified.

```Python
Expand All @@ -118,12 +118,12 @@ Inspecting the debug data gives a lot of info:
'text': 'Latest news\nUrgent update about Mr. Annoying'},
'EmergencyRegex': {
'match_result': False,
'negative_match_data': {
'negative': {
'BLACKLIST': [
{'match_text': 'Mr. Annoying', 'start': 32, 'stop': 44}
]},
'neutral_match_data': {},
'positive_match_data': {
'neutral': {},
'positive': {
'DEFAULT': [
{'match_text': 'Urgent', 'start': 12, 'stop': 18}
]
Expand Down
18 changes: 9 additions & 9 deletions docs/tutorials/08_MelusineRegex.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ to_delete_detection = to_delete_regex(
"You shall not pass through the magical portal of the lake from Monday to Thursday as it is currently under repair."
)

print(to_delete_detection[MelusineRegex.MATCH_RESULT]) # (1)!
print(to_delete_detection[MelusineRegex.POSITIVE_MATCH_FIELD]) # (2)!
print(to_delete_detection.match_result) # (1)!
print(to_delete_detection.positive) # (2)!
```

1. Prints `True`
Expand Down Expand Up @@ -96,7 +96,7 @@ to_delete_regex = AnnoyingEmailsRegex()
email = "You shall not pass through the magical portal of the lake from Monday to Thursday as it is currently under repair."
to_delete_detection = to_delete_regex(email)

print(to_delete_detection[MelusineRegex.MATCH_RESULT]) # (1)!
print(to_delete_detection.match_result) # (1)!
```

1. Prints `False`
Expand All @@ -116,9 +116,9 @@ class PreMatchHookAnnoyingEmailsRegex(AnnoyingEmailsRegex):
return text

preprocessed_to_delete_regex = PreMatchHookAnnoyingEmailsRegex()
spell_result = preprocessed_to_delete_regex.get_match_result(
spell_result = preprocessed_to_delete_regex(
"Andthen,, I told Morgana 'You sholl not pass!' as she wanted topass... Im stil wonddering why she did not find it fundny..."
)
).match_result
```

## Using the regex result
Expand All @@ -129,9 +129,9 @@ The complete `to_delete_detection` object looks like this:
``` json
{
"match_result":False,
"neutral_match_data":{
"neutral":{
},
"negative_match_data":{
"negative":{
"PORTAL_MENTIONNED":[
{
"start":31,
Expand All @@ -140,7 +140,7 @@ The complete `to_delete_detection` object looks like this:
}
]
},
"positive_match_data":{
"positive":{
"GANDALF_BEING_GANDALF":[
{
"start":0,
Expand All @@ -155,7 +155,7 @@ The complete `to_delete_detection` object looks like this:
For a more straightforward approach, if you only need the regex result, you can use the following syntax:

``` python
spell_analysis_result: bool = to_delete_regex.get_match_result(email) # (1)!
spell_analysis_result: bool = to_delete_regex(email).match_result # (1)!
```
1. Returns `True`
Some of the older fairies might need a more detailed explanation on what triggered the deletion of an email.
Expand Down
12 changes: 10 additions & 2 deletions melusine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@
import logging

from melusine._config import config
from melusine.base import MelusineDetector, MelusineRegex, MelusineRegexFullMatch, MelusineTransformer
from melusine.pipeline import MelusinePipeline

__all__ = ["config", "MelusinePipeline"]
__all__ = [
"config",
"MelusineDetector",
"MelusineRegex",
"MelusineRegexFullMatch",
"MelusineTransformer",
"MelusinePipeline",
]

VERSION = (3, 3, 4)
VERSION = (3, 4, 0)
__version__ = ".".join(map(str, VERSION))

# ------------------------------- #
Expand Down
Loading
Loading