-
Notifications
You must be signed in to change notification settings - Fork 66
correct() updated to only return positive match, otherwise None is returned. #111
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
base: master
Are you sure you want to change the base?
Conversation
Maybe it's more idiomatic to keep the return types consistent and keep to strings only? |
There is another issue with previous/current logic, including this PR.
Filtering on match.replacements which is empty in case of correct string. Current way of approach is to signal on return:
I'd be keen to hear suggestion to return None for Any thoughts on this? Local mod at my end is to return:
|
…est and str() for lack of suggestion, i.e. gibberish submit
… case of correct word submit for test and str() for lack of suggestion, i.e. gibberish submit
I still don't think it's desirable to have the behavior you've implemented. import language_tool_python
with language_tool_python.LanguageTool('en-US') as tool:
corrected tool.correct('This is a cat.')
print(corrected) Here I'm processing a literal, but in real use it's to process user input or something like this, so we don't know if the text is correct at the beginning, but even if it is, our aim is to get it back correct, so if it already is, why not return it? (And furthermore, it's not backwards compatible.) |
How would you distinguish with current code that submit: "Thisdasdasebadtefword" (not tested, just an example of gibberish), that correct function returns? Please suggest a working solution for use cases as explained above (correct text submit, correctable text submit, complete gibberish submit) - I might be looking at it from a wrong angle maybe because of the use case. Thanks. |
…status of a text (list of match)
I made a pull request on your repo! :) |
@bugsyb Don't forget to review on your fork so that PR can move forward. Thanks ! |
Amazing, thank you very much!
The requested change is implemented, without breaking change. |
@mdevolde Thanks, as always! And ok, if you don't mind adding documentation and bumping the version I can get a new version out by tomorrow. |
@jxmorris12 This isn't my pull request and I'm not a maintainer, so I can't add a commit to this branch, but if you merge this PR, I can create a new one with the version bump and the doc ;)) |
By the way, it might be nice to rebase (squash in first commit of the branch and keep only the description of my commit), the PR history is a bit chaotic. |
Initial code returned original string, whilst from logic perspective, at least for me, if there's no match/correction, it should return None.
p.s. thanks for prepping this interface to LanguateTool - saved me time. :)