newspaper icon indicating copy to clipboard operation
newspaper copied to clipboard

Fix concatenating sentence parts separated with newlines

Open dhgelling opened this issue 3 years ago • 0 comments

The text content of newspapers seems to be returned as paragraphs separated by two newlines. When doing nlp on this, the tokenizer sometimes thinks a sentence spans across two paragraphs, returning a sentence looking like 'first sentence\n\nsecond sentence', which means this part of the code would concatenate the words sentence and second, returning 'first sentencesecond sentence'. This change is meant to fix that, by replacing any run of multiple spaces or newlines by one space.

Another solution would be to first split on double newlines and processing the content of that separately before concatenating again, but this seemed like it would change the least

dhgelling avatar Feb 12 '21 13:02 dhgelling