-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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 treebank detokenizer #2575
Merged
Merged
Fix treebank detokenizer #2575
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Currently, the detokenizer doesn’t hanlde quotes quite well. Signed-off-by: Or Sharir <[email protected]>
Python’s double-quote raw strings cannot represent a single double-quote. Use single-quote raw strings instead (though a regular string would suffice too). Signed-off-by: Or Sharir <[email protected]>
* `` and '' should always be replaced with double quotes, regardless of spaces. * Starting quotes should remove padding just on the right. * Ending quotes should remove padding just on the left. * The way tokenizer works, you first convert starting/ending quotes to their respective symbol and then add padding as needed. The detokenizer should work the same way and replace the spceial token back to double quotes only at the last regex. Signed-off-by: Or Sharir <[email protected]>
The tokenizer checks for non-digits because we don’t want to add padding inside numbers and time formats (e.g., “1,000” or “9:30”). However, the detokenizer’s input will never have a colon/comma with spaces around if it was part of a number/time string. Thus, at this last point we just need to remove left padding in all cases, instead of checking for non-digit or whitespace (to handle cases where there’s a comma followed by double-quotes). Signed-off-by: Or Sharir <[email protected]>
Signed-off-by: Or Sharir <[email protected]>
Signed-off-by: Or Sharir <[email protected]>
Signed-off-by: Or Sharir <[email protected]>
We shouldn’t catch whitespace in most cases where we don’t remove it because it prevents matching at end/start of a line, e.g., when a line ends on a right parentheses we should still remove the left padding. Signed-off-by: Or Sharir <[email protected]>
(I keep them in code as a reminder for the reversed order in the tokenizer) Signed-off-by: Or Sharir <[email protected]>
Signed-off-by: Or Sharir <[email protected]>
Signed-off-by: Or Sharir <[email protected]>
Thanks @orsharir. Sorry for the delay. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix a few issues with how the Treebank's word detokenizer mishandled quotes, punctuation marks, and parentheses, including #2295 and #2220.