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

Why tokenize twice? #73

Open
saeub opened this issue Apr 13, 2022 · 0 comments
Open

Why tokenize twice? #73

saeub opened this issue Apr 13, 2022 · 0 comments

Comments

@saeub
Copy link

saeub commented Apr 13, 2022

I'm trying to adapt TransformerSum to a non-English custom dataset and currently very confused about this code in extractive.py:

if tokenized:
src_txt = [
" ".join([token.text for token in sentence if str(token) != "."]) + "."
for sentence in input_sentences
]
else:
nlp = English()
sentencizer = nlp.create_pipe("sentencizer")
nlp.add_pipe(sentencizer)
src_txt = [
" ".join([token.text for token in nlp(sentence) if str(token) != "."])
+ "."
for sentence in input_sentences
]

  • Why separate the words with spaces, when the resulting string is then tokenized using the tokenizer from the transformers library? I assume those tokenizers are not usually trained on pre-tokenized text, and neither are the pretrained models?
  • Why remove the space before "." characters, but not anywhere else?

Thanks for any explanations.

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