Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > de.comp.lang.python > #4673
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | "Sven R. Kunze" <srkunze@mail.de> |
| Newsgroups | de.comp.lang.python |
| Subject | Re: [Python-de] string split |
| Date | Wed, 22 Feb 2017 18:07:41 +0100 |
| Lines | 34 |
| Message-ID | <mailman.4.1487783270.2669.python-de@python.org> (permalink) |
| References | <CABTCcybjz2=TpMUvM7ur_obHfx2BGuoF4tohGuipgfrbonLcBA@mail.gmail.com> <562fb777-6db2-0457-2a4d-0d6d79588129@mail.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Trace | news.uni-berlin.de zUiBl8gCHtjJLzG04oSnIAaI1mdRjaNp9BxnYiTDrDTg== |
| Return-Path | <srkunze@mail.de> |
| X-Original-To | python-de@python.org |
| Delivered-To | python-de@mail.python.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mailde201610; t=1487783262; bh=57lhZXH9p9DkFoDgaoVnFPoBRmMm9oHibrDBRhhcWNE=; h=Subject:To:References:From:Date:In-Reply-To:From; b=MrWI5rtnYiMNBreec+K29nkuA0yR87rBhKlq6CzBtrN+JBJ0QJwl2Vhl1VFc1graB xMWj1BFqsk13rjAAr+ZsAcwYz6vwBCwfNPz3didWtYaSWAcsI3oVFxtZ2rLieT2c2S uoi9V/1BIl23iYjalG7s8TizKoM1srweypq/Ho00= |
| In-Reply-To | <CABTCcybjz2=TpMUvM7ur_obHfx2BGuoF4tohGuipgfrbonLcBA@mail.gmail.com> |
| X-purgate | clean |
| X-purgate | This mail is considered clean (visit http://www.eleven.de for further information) |
| X-purgate-type | clean |
| X-purgate-Ad | Categorized by eleven eXpurgate (R) http://www.eleven.de |
| X-purgate | This mail is considered clean (visit http://www.eleven.de for further information) |
| X-purgate | clean |
| X-purgate-size | 989 |
| X-purgate-ID | 154282::1487783261-00004FF0-0C60DA58/0/0 |
| X-BeenThere | python-de@python.org |
| X-Mailman-Version | 2.1.23 |
| Precedence | list |
| List-Id | Die Deutsche Python Mailingliste <python-de.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-de>, <mailto:python-de-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-de/> |
| List-Post | <mailto:python-de@python.org> |
| List-Help | <mailto:python-de-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-de>, <mailto:python-de-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <562fb777-6db2-0457-2a4d-0d6d79588129@mail.de> |
| X-Mailman-Original-References | <CABTCcybjz2=TpMUvM7ur_obHfx2BGuoF4tohGuipgfrbonLcBA@mail.gmail.com> |
| Xref | csiph.com de.comp.lang.python:4673 |
Show key headers only | View raw
Ich fürchte eine 100%e Lösung gibt's nicht. Aber vielleicht hilft das ja:
last_chars = {word[-1] for word in text.split()}
Damit lässt sich schon mal abschätzen, welche Endungszeichen es gibt.
Wenn du dir dann im Klaren bist, welche du alle akzeptieren möchtest:
Nimm dann dafür re.split https://docs.python.org/2/library/re.html#re.split
re.split('((?\W|\s)+)(?\.|\?|!)', text)
Bin grad auf dem Sprung, aber im Prinzip sollte es so gehen.
vG
Sven
On 22.02.2017 17:49, Frank Grellert wrote:
> Ich habe ein kniffliges Problem zu lösen:
> Ein längerer Text soll in einzelne Sätze aufgespalten werden. Leider
> enden nicht alle Sätze am Zeilenende und darüber hinaus enden auch
> nicht alle mit einem Punkt. Der Text lautet:
>
> text = """Dies ist ein Auszug aus einem langen Text: Welche Zeichen
> befinden sich am Satzende?
> Manchmal ist es ein Ausrufezeichen! Häufig ist es ein Punkt.
> """
> Hat jemand eine Idee?
>
> Danke!
>
> Frank
>
Back to de.comp.lang.python | Previous | Next | Find similar
Re: [Python-de] string split "Sven R. Kunze" <srkunze@mail.de> - 2017-02-22 18:07 +0100
csiph-web