Giter Club home page Giter Club logo

Comments (5)

tom-de-smedt avatar tom-de-smedt commented on July 17, 2024

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.

tansaku avatar tansaku commented on July 17, 2024

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.

tom-de-smedt avatar tom-de-smedt commented on July 17, 2024

You can use the github revision, the new 2.4 will be on the CLiPS website in a couple of days.

from pattern.

tansaku avatar tansaku commented on July 17, 2024

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.

tansaku avatar tansaku commented on July 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.