преобразовать строку в список в зависимости от размера фрагмента символов, которые были покрыты, но также близко к ближайшему слову python - PullRequest
0 голосов
/ 29 октября 2019

У меня есть строка, похожая на эту.

Zebra finches usually learn to sing from their fathers. But now, scientists and nature lovers have taught the little birds to memorize a tune without ever learning it and they did so by implanting memories of the songs in the birds brains This strange experiment was designed to discover the brain pathways that encode note duration in the birds. Ultimately the point is to draw parallels with how humans learn to speak Hopefully the research will help scientists target genes and neurons to improve language learning in people with autism and other conditions that affect vocalization

Я хочу преобразовать эту строку в список, где у каждого элемента есть ограничение на число символов, которое очень близко к 198 и близко только к ближайшему слову, иЯ не хочу никаких подстрок.

мой вывод должен быть примерно таким:

["Zebra finches usually learn to sing from their fathers. But now, scientists and nature lovers have taught the little birds to memorize a tune without ever learning it and they did so by", "implanting memories of the songs in the birds brains This strange experiment was designed to discover the brain pathways that encode note duration in the birds. Ultimately the point is to draw", "parallels with how humans learn to speak Hopefully the research will help scientists target genes and neurons to improve language learning in people with autism and other conditions that affect", "vocalization"] ```

>>> for i in res:
...     print len(i)
...
185
192
193
12

Есть ли способ сделать это?

Заранее спасибо.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...