连接项目搜索查询帕辛图书馆。
cnx-query-grammar的Python项目详细描述
连接项目查询语法分析库。
安装
使用setup.py安装cnx查询语法:
$ 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赖斯大学