Skip to content

Commit 985b052

Browse files
committed
feat(Compare and Comply): Add ContractCurrencies model
1 parent af91a80 commit 985b052

File tree

5 files changed

+156
-19
lines changed

5 files changed

+156
-19
lines changed

compare-comply/src/main/java/com/ibm/watson/compare_comply/v1/model/ClassifyReturn.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018 IBM Corp. All Rights Reserved.
2+
* (C) Copyright IBM Corp. 2019.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55
* the License. You may obtain a copy of the License at
@@ -40,6 +40,8 @@ public class ClassifyReturn extends GenericModel {
4040
private List<ContractTerms> contractTerms;
4141
@SerializedName("payment_terms")
4242
private List<PaymentTerms> paymentTerms;
43+
@SerializedName("contract_currencies")
44+
private List<ContractCurrencies> contractCurrencies;
4345
private List<Tables> tables;
4446
@SerializedName("document_structure")
4547
private DocStructure documentStructure;
@@ -116,7 +118,7 @@ public List<ContractAmts> getContractAmounts() {
116118
/**
117119
* Gets the terminationDates.
118120
*
119-
* The date or dates on which the document is to be terminated.
121+
* The dates on which the document is to be terminated.
120122
*
121123
* @return the terminationDates
122124
*/
@@ -127,7 +129,7 @@ public List<TerminationDates> getTerminationDates() {
127129
/**
128130
* Gets the contractTypes.
129131
*
130-
* The document's contract type or types as declared in the document.
132+
* The contract type as declared in the document.
131133
*
132134
* @return the contractTypes
133135
*/
@@ -138,7 +140,7 @@ public List<ContractTypes> getContractTypes() {
138140
/**
139141
* Gets the contractTerms.
140142
*
141-
* The duration or durations of the contract.
143+
* The durations of the contract.
142144
*
143145
* @return the contractTerms
144146
*/
@@ -149,14 +151,25 @@ public List<ContractTerms> getContractTerms() {
149151
/**
150152
* Gets the paymentTerms.
151153
*
152-
* The document's payment duration or durations.
154+
* The document's payment durations.
153155
*
154156
* @return the paymentTerms
155157
*/
156158
public List<PaymentTerms> getPaymentTerms() {
157159
return paymentTerms;
158160
}
159161

162+
/**
163+
* Gets the contractCurrencies.
164+
*
165+
* The contract currencies as declared in the document.
166+
*
167+
* @return the contractCurrencies
168+
*/
169+
public List<ContractCurrencies> getContractCurrencies() {
170+
return contractCurrencies;
171+
}
172+
160173
/**
161174
* Gets the tables.
162175
*
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
* (C) Copyright IBM Corp. 2019.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5+
* the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11+
* specific language governing permissions and limitations under the License.
12+
*/
13+
package com.ibm.watson.compare_comply.v1.model;
14+
15+
import java.util.List;
16+
17+
import com.google.gson.annotations.SerializedName;
18+
import com.ibm.cloud.sdk.core.service.model.GenericModel;
19+
20+
/**
21+
* The contract currencies that are declared in the document.
22+
*/
23+
public class ContractCurrencies extends GenericModel {
24+
25+
/**
26+
* The confidence level in the identification of the contract currency.
27+
*/
28+
public interface ConfidenceLevel {
29+
/** High. */
30+
String HIGH = "High";
31+
/** Medium. */
32+
String MEDIUM = "Medium";
33+
/** Low. */
34+
String LOW = "Low";
35+
}
36+
37+
@SerializedName("confidence_level")
38+
private String confidenceLevel;
39+
private String text;
40+
@SerializedName("text_normalized")
41+
private String textNormalized;
42+
@SerializedName("provenance_ids")
43+
private List<String> provenanceIds;
44+
private Location location;
45+
46+
/**
47+
* Gets the confidenceLevel.
48+
*
49+
* The confidence level in the identification of the contract currency.
50+
*
51+
* @return the confidenceLevel
52+
*/
53+
public String getConfidenceLevel() {
54+
return confidenceLevel;
55+
}
56+
57+
/**
58+
* Gets the text.
59+
*
60+
* The contract currency.
61+
*
62+
* @return the text
63+
*/
64+
public String getText() {
65+
return text;
66+
}
67+
68+
/**
69+
* Gets the textNormalized.
70+
*
71+
* The normalized form of the contract currency, which is listed as a string in
72+
* [ISO-4217](https://www.iso.org/iso-4217-currency-codes.html) format. This element is optional; it is returned only
73+
* if normalized text exists.
74+
*
75+
* @return the textNormalized
76+
*/
77+
public String getTextNormalized() {
78+
return textNormalized;
79+
}
80+
81+
/**
82+
* Gets the provenanceIds.
83+
*
84+
* Hashed values that you can send to IBM to provide feedback or receive support.
85+
*
86+
* @return the provenanceIds
87+
*/
88+
public List<String> getProvenanceIds() {
89+
return provenanceIds;
90+
}
91+
92+
/**
93+
* Gets the location.
94+
*
95+
* The numeric location of the identified element in the document, represented with two integers labeled `begin` and
96+
* `end`.
97+
*
98+
* @return the location
99+
*/
100+
public Location getLocation() {
101+
return location;
102+
}
103+
}

compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/CompareComplyServiceIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class CompareComplyServiceIT extends CompareComplyServiceTest {
5151
private static final String RESOURCE = "src/test/resources/compare_comply/";
5252
private static final File CONTRACT_A = new File(RESOURCE + "contract-a.pdf");
5353
private static final File CONTRACT_B = new File(RESOURCE + "contract-b.pdf");
54-
private static final File TABLE_FILE = new File(RESOURCE + "test-table.pdf");
54+
private static final File TABLE_FILE = new File(RESOURCE + "test-table.png");
5555
private static final File INPUT_CREDENTIALS_FILE =
5656
new File(RESOURCE + "cloud-object-storage-credentials-input.json");
5757
private static final File OUTPUT_CREDENTIALS_FILE =
@@ -92,7 +92,7 @@ public void testClassifyElements() throws FileNotFoundException {
9292
public void testExtractTables() throws FileNotFoundException {
9393
ExtractTablesOptions extractTablesOptions = new ExtractTablesOptions.Builder()
9494
.file(TABLE_FILE)
95-
.fileContentType(HttpMediaType.APPLICATION_PDF)
95+
.fileContentType("image/png")
9696
.build();
9797
TableReturn response = service.extractTables(extractTablesOptions).execute().getResult();
9898

compare-comply/src/test/java/com/ibm/watson/compare_comply/v1/CompareComplyTest.java

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.ibm.watson.compare_comply.v1.model.CompareDocumentsOptions;
2525
import com.ibm.watson.compare_comply.v1.model.CompareReturn;
2626
import com.ibm.watson.compare_comply.v1.model.ContractAmts;
27+
import com.ibm.watson.compare_comply.v1.model.ContractCurrencies;
2728
import com.ibm.watson.compare_comply.v1.model.ContractTerms;
2829
import com.ibm.watson.compare_comply.v1.model.ContractType;
2930
import com.ibm.watson.compare_comply.v1.model.ConvertToHtmlOptions;
@@ -618,14 +619,14 @@ public void testClassifyElements() throws FileNotFoundException, InterruptedExce
618619
assertEquals(ROW_INDEX_END, response.getTables().get(0).getBodyCells().get(0).getRowIndexEnd());
619620
assertEquals(COLUMN_INDEX_BEGIN, response.getTables().get(0).getBodyCells().get(0).getColumnIndexBegin());
620621
assertEquals(COLUMN_INDEX_END, response.getTables().get(0).getBodyCells().get(0).getColumnIndexEnd());
621-
assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getRowHeaderIds().get(0).getId());
622-
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getRowHeaderTexts().get(0).getText());
622+
assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getRowHeaderIds().get(0));
623+
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getRowHeaderTexts().get(0));
623624
assertEquals(TEXT_NORMALIZED,
624-
response.getTables().get(0).getBodyCells().get(0).getRowHeaderTextsNormalized().get(0).getTextNormalized());
625-
assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderIds().get(0).getId());
626-
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTexts().get(0).getText());
625+
response.getTables().get(0).getBodyCells().get(0).getRowHeaderTextsNormalized().get(0));
626+
assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderIds().get(0));
627+
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTexts().get(0));
627628
assertEquals(TEXT_NORMALIZED,
628-
response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTextsNormalized().get(0).getTextNormalized());
629+
response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTextsNormalized().get(0));
629630
assertEquals(TYPE, response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getType());
630631
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getText());
631632
assertEquals(BEGIN,
@@ -721,6 +722,12 @@ public void testClassifyElements() throws FileNotFoundException, InterruptedExce
721722
assertEquals(PROVENANCE_ID, response.getPaymentTerms().get(0).getProvenanceIds().get(0));
722723
assertEquals(BEGIN, response.getPaymentTerms().get(0).getLocation().getBegin());
723724
assertEquals(END, response.getPaymentTerms().get(0).getLocation().getEnd());
725+
assertEquals(ContractCurrencies.ConfidenceLevel.HIGH, response.getContractCurrencies().get(0).getConfidenceLevel());
726+
assertEquals(TEXT, response.getContractCurrencies().get(0).getText());
727+
assertEquals(TEXT_NORMALIZED, response.getContractCurrencies().get(0).getTextNormalized());
728+
assertEquals(PROVENANCE_ID, response.getContractCurrencies().get(0).getProvenanceIds().get(0));
729+
assertEquals(BEGIN, response.getContractCurrencies().get(0).getLocation().getBegin());
730+
assertEquals(END, response.getContractCurrencies().get(0).getLocation().getEnd());
724731
}
725732

