Bugfix unicode compatibility#30
Open
wradstok wants to merge 3 commits intoDeepGraphLearning:masterfrom
Open
Conversation
cthoyt
reviewed
Jul 22, 2020
codes/run.py
Outdated
| with open(file_path) as fin: | ||
| for line in fin: | ||
| h, r, t = line.strip().split('\t') | ||
| h, r, t = map(lambda x: x.strip(), unicodedata.normalize('NFKC', line).split('\t')) |
There was a problem hiding this comment.
str.strip could be a shorter replacement for lambda x: x.strip()
Author
There was a problem hiding this comment.
Thanks, didn't realize this was possible.
I mistakenly thought I was dealing with a unicode issue due to the error I received. Upon investigating closer I realized that when the entity/relations are loaded and the entire line is split, trailing spaces are removed because the names are at the end. However, when loading triples this only occurs on the tail entities. Fixed by mapping str.split() on all components when loading triples.
Author
|
I mistakenly thought I was dealing with a unicode issue due to the error I received. Upon investigating closer I realized that when the entity/relations are loaded and the entire line is split, trailing spaces are removed because the names are at the end. However, when loading triples this only occurs on the tail entities. Fixed by mapping str.split() on all components when loading triples. |
This file contains hidden or 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
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.
Hi,
When operating on my data set I was getting the following error:
To fix the issue, I added calls to
unicodedata.normalize()before loading triples to normalize such weird characters (non-breaking spaces). I also fixed two minor grammatical mistakes in error messages.