Giter Site home page Giter Site logo

grammaregex's Issues

Retrieve tokens on the path to a matching

It's often interesting to know not only the leaf token as selected by a pattern, but also some of the intermediate steps. Python's re package even provides functionality-- named groups-- to identify particular parts of a matching that may be interesting separately.

An example of how this might look like for grammaregex would be:

example sentence: "Mrs. Robinson graduated from the Wharton School of the University of Pennsylvania in 1980."
pattern: ?PVBD/prep/?PIN/pobj/?P*
matchings: [{"root": "graduated", "prep": "from", "where": "School"}, {"root": "graduated", "prep": "in", "where": "1980"}]

An example implementation of such behavior (with backwards compatibility: if no ?P<> appears in the pattern to match, just return tokens as before) can be found at this branch.

Stars in sets of options are considered a valid pattern

Example:

grammaregex.verify_pattern("[VERB,**]/")
True
grammaregex.verify_pattern("[VERB,
]/*")
True

This happens because the full verify_pattern function is called on each list element, meaning each list element gets matched against a regex for which "*" and "**" are acceptable strings.

Error on print statement : Is this library created using Python 3?

Traceback (most recent call last):
from textpipeliner import PipelineEngine, Context
File "/Library/Python/2.7/site-packages/textpipeliner/init.py", line 3, in
from .pipes import *
File "/Library/Python/2.7/site-packages/textpipeliner/pipes/init.py", line 1, in
from .pipe import Pipe,
File "/Library/Python/2.7/site-packages/textpipeliner/pipes/pipe.py", line 2, in
from grammaregex import find_tokens, match_tree
File "/Library/Python/2.7/site-packages/grammaregex/init.py", line 1, in
from .grammaregex import match_tree, find_tokens, print_tree, verify_pattern, PatternSyntaxException
File "/Library/Python/2.7/site-packages/grammaregex/grammaregex.py", line 70
print("{", end=" ")

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.