sapling-py 2.0.2__tar.gz → 3.0.1__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-2.0.2/sapling_py.egg-info → sapling-py-3.0.1}/PKG-INFO +4 -1
- {sapling-py-2.0.2 → sapling-py-3.0.1}/sapling/client.py +142 -0
- sapling-py-3.0.1/sapling/version.py +1 -0
- {sapling-py-2.0.2 → sapling-py-3.0.1/sapling_py.egg-info}/PKG-INFO +4 -1
- sapling-py-2.0.2/sapling/version.py +0 -1
- {sapling-py-2.0.2 → sapling-py-3.0.1}/LICENSE +0 -0
- {sapling-py-2.0.2 → sapling-py-3.0.1}/README.md +0 -0
- {sapling-py-2.0.2 → sapling-py-3.0.1}/sapling/__init__.py +0 -0
- {sapling-py-2.0.2 → sapling-py-3.0.1}/sapling_py.egg-info/SOURCES.txt +0 -0
- {sapling-py-2.0.2 → sapling-py-3.0.1}/sapling_py.egg-info/dependency_links.txt +0 -0
- {sapling-py-2.0.2 → sapling-py-3.0.1}/sapling_py.egg-info/requires.txt +0 -0
- {sapling-py-2.0.2 → sapling-py-3.0.1}/sapling_py.egg-info/top_level.txt +0 -0
- {sapling-py-2.0.2 → sapling-py-3.0.1}/setup.cfg +0 -0
- {sapling-py-2.0.2 → sapling-py-3.0.1}/setup.py +0 -0
- {sapling-py-2.0.2 → sapling-py-3.0.1}/test/__init__.py +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sapling-py
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.1
|
|
4
4
|
Summary: Sapling Python Client
|
|
5
5
|
Home-page: https://sapling.ai
|
|
6
6
|
Author: Sapling Intelligence
|
|
7
7
|
Author-email: info@sapling.ai
|
|
8
8
|
License: Apache License 2.0
|
|
9
|
+
Platform: UNKNOWN
|
|
9
10
|
Classifier: Development Status :: 3 - Alpha
|
|
10
11
|
Classifier: Programming Language :: Python :: 3
|
|
11
12
|
Description-Content-Type: text/markdown
|
|
@@ -91,3 +92,5 @@ License
|
|
|
91
92
|
Copyright 2022 Sapling Intelligence, Inc.
|
|
92
93
|
|
|
93
94
|
Licensed under the Apache License, Version 2.0.
|
|
95
|
+
|
|
96
|
+
|
|
@@ -54,6 +54,14 @@ class SaplingClient:
|
|
|
54
54
|
:param auto_apply: Whether to return a field with edits applied to the text
|
|
55
55
|
:type auto_apply: bool
|
|
56
56
|
:rtype: list[dict]
|
|
57
|
+
:return:
|
|
58
|
+
- sentence: Unedited sentence
|
|
59
|
+
- sentence_start: Offset of sentence from start of text
|
|
60
|
+
- start: Offset of edit start relative to sentence
|
|
61
|
+
- end: Offset of edit end relative to sentence
|
|
62
|
+
- replacement: Suggested replacement
|
|
63
|
+
- error_type: Error type
|
|
64
|
+
- general_error_type: General Error type
|
|
57
65
|
|
|
58
66
|
Supported languages:
|
|
59
67
|
- `de`: German (Deutsch)
|
|
@@ -366,6 +374,13 @@ class SaplingClient:
|
|
|
366
374
|
:type text: str
|
|
367
375
|
:param sent_scores: If true, each sentence will also be scored individually.
|
|
368
376
|
:type sent_scores: bool
|
|
377
|
+
|
|
378
|
+
:rtype: dict
|
|
379
|
+
:return:
|
|
380
|
+
- score: float between 0 and 1, probability that text is AI generated
|
|
381
|
+
- sentence_scores: If sent_scores is set, will return a list of scores per sentence.
|
|
382
|
+
- text: text that was processed
|
|
383
|
+
|
|
369
384
|
'''
|
|
370
385
|
url = f'{self.url_endpoint}aidetect'
|
|
371
386
|
data = {
|
|
@@ -382,3 +397,130 @@ class SaplingClient:
|
|
|
382
397
|
if 200 <= resp.status_code < 300:
|
|
383
398
|
return resp.json()
|
|
384
399
|
raise Exception(f'HTTP {resp.status_code}: resp.text')
|
|
400
|
+
|
|
401
|
+
def chunk_text(
|
|
402
|
+
self,
|
|
403
|
+
text,
|
|
404
|
+
max_length,
|
|
405
|
+
step_size=None,
|
|
406
|
+
):
|
|
407
|
+
'''
|
|
408
|
+
Break an input text into blocks of length of most max_length. When splitting the text, the API follows the following preference stack:
|
|
409
|
+
|
|
410
|
+
page break > paragraph breaks > line breaks > tabs > punctuation > all other whitespace
|
|
411
|
+
|
|
412
|
+
:param text: Text to be chunked
|
|
413
|
+
:type text: str
|
|
414
|
+
:param max_length: Maximum length of text segments.
|
|
415
|
+
:type max_length: integer
|
|
416
|
+
:param step_size: Size of window to look for split points.
|
|
417
|
+
:type step_size: integer
|
|
418
|
+
:rtype: dict
|
|
419
|
+
:return:
|
|
420
|
+
- chunks: List of resulting chunks
|
|
421
|
+
'''
|
|
422
|
+
url = f'{self.url_endpoint}ingest/chunk_text'
|
|
423
|
+
data = {
|
|
424
|
+
'key': self.api_key,
|
|
425
|
+
'text': text,
|
|
426
|
+
'max_length': max_length
|
|
427
|
+
}
|
|
428
|
+
if step_size is not None:
|
|
429
|
+
data['step_size'] = step_size
|
|
430
|
+
resp = requests.post(
|
|
431
|
+
url,
|
|
432
|
+
json=data,
|
|
433
|
+
timeout=self.timeout,
|
|
434
|
+
)
|
|
435
|
+
if 200 <= resp.status_code < 300:
|
|
436
|
+
return resp.json()
|
|
437
|
+
raise Exception(f'HTTP {resp.status_code}: {resp.text}')
|
|
438
|
+
|
|
439
|
+
def chunk_html(
|
|
440
|
+
self,
|
|
441
|
+
html,
|
|
442
|
+
max_length,
|
|
443
|
+
step_size=None,
|
|
444
|
+
):
|
|
445
|
+
'''
|
|
446
|
+
Break an input text into blocks of length of most max_length. When splitting the text, the API follows the following preference stack:
|
|
447
|
+
|
|
448
|
+
page break > paragraph breaks > line breaks > tabs > punctuation > all other whitespace
|
|
449
|
+
|
|
450
|
+
Note: This endpoint not only breaks up the HTML but also discards all HTML tags, resulting in plain text.
|
|
451
|
+
|
|
452
|
+
:param html: HTML to be chunked
|
|
453
|
+
:type html: str
|
|
454
|
+
:param max_length: Maximum length of text segments.
|
|
455
|
+
:type max_length: integer
|
|
456
|
+
:param step_size: Size of window to look for split points.
|
|
457
|
+
:type step_size: integer
|
|
458
|
+
:rtype: dict
|
|
459
|
+
:return:
|
|
460
|
+
- chunks: List of resulting chunks representing the segmented text contained within the HTML
|
|
461
|
+
'''
|
|
462
|
+
url = f'{self.url_endpoint}ingest/chunk_html'
|
|
463
|
+
data = {
|
|
464
|
+
'key': self.api_key,
|
|
465
|
+
'html': html,
|
|
466
|
+
'max_length': max_length
|
|
467
|
+
}
|
|
468
|
+
if step_size is not None:
|
|
469
|
+
data['step_size'] = step_size
|
|
470
|
+
resp = requests.post(
|
|
471
|
+
url,
|
|
472
|
+
json=data,
|
|
473
|
+
timeout=self.timeout,
|
|
474
|
+
)
|
|
475
|
+
if 200 <= resp.status_code < 300:
|
|
476
|
+
return resp.json()
|
|
477
|
+
raise Exception(f'HTTP {resp.status_code}: {resp.text}')
|
|
478
|
+
|
|
479
|
+
def postprocess(
|
|
480
|
+
self,
|
|
481
|
+
text,
|
|
482
|
+
session_id,
|
|
483
|
+
operations,
|
|
484
|
+
):
|
|
485
|
+
'''
|
|
486
|
+
Performs a variety of operations that are useful for working with the outputs of an NLP (whether human or AI) system. These include:
|
|
487
|
+
- Fixing or restoring punctuation
|
|
488
|
+
- Fixing capitalization
|
|
489
|
+
- Fixing or restoring whitespace
|
|
490
|
+
Example use cases include repairing transcriptions or captions.
|
|
491
|
+
|
|
492
|
+
:param text: Text to postprocess
|
|
493
|
+
:type text: str
|
|
494
|
+
:param session_id: Unique name or UUID of document or portion of text that is being chunked
|
|
495
|
+
:type text: str
|
|
496
|
+
:param operations: Operations to apply. The currently accepted operations are:
|
|
497
|
+
- capitalize
|
|
498
|
+
- punctuate
|
|
499
|
+
- fixspaces
|
|
500
|
+
:type operations: list[str]
|
|
501
|
+
:rtype: list[dict]
|
|
502
|
+
:return:
|
|
503
|
+
Same as the edits endpoint:
|
|
504
|
+
- sentence: Unedited sentence
|
|
505
|
+
- sentence_start: Offset of sentence from start of text
|
|
506
|
+
- start: Offset of edit start relative to sentence
|
|
507
|
+
- end: Offset of edit end relative to sentence
|
|
508
|
+
- replacement: Suggested replacement
|
|
509
|
+
- error_type: Error type
|
|
510
|
+
- general_error_type: General Error type
|
|
511
|
+
'''
|
|
512
|
+
url = f'{self.url_endpoint}postprocess'
|
|
513
|
+
data = {
|
|
514
|
+
'key': self.api_key,
|
|
515
|
+
'text': text,
|
|
516
|
+
'session_id': session_id,
|
|
517
|
+
'operations': operations,
|
|
518
|
+
}
|
|
519
|
+
resp = requests.post(
|
|
520
|
+
url,
|
|
521
|
+
json=data,
|
|
522
|
+
timeout=self.timeout,
|
|
523
|
+
)
|
|
524
|
+
if 200 <= resp.status_code < 300:
|
|
525
|
+
return resp.json()
|
|
526
|
+
raise Exception(f'HTTP {resp.status_code}: {resp.text}')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '3.0.1'
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sapling-py
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.1
|
|
4
4
|
Summary: Sapling Python Client
|
|
5
5
|
Home-page: https://sapling.ai
|
|
6
6
|
Author: Sapling Intelligence
|
|
7
7
|
Author-email: info@sapling.ai
|
|
8
8
|
License: Apache License 2.0
|
|
9
|
+
Platform: UNKNOWN
|
|
9
10
|
Classifier: Development Status :: 3 - Alpha
|
|
10
11
|
Classifier: Programming Language :: Python :: 3
|
|
11
12
|
Description-Content-Type: text/markdown
|
|
@@ -91,3 +92,5 @@ License
|
|
|
91
92
|
Copyright 2022 Sapling Intelligence, Inc.
|
|
92
93
|
|
|
93
94
|
Licensed under the Apache License, Version 2.0.
|
|
95
|
+
|
|
96
|
+
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '2.0.2'
|
|
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
|