Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99797
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Peter Otten <__peter__@web.de> |
| Newsgroups | comp.lang.python |
| Subject | Re: Exclude text within quotation marks and words beginning with a capital letter |
| Date | Tue, 01 Dec 2015 13:43:56 +0100 |
| Organization | None |
| Lines | 26 |
| Message-ID | <mailman.72.1448973862.14615.python-list@python.org> (permalink) |
| References | <a1da3bd6-5643-46b4-bcc5-69659367d491@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Trace | news.uni-berlin.de vMJ5AvMYvw+siVjTXFXw5gfnaWDbfud5otWu6ydgKZ9g== |
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'elif': 0.04; 'subject:text': 0.04; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; '2.7': 0.13; 'def': 0.13; '"hello': 0.16; '\'"\':': 0.16; 'pairs:': 0.16; 'quoted': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'wrote:': 0.16; 'thanks.': 0.18; '>>>': 0.20; 'pos': 0.22; 'kevin': 0.23; 'import': 0.24; 'words': 0.24; 'written': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'compatible': 0.27; 'coding': 0.27; 'yield': 0.27; 'exclude': 0.29; 'identifies': 0.29; '(including': 0.30; 'skip:[ 10': 0.31; 'advice': 0.35; 'text': 0.35; 'false': 0.35; 'text.': 0.35; 'beginning': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'say': 0.37; 'received:org': 0.37; 'to:addr:python.org': 0.40; 'subject:with': 0.40; 'received:de': 0.40; 'within': 0.64; 'upper': 0.76; 'subject:letter': 0.84; 'quotation': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | p57bd9ec4.dip0.t-ipconnect.de |
| User-Agent | KNode/4.13.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:99797 |
Show key headers only | View raw
Kevin Glover wrote:
> I am working on a program that is written in Python 2.7 to be compatible
> with the POS tagger that I import from Pattern. The tagger identifies all
> the nouns in a text. I need to exclude from the tagger any text that is
> within quotation marks, and also any word that begins with an upper case
> letter (including words at the beginning of sentences).
>
> Any advice on coding that would be gratefully received. Thanks.
How about removing them afterwards?
>>> def skip_quoted(pairs):
... quoted = False
... for a, b in pairs:
... if a == '"':
... quoted = not quoted
... elif not quoted:
... yield a, b
...
>>> from pattern.en import tag
>>> [p for p in skip_quoted(tag('Did you say "Hello world"?')) if not p[0]
[0].isupper()]
[(u'you', u'PRP'), (u'say', u'VB'), (u'?', u'.')]
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Exclude text within quotation marks and words beginning with a capital letter Kevin Glover <kevingloveruk@gmail.com> - 2015-12-01 03:17 -0800 Re: Exclude text within quotation marks and words beginning with a capital letter Peter Otten <__peter__@web.de> - 2015-12-01 13:43 +0100 Re: Exclude text within quotation marks and words beginning with a capital letter Jason Friedman <jsf80238@gmail.com> - 2015-12-04 10:38 -0700
csiph-web