sapling-py 4.0.0__tar.gz → 4.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sapling-py-4.0.0/sapling_py.egg-info → sapling_py-4.0.2}/PKG-INFO +2 -1
- {sapling-py-4.0.0 → sapling_py-4.0.2}/sapling/client.py +58 -26
- sapling_py-4.0.2/sapling/version.py +1 -0
- {sapling-py-4.0.0 → sapling_py-4.0.2/sapling_py.egg-info}/PKG-INFO +2 -1
- sapling-py-4.0.0/sapling/version.py +0 -1
- {sapling-py-4.0.0 → sapling_py-4.0.2}/LICENSE +0 -0
- {sapling-py-4.0.0 → sapling_py-4.0.2}/README.md +0 -0
- {sapling-py-4.0.0 → sapling_py-4.0.2}/sapling/__init__.py +0 -0
- {sapling-py-4.0.0 → sapling_py-4.0.2}/sapling_py.egg-info/SOURCES.txt +0 -0
- {sapling-py-4.0.0 → sapling_py-4.0.2}/sapling_py.egg-info/dependency_links.txt +0 -0
- {sapling-py-4.0.0 → sapling_py-4.0.2}/sapling_py.egg-info/requires.txt +0 -0
- {sapling-py-4.0.0 → sapling_py-4.0.2}/sapling_py.egg-info/top_level.txt +0 -0
- {sapling-py-4.0.0 → sapling_py-4.0.2}/setup.cfg +0 -0
- {sapling-py-4.0.0 → sapling_py-4.0.2}/setup.py +0 -0
- {sapling-py-4.0.0 → sapling_py-4.0.2}/test/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sapling-py
|
|
3
|
-
Version: 4.0.
|
|
3
|
+
Version: 4.0.2
|
|
4
4
|
Summary: Sapling Python Client
|
|
5
5
|
Home-page: https://sapling.ai
|
|
6
6
|
Author: Sapling Intelligence
|
|
@@ -10,6 +10,7 @@ Classifier: Development Status :: 3 - Alpha
|
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
License-File: LICENSE
|
|
13
|
+
Requires-Dist: requests
|
|
13
14
|
|
|
14
15
|
# Sapling Python Client
|
|
15
16
|
|
|
@@ -38,6 +38,8 @@ class SaplingClient:
|
|
|
38
38
|
medical=None,
|
|
39
39
|
auto_apply=False,
|
|
40
40
|
advanced_edits=None,
|
|
41
|
+
user_id=None,
|
|
42
|
+
is_anon_user=None,
|
|
41
43
|
):
|
|
42
44
|
'''
|
|
43
45
|
Fetches edits (including for grammar and spelling) for provided text.
|
|
@@ -46,8 +48,8 @@ class SaplingClient:
|
|
|
46
48
|
:type text: str
|
|
47
49
|
:param session_id: Unique name or UUID of document or portion of text that is being checked
|
|
48
50
|
:type session_id: str
|
|
49
|
-
:param
|
|
50
|
-
:type
|
|
51
|
+
:param lang: 2 letter ISO 639-1 language code
|
|
52
|
+
:type lang: str
|
|
51
53
|
:param variety: Specifies regional English variety preference. Defaults to the configuration in the user Sapling dashboard.
|
|
52
54
|
:type variety: str
|
|
53
55
|
:param medical: If true, the backend will apply Sapling's medical dictionary.
|
|
@@ -56,26 +58,10 @@ class SaplingClient:
|
|
|
56
58
|
:type auto_apply: bool
|
|
57
59
|
:param advanced_edits: Additional edit configurations
|
|
58
60
|
:type advanced_edits: dict
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
- hard_to_read
|
|
64
|
-
- qualifiers
|
|
65
|
-
- voice
|
|
66
|
-
- dei
|
|
67
|
-
- gender
|
|
68
|
-
- gender_pronoun
|
|
69
|
-
- gender_noun
|
|
70
|
-
- gender_id
|
|
71
|
-
- sensitivity
|
|
72
|
-
- disability
|
|
73
|
-
- age
|
|
74
|
-
- race
|
|
75
|
-
- social_class
|
|
76
|
-
- violence
|
|
77
|
-
\
|
|
78
|
-
|
|
61
|
+
:param user_id: Track IDs representing your end users
|
|
62
|
+
:type user_id: str
|
|
63
|
+
:param is_anon_user: If user_id represents a logged-in or anonymous user
|
|
64
|
+
:type is_anon_user: bool
|
|
79
65
|
:rtype: dict
|
|
80
66
|
:return:
|
|
81
67
|
- edits: List of Edits:
|
|
@@ -111,6 +97,24 @@ class SaplingClient:
|
|
|
111
97
|
- `ca-variety`: Canadian English
|
|
112
98
|
- `null-variety`: Don't suggest changes based on English variety
|
|
113
99
|
|
|
100
|
+
Supported advanced_edit options:
|
|
101
|
+
- advanced_edits
|
|
102
|
+
- adverbs
|
|
103
|
+
- simplifications
|
|
104
|
+
- hard_to_read
|
|
105
|
+
- qualifiers
|
|
106
|
+
- voice
|
|
107
|
+
- dei
|
|
108
|
+
- gender
|
|
109
|
+
- gender_pronoun
|
|
110
|
+
- gender_noun
|
|
111
|
+
- gender_id
|
|
112
|
+
- sensitivity
|
|
113
|
+
- disability
|
|
114
|
+
- age
|
|
115
|
+
- race
|
|
116
|
+
- social_class
|
|
117
|
+
- violence
|
|
114
118
|
'''
|
|
115
119
|
|
|
116
120
|
url = self.url_endpoint + 'edits'
|
|
@@ -131,6 +135,11 @@ class SaplingClient:
|
|
|
131
135
|
if advanced_edits is not None:
|
|
132
136
|
data['advanced_edits'] = advanced_edits
|
|
133
137
|
|
|
138
|
+
if user_id is not None:
|
|
139
|
+
data['user_id'] = user_id
|
|
140
|
+
if is_anon_user is not None:
|
|
141
|
+
data['is_anon_user'] = is_anon_user
|
|
142
|
+
|
|
134
143
|
resp = requests.post(
|
|
135
144
|
url,
|
|
136
145
|
json=data,
|
|
@@ -144,6 +153,7 @@ class SaplingClient:
|
|
|
144
153
|
self,
|
|
145
154
|
edit_uuid,
|
|
146
155
|
session_id=None,
|
|
156
|
+
user_id=None,
|
|
147
157
|
):
|
|
148
158
|
'''
|
|
149
159
|
Use this API endpoint to have Sapling adapt its system over time.
|
|
@@ -156,6 +166,8 @@ class SaplingClient:
|
|
|
156
166
|
:type edit_uuid: str, uuid
|
|
157
167
|
:param session_id: Unique name or UUID of text that is being processed
|
|
158
168
|
:type session_id: str
|
|
169
|
+
:param user_id: Track IDs representing your end users
|
|
170
|
+
:type user_id: str
|
|
159
171
|
'''
|
|
160
172
|
url = f'{self.url_endpoint}edits/{edit_uuid}/accept'
|
|
161
173
|
session_id = session_id or self.default_session_id
|
|
@@ -163,6 +175,10 @@ class SaplingClient:
|
|
|
163
175
|
'key': self.api_key,
|
|
164
176
|
'session_id': session_id,
|
|
165
177
|
}
|
|
178
|
+
|
|
179
|
+
if user_id is not None:
|
|
180
|
+
data['user_id'] = user_id
|
|
181
|
+
|
|
166
182
|
resp = requests.post(
|
|
167
183
|
url,
|
|
168
184
|
json=data,
|
|
@@ -176,6 +192,7 @@ class SaplingClient:
|
|
|
176
192
|
self,
|
|
177
193
|
edit_uuid,
|
|
178
194
|
session_id=None,
|
|
195
|
+
user_id=None,
|
|
179
196
|
):
|
|
180
197
|
'''
|
|
181
198
|
Use this API endpoint to have Sapling not recommend the same edit anymore.
|
|
@@ -188,6 +205,8 @@ class SaplingClient:
|
|
|
188
205
|
:type edit_uuid: str, uuid
|
|
189
206
|
:param session_id: Unique name or UUID of text that is being processed
|
|
190
207
|
:type session_id: str
|
|
208
|
+
:param user_id: Track IDs representing your end users
|
|
209
|
+
:type user_id: str
|
|
191
210
|
'''
|
|
192
211
|
url = f'{self.url_endpoint}edits/{edit_uuid}/reject'
|
|
193
212
|
session_id = session_id or self.default_session_id
|
|
@@ -195,6 +214,10 @@ class SaplingClient:
|
|
|
195
214
|
'key': self.api_key,
|
|
196
215
|
'session_id': session_id,
|
|
197
216
|
}
|
|
217
|
+
|
|
218
|
+
if user_id is not None:
|
|
219
|
+
data['user_id'] = user_id
|
|
220
|
+
|
|
198
221
|
resp = requests.post(
|
|
199
222
|
url,
|
|
200
223
|
json=data,
|
|
@@ -214,6 +237,8 @@ class SaplingClient:
|
|
|
214
237
|
auto_apply=False,
|
|
215
238
|
variety=None,
|
|
216
239
|
user_data=None,
|
|
240
|
+
user_id=None,
|
|
241
|
+
is_anon_user=None
|
|
217
242
|
):
|
|
218
243
|
'''
|
|
219
244
|
Fetches spelling (no grammar or phrase level) edits for provided text.
|
|
@@ -234,6 +259,10 @@ class SaplingClient:
|
|
|
234
259
|
:type advanced_edits: dict
|
|
235
260
|
:param variety: Specifies regional English variety preference. Defaults to the configuration in the user Sapling dashboard.
|
|
236
261
|
:type variety: str
|
|
262
|
+
:param user_id: Track IDs representing your end users
|
|
263
|
+
:type user_id: str
|
|
264
|
+
:param is_anon_user: If user_id represents a logged-in or anonymous user
|
|
265
|
+
:type is_anon_user: bool
|
|
237
266
|
|
|
238
267
|
:rtype: list[dict]
|
|
239
268
|
|
|
@@ -309,14 +338,18 @@ class SaplingClient:
|
|
|
309
338
|
if user_data is not None:
|
|
310
339
|
data['user_data'] = user_data
|
|
311
340
|
|
|
341
|
+
if user_id is not None:
|
|
342
|
+
data['user_id'] = user_id
|
|
343
|
+
if is_anon_user is not None:
|
|
344
|
+
data['is_anon_user'] = is_anon_user
|
|
345
|
+
|
|
312
346
|
resp = requests.post(
|
|
313
347
|
url,
|
|
314
348
|
json=data,
|
|
315
349
|
timeout=self.timeout,
|
|
316
350
|
)
|
|
317
351
|
if 200 <= resp.status_code < 300:
|
|
318
|
-
|
|
319
|
-
return resp_json.get('edits')
|
|
352
|
+
return resp.json()
|
|
320
353
|
raise Exception(f'HTTP {resp.status_code}: {resp.text}')
|
|
321
354
|
|
|
322
355
|
|
|
@@ -347,8 +380,7 @@ class SaplingClient:
|
|
|
347
380
|
timeout=self.timeout,
|
|
348
381
|
)
|
|
349
382
|
if 200 <= resp.status_code < 300:
|
|
350
|
-
|
|
351
|
-
return resp_json
|
|
383
|
+
return resp.json()
|
|
352
384
|
raise Exception(f'HTTP {resp.status_code}: {resp.text}')
|
|
353
385
|
|
|
354
386
|
def accept_complete(
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '4.0.2'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sapling-py
|
|
3
|
-
Version: 4.0.
|
|
3
|
+
Version: 4.0.2
|
|
4
4
|
Summary: Sapling Python Client
|
|
5
5
|
Home-page: https://sapling.ai
|
|
6
6
|
Author: Sapling Intelligence
|
|
@@ -10,6 +10,7 @@ Classifier: Development Status :: 3 - Alpha
|
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
License-File: LICENSE
|
|
13
|
+
Requires-Dist: requests
|
|
13
14
|
|
|
14
15
|
# Sapling Python Client
|
|
15
16
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '4.0.0'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|