Package: sap-business-document-processing
Python Client Library for the SAP AI Business Services: Document Classification and Document Information ExtractionThis repository contains thesource codeof a Python client library to facilitate the use of the SAP AI Business Services:Document ClassificationandDocument Information Extraction. The client library provides two API Client classes that contain convenient methods to access these services and issue calls to theDocument Classification REST APIandDocument Information Extraction REST APIrespectively. To use the library you need tohave access to SAP Business Technology Platform.Check out theusage examples, they are very useful to get started with the services.Have a look atAPI documentationin order to use the library.Notes for users of the sap-document-classification-client libraryThis library includes all the capabilities of the sap-document-classification-client, which will not be developed further. However, the code is still availablehere.
If you want to switch to this library, you have to be aware of the following changes:The DCApiClient can now be imported directly from the top module via:from sap_business_document_processing import DCApiClientThe functionsclassifiy_documents,upload_documents_to_dataset,upload_documents_directory_to_datasetnow return an iterator instead of a list. You can either analyze individual results using withresult = next(iterator)within a try-catch block (e.g. to handle each failed document) or useresults = list(iterator)to turn it to a list. The latter will raise an error if at least one document failed.The functionget_datasets_infonow returns a list which is the "dataset" part of the API response json. (You just need to delete the ["dataset"] from the response to work with it as until now)The functionget_classification_documents_infonow returns a list which is the "results" part of the API response json.The functionget_training_models_infonow returns a list which is the "models" part of the API response json.The functionget_deployed_models_infonow returns a list which is the "deployments" part of the API response json.The library now raises the following custom exceptions:BDPApiException: Base exception for all exceptions of this library. Raise when no other exception is applicable.BDPClientException: Raised when an HTTP response with status code between 400 and 500 is returned. Usually means incorrect user input. (Replaces some HTTPErrors)BDPServerException: Raised when an HTTP response with status code between 500 and 600 is returned. Usually means that the server had some internal error. (Replaces some HTTPErrors)BDPUnauthorizedException: Raised when an HTTP response with status code 401 is returned. Usually means that a wrong OAuth credentials were provided.BDPFailedAsynchronousOperationException: Raised when an asynchronous job failed during processing. (Replaces FailedCallException)BDPPollingTimeoutException: Raised when an asynchronous job exceeds the set polling_max_attempts. (Replaces PollingTimeoutException)The function_poll_for_urlnow doesn`t expect an 'url' and 'payload' parameters, but 'path' and 'json' parameters instead.RequirementsThis library requires properly setupPython3.6 (or higher version) environment.Download and InstallationThis Python library should be consumed in the standard way by runningpip install sap-business-document-processingor adding the library as a dependency of your code inrequirements.txtfile.Demo usagePrerequisites:Get a Free Account on SAP BTP TrialCreate Service Instance for Document Classification with Trial AccountCreate Service Instance for Document Information ExtractionDocument ClassificationTo try out the Document classification service using the document classification client
library you can also run the two demo links below:Try out classification using default modeldemoTry out training and classification using custom modeldemo(requires an enterprise account, trial account isnotsufficient)Document Information ExtractionTry out the Document Information Extraction service with thisshowcaseExercisesExercise 1 - Set up Document Information Extraction Service and UIExercise 2 - Upload a document for extraction using UI applicationExercise 3 - Visualize, correct extraction results and confirm document using UI applicationExercise 4 - Get Auth token to use Document Information Extraction Rest APIExercise 5 - Get extraction results of document using Rest APIExercise 6 - Upload supplier Data for matchingExercise 7 - Upload document through Rest API to enrich the extraction Results with supplier dataKnown IssuesPlease see theissues section.How to obtain supportIn case you would like to contribute to this project, ask any questions or get support, please open an issue containing the description of your question or planned contribution in GitHub and we will get in touch.LicensingPlease see ourLICENSEfor copyright and license information. Detailed information including third-party components and their licensing/copyright information is available via theREUSE tool.