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


Groups > comp.lang.python > #5593

Re: best way to extract sentence from txt file

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <motoom@xs4all.nl>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.075
X-Spam-Evidence '*H*': 0.85; '*S*': 0.00; 'parsing': 0.09; 'somewhere': 0.11; 'wrote:': 0.14; '.txt': 0.16; 'from:addr:xs4all.nl': 0.16; 'means:': 0.16; 'message- id:@xs4all.nl': 0.16; 'received:194.109': 0.16; 'received:194.109.24': 0.16; 'received:xs4all.nl': 0.16; 'simple:': 0.16; 'subject:file': 0.16; 'this?': 0.18; 'interpret': 0.19; 'cc:2**0': 0.20; 'maybe': 0.21; '(or': 0.22; 'header:In- Reply-To:1': 0.22; 'file,': 0.22; '(and': 0.22; 'extract': 0.25; 'list': 0.30; '17,': 0.31; 'random': 0.31; 'to:addr:python-list': 0.32; 'lines': 0.34; 'received:192': 0.34; 'file': 0.35; 'question': 0.35; 'quotes': 0.35; 'quite': 0.36; 'charset:us- ascii': 0.36; 'received:192.168': 0.37; 'some': 0.37; 'sequence': 0.38; 'role': 0.39; 'to:addr:python.org': 0.39; 'header:Mime- Version:1': 0.39; 'how': 0.39; 'might': 0.40; 'best': 0.60; 'header:Message-Id:1': 0.62; 'greetings,': 0.64; 'play': 0.64; 'collection': 0.71; 'yourself,': 0.72; 'fight': 0.77; 'mark?': 0.84; 'received:192.168.6': 0.84; 'sentences,': 0.84; '"learn': 0.91; 'involved.': 0.91; 'subject:best': 0.93
Subject Re: best way to extract sentence from txt file
Mime-Version 1.0 (Apple Message framework v1084)
Content-Type text/plain; charset=us-ascii
From Michiel Overtoom <motoom@xs4all.nl>
In-Reply-To <BANLkTikTFwqHACw9fgwOS01ugpGuNFo_8A@mail.gmail.com>
Date Tue, 17 May 2011 20:40:40 +0200
Content-Transfer-Encoding quoted-printable
References <BANLkTing_u9wp7YAhtapNZJg+2wa-w4NbA@mail.gmail.com> <BANLkTikTFwqHACw9fgwOS01ugpGuNFo_8A@mail.gmail.com>
To python-list@python.org
X-Mailer Apple Mail (2.1084)
X-Virus-Scanned by XS4ALL Virus Scanner
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1693.1305658450.9059.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 82.94.164.166
X-Trace 1305658450 news.xs4all.nl 49044 [::ffff:82.94.164.166]:60991
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:5593

Show key headers only | View raw


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


Thread

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

csiph-web