Connexions project search query parsing library.
Project description
The Connections project query grammar parsing library.
Install
Use setup.py to install cnx-query-grammar:
$ python setup.py install
This creates a script called query_parser.
Usage
>>> from cnxquerygrammar.query_parser import grammar, DictFormater >>> node_tree = grammar.parse('Some text') >>> DictFormater().visit(node_tree) [('text', 'Some'), ('text', 'text')] >>> node_tree = grammar.parse('"A phrase"') >>> DictFormater().visit(node_tree) [('text', 'A phrase')] >>> node_tree = grammar.parse('author:"John Smith" type:book') >>> DictFormater().visit(node_tree) [('author', 'John Smith'), ('type', 'book')] >>> node_tree = grammar.parse('author:"John Smith" type:book title:" A Title With Spaces"') >>> DictFormater().visit(node_tree) [('author', 'John Smith'), ('type', 'book'), ('title', 'A Title With Spaces')]
Test
To run the tests:
$ python -m unittest discover
License
This software is subject to the provisions of the GNU Affero General Public License Version 3.0 (AGPL). See license.txt for details. Copyright (c) 2013 Rice University
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
cnx-query-grammar-0.2.2.zip
(7.7 kB
view hashes)
Built Distributions
Close
Hashes for cnx_query_grammar-0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37af62033099205a994459b903a7d96a9f28e8a18f6a3515e61bcf6272790b62 |
|
MD5 | 93e844d47d07418aae77615a0d4f8ae6 |
|
BLAKE2b-256 | a97295611868010df6ea020cd4c7fa498171fdfc8d490ae769b31da99887a6b7 |
Close
Hashes for cnx_query_grammar-0.2.2-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 735db8a2ec65cbe01470c760a5cfbfb12d6f6093af9135ea1021d34fe003ebf5 |
|
MD5 | 08d3ac199f8b196ba13b302e42a8bb6b |
|
BLAKE2b-256 | 1f876b61380fdff10cb088f920e84106b6e9b74b6bfec78a501c46fd06ae6508 |