跳转到主要内容

Python对Hypothesis注释系统的封装

项目描述

Hypothesis

Hypothesis API的Python封装

使用TextQuoteSelector创建注释

h = hypothesis.Hypothesis(username=USER, token=TOKEN)  # your h username and api token (from https://hypothes.is/account/developer)

url = 'url of web page to annotate'
exact = 'selected text (i.e. the quote)'
prefix = '30 chars preceding the quote'
suffix = '30 chars following the quote'
title = 'title of the web page'
tags = ["tag1", "tag2"]
text = "body of annotation, can include [markup](http://example.com)"
   
payload = {
    "uri": url,
    "target": 
        [{
            "source": [url],
            "selector": 
                [{
                    "type": "TextQuoteSelector", 
                    "prefix": prefix,
                    "exact": exact,
                    "suffix": suffix
                    }
                 ]
        }], 
    "tags": tags,
    "text": text,
     "document": {
         "title": [title]
     },
     "permissions": h.permissions,
     "group": h.group
  }

r = h.post_annotation(payload)
print r.status_code

项目详情


下载文件

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

源代码分发

hypothesis-api-1.0.2.tar.gz (8.4 kB 查看哈希值)

上传时间: 源代码

构建分发

hypothesis_api-1.0.2-py3-none-any.whl (9.0 kB 查看哈希值)

上传时间: Python 3

由以下支持