跳转到主要内容

Connexions项目搜索查询解析库。

项目描述

连接项目查询语法解析库。

安装

使用setup.py安装cnx-query-grammar

$ python setup.py install

这会创建一个名为query_parser的脚本。

用法

>>> 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')]

测试

运行测试

$ python -m unittest discover

许可证

本软件受GNU Affero通用公共许可证版本3.0(AGPL)的条款约束。有关详情,请参阅license.txt。版权(c)2013 Rice大学

项目详情


下载文件

下载适用于您的平台文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

cnx-query-grammar-0.2.2.zip (7.7 kB 查看哈希)

上传时间:

cnx-query-grammar-0.2.2.tar.gz (4.1 kB 查看哈希)

上传于 源代码

cnx-query-grammar-0.2.2.tar.bz2 (4.1 kB 查看哈希值)

上传于 源代码

构建版本

cnx_query_grammar-0.2.2-py3-none-any.whl (6.6 kB 查看哈希值)

上传于 Python 3

cnx_query_grammar-0.2.2-py2-none-any.whl (6.6 kB 查看哈希值)

上传于 Python 2

由以下支持