-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Checker API to accept the full result object. #4
Conversation
This is not a ready-to-merge PR. There are still more tests and changes to the documentation needed. If in general the idea is ok – I can to do those as well. |
Thanks for your PR. Do you have a concrete usecase example where this change can be helpful? |
Yes. In a side-project I'm using checker to discard results that were using only one source of text (as opposed to using several different sources). The source of text is set in an attribute of data sentences, so I need access to that info in the checker. |
Also it seems like at some point the proposed API was the intended one, judging by this test (in the master branch): https://github.com/scambier/markov-strings/blob/master/test/test.js#L117 |
Indeed, I totally forgot about that test. I'm ok with this PR, but it needs to be correctly implemented. IMO, the "cleanest" solution would be to keep the |
Ok, I agree that it's better to deprecate |
Let's go with |
4c1c180
to
53f7d80
Compare
I've changed the implementation and the docs, added tests. Let me know if I missed something, otherwise it's ready to be merged. |
Sometimes it's valuable for the checker to have other information about the result under question, such as original sentences or their attributes. This commit deprecates checker API and adds a new filter API. The difference between the two is that checker takes string as input, while filter takes the whole result object.
53f7d80
to
a189e93
Compare
Merged and published :) |
Sometimes it's valuable for the checker to have other information about
the result under question, such as original sentences or their
attributes.
This commit changes the API of the checker to support that usecase. It'a
a breaking change, that can be avoided by extending the existent API
rather than replacing it.
Alternative proposal would be to add a different option to Markov
constructor options e.g.
resultChecker: (result) => Boolean
.