Skip to main content

Spatial Text Service

Overview

ai-core-spatial-text service utilizes the cognaize_spatial_text Python library for extracting text from PDF documents while preserving the document's spatial layout by using Optical Character Recognition (OCR). The service is using aiohttp for handling HTTP and WebSocket connections. For more details about cognaize_spatial_text, please refer to the documentation of Spatial Text Package.

Installation

Install the required dependencies using pip along with the FURY_AUTH authentication token:

FURY_AUTH=${FURY_AUTH} pip install -r requirements.txt

Running the Service Locally

Launching the Server:

python app/server.py

Monitoring Service Progress via WebSocket [Optional]

  • Set the request type to WebSocket
  • Enter the WebSocket URL: ws://localhost:8000/ws
  • Click Connect

Uploading PDF File to Process: To upload a PDF file for processing:

  • Open Postman
  • Set the request type to http
  • Set the method to POST
  • Use the URL http://localhost:8000/txt
  • Add a key with the type File and name it file
  • Select the PDF file from your computer that you wish to upload
  • Click Send to upload the file and start the Spatial Text Creation process

Viewing the Output:

  • Response Format: The response will appear in JSON format as follows:
{
"result": "spatial text content",
"filename": "uploaded_file.pdf"
}
  • WebSocket Updates: If connected via WebSocket, you'll receive real-time updates on the process of creating Spatial Text.