Skip to main content

chunk_file_python

from sapling import SaplingClient

file_name = '<FILE_TO_PROCESS>'
api_key = '<api-key>'

text = ''
with open(file_name) as f:
text = f.read().strip()

client = SaplingClient(api_key=api_key)
chunks = client.chunk_text(text, max_length=20000)

for chunk in chunks:
edits = client.edits(chunk, session_id=file_name)