连接项目搜索查询帕辛图书馆。

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赖斯大学

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
具有x86javapath的x64机器上x86java上的java JNI未满足链接错误   java将Pixmap的一部分上传到GPU   图像Java位图RLE8格式   java Android studio谷歌广告崩溃应用程序   java如何创建包含未知数量对象的变量?   Java计算给定int数组的所有可能组合   java JDBC classnotfound异常   httpclient中的java将HttpEntity转换为字符串的最优雅/正确的方法是什么?   如何从Java程序运行nano?   java在安卓中调用自定义类/方法   调用方法和JOptionPane后,允许代码继续执行所需的java计时器或其他想法   关于侦听器的向量Java并发问题   线程池执行器Java线程池   java配置DTO上的Swagger javax验证约束   Java中用于按钮功能的swing操作命令   ServletOutputStream中的java设置状态代码   java打印输入数组的平均值