|
| 1 | +# coding: utf-8 |
| 2 | +from __future__ import print_function |
| 3 | +import json |
| 4 | +import os |
| 5 | +from ibm_watson import CompareComplyV1 |
| 6 | + |
| 7 | +# If service instance provides API key authentication |
| 8 | +compare_comply = CompareComplyV1( |
| 9 | + version='2018-03-23', |
| 10 | + ## url is optional, and defaults to the URL below. Use the correct URL for your region. |
| 11 | + url='https://gateway.watsonplatform.net/compare-comply/api', |
| 12 | + iam_apikey='YOUR APIKEY') |
| 13 | + |
| 14 | +# compare_comply = CompareComplyV1( |
| 15 | +# version='2018-03-23', |
| 16 | +# ## url is optional, and defaults to the URL below. Use the correct URL for your region. |
| 17 | +# # url='https://gateway.watsonplatform.net/compare-comply/api', |
| 18 | +# username='YOUR SERVICE USERNAME', |
| 19 | +# password='YOUR SERVICE PASSWORD') |
| 20 | + |
| 21 | +print('Convert to HTML') |
| 22 | +contract = os.path.abspath('resources/contract_A.pdf') |
| 23 | +with open(contract, 'rb') as file: |
| 24 | + result = compare_comply.convert_to_html(file).get_result() |
| 25 | + print(json.dumps(result, indent=2)) |
| 26 | + |
| 27 | +print('Classify elements') |
| 28 | +contract = os.path.abspath('resources/contract_A.pdf') |
| 29 | +with open(contract, 'rb') as file: |
| 30 | + result = compare_comply.classify_elements(file, 'application/pdf').get_result() |
| 31 | + print(json.dumps(result, indent=2)) |
| 32 | + |
| 33 | +print('Extract tables') |
| 34 | +table = os.path.abspath('resources/contract_A.pdf') |
| 35 | +with open(table, 'rb') as file: |
| 36 | + result = compare_comply.extract_tables(file).get_result() |
| 37 | + print(json.dumps(result, indent=2)) |
0 commit comments