Skip to content
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

Remove the <UNK> token at the end of each sentence #22

Open
jackyuanjie1990 opened this issue Jan 10, 2021 · 0 comments
Open

Remove the <UNK> token at the end of each sentence #22

jackyuanjie1990 opened this issue Jan 10, 2021 · 0 comments

Comments

@jackyuanjie1990
Copy link

Hello,

Thank you for your implementation. However, I found one issue that every sentence ends up with the token (like below).
****source == a guy on a bike next to a
****target == a bicyclist passing a red commuter bus at a stop on a city
****predict == a man riding a bike on a city

I dig into the codes and found that the error happens at the function tokenize_and_map in data_handler.py
line.split(' ') can't remove the '\n', so that the last token of all the sentences contains '\n'
For example:
['a', 'very', 'clean', 'and', 'well', 'decorated', 'empty', 'bathroom\n']

To fix this bug, we just need to change line.split(' ') to line.split().
def tokenize_and_map(self,line):
return [self.vocab.get(token, self.UNK_TOKEN) for token in line.split()]

Thanks,

Jack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant