-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix grokker rules that have fields with common prefixes #571
Fix grokker rules that have fields with common prefixes #571
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for your contribution.
please consider to have a look at one minor change
logprep/processor/grokker/rule.py
Outdated
split_field = dotted_field.split(".") | ||
if len(split_field) > 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
split_field = dotted_field.split(".") | |
if len(split_field) > 1: | |
if "." in dotted_field: |
- if a dot is in dotted field, the length will be greater than 1
- much cheaper operation than two method calls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well we still need the dotted_field.split(".")
in the next line. So what I could offer is something like following. But it doesn't really reduce the method calls except the change of len(...) > 1
to "." in dotted_field
.
if "." in dotted_field:
replacement = "".join(f"[{element}]" for element in dotted_field.split("."))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still better 👍
…ady-existing-field
closes #564