krzysiekfonal / grammaregex Goto Github PK
View Code? Open in Web Editor NEWRegex like pattern tree matching but on sentence's tree instead of Strings
License: MIT License
Regex like pattern tree matching but on sentence's tree instead of Strings
License: MIT License
A detailed description of what forms a valid pattern will help the user.
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=" ")
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.