Gavagai API帮助程序库。

Gavagai的Python项目详细描述


一个Gavagaiapi帮助程序库。

https://travis-ci.org/dewe/gavagai-python.svg?branch=master

安装

$ pip install gavagai

API键

Gavagai Developer Portal免费获取自己的api密钥。

在实例化客户机时可以指定api密钥,请参见示例 下面。或者,您可以设置gavagai_apikey环境 变量,只需调用GavagaiClient()

API方法

此版本支持的gavagai rest api方法:

  • /keywords-从 文本。
  • /lexicon-在Gavagai Living Lexicon中查找单词。
  • /tonality-多维情绪分析。
  • /topics&;/stories-多文本摘要:获取 你的文本集的要点不必阅读每一个 一句话。

使用

Gavagai API documentation 有关可用API资源的详细信息。

示例:对一组文本的api调用

/keywords资源从集合中提取突出的概念 文本。按出现次数排序。

fromgavagai.clientimportGavagaiClientfrompprintimportpprinttexts=['Stayed here for 3 nights at the beginning of a trip of California. Could not say enough good things about the hotel Monaco. Amazing staff, amazing rooms and the location is brilliant! First stay at a Kimpton hotel, but definitely not the last!!!','I did a lot of research looking for a hotel suite for our family vacation in San Francisco. The Hotel Monaco was a perfect choice. What friendly and delightful staff. I will miss the Grand Cafe, but I will make sure to come back to see their new offerings.','My partner and I spent four nights here over New Years and loved it. Super staff; lovely, quiet room; excellent location within easy walking to much of Downtown and an overall experience that was perfect.']client=GavagaiClient('use_your_own_api_key')result=client.keywords(texts)keywords=result.json()pprint(keywords)

示例:指定语言

的api调用

/tonality资源测量多维情绪,基于 词汇分析。默认语言为英语,但对于其他语言的文本 语言,应指定语言选项。

romgavagai.clientimportGavagaiClientfrompprintimportpprinttexts=[u'Din idiot!',u'Jag älskar dig.',u'Hen hatar det.']client=GavagaiClient('use_your_own_api_key')result=client.tonality(texts,language='sv')# swedish language optionkeywords=result.json()pprint(keywords)

为开发而设置

来自此存储库的根目录:

$ pip install -r requirements.txt

运行测试

$ py.test

释放

我用zest.releaser来释放这个包。

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

推荐PyPI第三方库


热门话题
使用Selenium Java查找筛选器窗格“铅笔图标”的元素时出现问题   分布式缓存l2上使用infinispan和hibernate的java连接锁   使用Java的DOM XML API解析XML中的符号和   java是解析和操作字符串的有效方法   java发布NewRelicMeterRegistry时如何过滤仪表   多维数组在java中读取文件后将数据值分组   java如何将httpClient配置为jsoup   java BreakIterator在Android中是如何工作的?   找不到maven GAE类:原因:java。lang.ClassNotFoundException应用程序标识cRedential$AppenginecRedential包装   Jlabel调整java大小   调试如何在VScode中的java类依赖项中设置断点   java正在获取文件夹名,而不是。mp3文件{Android}   java如何将从DiffieHellman类生成的AES密钥添加到使用该密钥的类