726733
@Test
@@ -778,14 +785,14 @@ public void testExtractTables() throws FileNotFoundException, InterruptedExcepti
778785
assertEquals(ROW_INDEX_END, response.getTables().get(0).getBodyCells().get(0).getRowIndexEnd());
779786
assertEquals(COLUMN_INDEX_BEGIN, response.getTables().get(0).getBodyCells().get(0).getColumnIndexBegin());
780787
assertEquals(COLUMN_INDEX_END, response.getTables().get(0).getBodyCells().get(0).getColumnIndexEnd());
781-
assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getRowHeaderIds().get(0).getId());
782-
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getRowHeaderTexts().get(0).getText());
788+
assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getRowHeaderIds().get(0));
789+
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getRowHeaderTexts().get(0));
783790
assertEquals(TEXT_NORMALIZED,
784-
response.getTables().get(0).getBodyCells().get(0).getRowHeaderTextsNormalized().get(0).getTextNormalized());
785-
assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderIds().get(0).getId());
786-
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTexts().get(0).getText());
791+
response.getTables().get(0).getBodyCells().get(0).getRowHeaderTextsNormalized().get(0));
792+
assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderIds().get(0));
793+
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTexts().get(0));
787794
assertEquals(TEXT_NORMALIZED,
788-
response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTextsNormalized().get(0).getTextNormalized());
795+
response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTextsNormalized().get(0));
789796
assertEquals(TYPE, response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getType());
790797
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getText());
791798
assertEquals(BEGIN,

compare-comply/src/test/resources/compare_comply/classify-return.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,5 +350,19 @@
350350
"end": 1
351351
}
352352
}
353+
],
354+
"contract_currencies": [
355+
{
356+
"confidence_level": "High",
357+
"text": "text",
358+
"text_normalized": "text_normalized",
359+
"provenance_ids": [
360+
"provenance_id"
361+
],
362+
"location": {
363+
"begin": 0,
364+
"end": 1
365+
}
366+
}
353367
]
354368
}

0 commit comments

Comments
 (0)