Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #5593
| Subject | Re: best way to extract sentence from txt file |
|---|---|
| From | Michiel Overtoom <motoom@xs4all.nl> |
| Date | 2011-05-17 20:40 +0200 |
| References | <BANLkTing_u9wp7YAhtapNZJg+2wa-w4NbA@mail.gmail.com> <BANLkTikTFwqHACw9fgwOS01ugpGuNFo_8A@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1693.1305658450.9059.python-list@python.org> (permalink) |
On May 17, 2011, at 20:22, Robert Pazur wrote:
> my question is maybe quite simple:
> What is the best (and shortest) way to extract sentence from .txt file?
Well, open("filename.txt").readlines() gives you a list of all the lines in a txt file, which might not be sentences, depending on the text file is structured. If you really want to interpret the text file as a collection of sentences, some parsing might be involved. What is a sentence? A sequence of words ending with a dot? With a question mark? How do quotes play a role in this?
Did you have a specific sentence (or line) in thought? The first line? The last line? A random line somewhere in between?
Until then we have to guess, and my E.S.P. is notoriously bad.
Greetings,
--
"Learn to value yourself, which means: fight for your happiness." - Ayn Rand
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: best way to extract sentence from txt file Michiel Overtoom <motoom@xs4all.nl> - 2011-05-17 20:40 +0200
csiph-web