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

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第三方库


热门话题
Android Studio Java将输入存储在一个文本文件中,所有输入在一行中加载后显示在屏幕上   在我的Java应用程序中记录日志配置   java在将socket从Localhost构建到google时出错。通用域名格式   在java中通过SOAP发送附件   java Tomcat的JspWriter编码不正确   java应用程序在截击StringRequest时不断崩溃   java需要一个保持顺序并具有“顺序敏感”equals/hashCode的映射   Java框架地址栏元素   java如何从特定范围生成4个不重复的数字?   googleappenginejava。安全AccessControlException:拒绝访问(java.io.FilePermission)   加载游戏时java Fabric入口点异常崩溃   java Python我如何读入和读出,以便其他读者可以阅读它以便进一步购买?