Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #70606

Re: how to split this kind of text into sections

From Terry Reedy <tjreedy@udel.edu>
Subject Re: how to split this kind of text into sections
Date 2014-04-25 13:52 -0400
References <CACW-qXU3nQZY1VV+aGucqKeFjxz+OdVvmrSmSZRitj-+OvKFkA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.9502.1398448424.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 4/25/2014 9:07 AM, oyster wrote:
> I have a long text, which should be splitted into some sections, where
> all sections have a pattern like following with different KEY.

Computers are worse at reading your mind than humans. If you can write 
rules that another person could follow, THEN we could help you translate 
the rules to Python.

If you have 1 moderate length file or a few short files, I would edit 
them by hand to remove ignore lines and put a blank line between 
sections. A program to do the rest would then be easy.

> the above text should be splitted as a LIST with 3 items, and I also
> need to know the KEY for LIST is ['I am section', 'let's continue', 'I
> am using']:

This suggests that the rule for keys is 'first 3 words of a line, with 
contractions counted as 2 words'. Correct?

Another possible rule is 'a member of the following list: ...', as you 
gave above but presumably expanded.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: how to split this kind of text into sections Terry Reedy <tjreedy@udel.edu> - 2014-04-25 13:52 -0400

csiph-web