Алгоритм склеивания строк после OCR

После распознавания текста в оцифрованном тексте в каждой строке присутствуют лишние переводы строк.

Например, из такой страницы

будет получен следующий текст

LOST ISLAND

except one or two dark forms of steamers labor-
ing along like gray ghosts of the ocean.

‘It ’s a rare night for trouble,’’ Captain Grum-
mitt said, ‘‘but I think this is where we get under
the lee of the land for a spell.’’

Still he kept his hand off the engine-room tele-
graph. Once or twice during the last quarter of
an hour he had been peering through his night
glasses away to the southeast. ,

‘“‘Blow me if I didn’t see a light down that
way,’’ he muttered. ‘‘Mebbe I’m beginning to
fancy things in my old age. If only this rain
would ease up for a minute— Gosh! There it is
again. Now what in thunder is up?’’ he said,
suddenly moving the lever over to the signal
‘‘FWull speed ahead.’’

The Mary Ellen plunged forward, rolling over
at a terrific angle as the heavy seas struck her
port beam. .

’ “What do you make of it, Cap’n?’’ Dave asked.

“‘Dunno.’’ Captain Grummitt was scratching

180

Чтобы получить текст без лишних переводов строк нужно заменить все переводы строк на пробелы за исключением случая когда два перевода строки идут подряд, в этом случае замену делать не нужно.

Ссылки на эту заметку

Эта заметка на GitHub

Обсудить на форуме

Последниее изменение: