Skip to content

Commit ec377be

Browse files
committed
chore(examples): Added examples for compare comply
1 parent 780f3c1 commit ec377be

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

examples/compare_comply_v1.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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

Comments
 (0)