Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
feat(decorator): added new methods to extract vocab or non-vocab decorators from model #888
feat(decorator): added new methods to extract vocab or non-vocab decorators from model #888
Changes from 12 commits
7dbda25
2ab3dbd
1ba299a
03f5f30
882af9a
b0667c2
aaa8c93
4594013
8bd6097
1234ca7
718f195
8a1ab63
ed9b763
7e2866c
8671f27
e384026
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
I think if you recreate the
RegEx
object at each call, it would be slower than just usingstartsWith
. Is there a reason you want to put thevocabPattern
in the function body?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.
You are correct, we can use startWith instead of regex. Earlier it was having /^Term_/i as vocabPattern to check it in case insensitive manner.
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.
Updated
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.
You could have also move the regex to constructor and use the compiled regex. There are trade offs using either
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.
Is there a yaml library that we can use instead of directly parsing the string? Maybe not for this PR but that would help a lot.
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.
We can directly create the obj in expected yaml format and use the yaml library to stringify the object or parse the string to yaml obj.
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.
shouldn't this return all the decorators?
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.
if removeDecoratorsFromModel is true then it should return undefined to remove all the decorators from the model
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.
Is there a disconnect between the
Action
and the logic then?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.
The
action
parameter specifies what to extract from the model (vocab decorators, non-vocab decorators, or both). Meanwhile,removeDecoratorsFromModel
flag determines if the decorators should be deleted or not from the model itself after extraction.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.
This function then can be called
filterOutDecorators
. And then, I think you can just return early ifthis.removeDecoratorsFromModel
is false with the decorators and avoid wrapping the whole function definition in an if statement.Otherwise it looks like the code is looking like doing the opposite of what the function is aiming to do.
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.
Updated
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.
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.
Updated similar changes