Comments (5)
The latest revision has support for match groups, using the { } control characters:
>>> from pattern.search import search
>>> from pattern.en import Sentence, parse
>>> s = Sentence(parse("There is a red ball", lemmata=True))
>>> m = search("There be DT {JJ? NN}", s)
>>> print m[0].group(0).string
>>> print m[0].group(1).string
"There is a red ball"
"red ball"
Match.group(0) is the full pattern, Match.group(1) is the first subgroup. Note that ? is now used for optional constraints. The reason for using { } for groups is that ( ) will also still work for optional constraints, but it is now deprecated. In future versions, { } will then gradually switch to ( ), as in regex syntax.
An example is included in the latest revision. Unit tests are also included but let me know if you run in to any bugs.
from pattern.
That sounds great. How should I be grabbing the latest version? It's still 2.3. here: http://www.clips.ua.ac.be/pages/pattern should I be checking out of github
from pattern.
You can use the github revision, the new 2.4 will be on the CLiPS website in a couple of days.
from pattern.
Thanks - I might hold off for the 2.4 so that I can peg against a particular major revision in my release notes
from pattern.
I couldn't wait - I pulled out from git, but didn't seem to work for me :-(
Enthought Python Distribution (EPD) free version -- www.enthought.com
Version: 7.3-1 (32-bit)
(type 'upgrade' or see www.enthought.com/epd/upgrade to get the full EPD)
Python 2.7.3 |EPD_free 7.3-1 (32-bit)| (default, Apr 12 2012, 11:28:34)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "credits", "demo" or "enthought" for more information.
from pattern.search import search
from pattern.en import Sentence, parse
s = Sentence(parse("There is a red ball", lemmata=True))
m = search("There be DT {JJ? NN}", s)
print m[0].group(0).string
Traceback (most recent call last):
File "", line 1, in
IndexError: list index out of range
print m[0].group(1).string
Traceback (most recent call last):
File "", line 1, in
IndexError: list index out of range
Here's how I pulled from git:
git clone git://github.com/clips/pattern.git
I then updated my python path ... any ideas?
from pattern.
Related Issues (20)
- ERROR: test_lexicon (__main__.TestLexicon)
- ERROR al instalar el módulo HOT 1
- Problema StopIteration HOT 5
- Verb conjugation (Python 3.7-3.8) HOT 1
- Problematic lemmatization of 'thieves' and 'glass'
- Unexpected tokenization
- Why do I need mysql for a python package? HOT 1
- Conjugation of verbs with the ß in pattern.text.de appears to be broken
- Documentation of "pattern es" mismatch library code
- Mood if Statements Order
- Some invalid english verbs, missing forms
- Is Email pattern still working?
- Unexpected StopIteration exception being raised. HOT 1
- License Type issue
- Running Example Code Results in Exception HOT 1
- 'Thread' object has no attribute 'isAlive'
- pip install throws error - bin/sh: 1: mysql_config: not found HOT 3
- How can i use Neo4j with Pattern?
- Is this project active? HOT 3
- Issue with Pluralization in German Language for Umlauts
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pattern.