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


Groups > comp.lang.python > #5593 > unrolled thread

Re: best way to extract sentence from txt file

Started byMichiel Overtoom <motoom@xs4all.nl>
First post2011-05-17 20:40 +0200
Last post2011-05-17 20:40 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: best way to extract sentence from txt file Michiel Overtoom <motoom@xs4all.nl> - 2011-05-17 20:40 +0200

#5593 — Re: best way to extract sentence from txt file

FromMichiel Overtoom <motoom@xs4all.nl>
Date2011-05-17 20:40 +0200
SubjectRe: best way to extract sentence from txt file
Message-ID<mailman.1693.1305658450.9059.python-list@python.org>
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      

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web