Skip to content

Commit

Permalink
feat(Compare and Comply): Add ContractCurrencies model
Browse files Browse the repository at this point in the history
  • Loading branch information
lpatino10 committed Aug 21, 2019
1 parent af91a80 commit 985b052
Show file tree
Hide file tree
Showing 5 changed files with 156 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018 IBM Corp. All Rights Reserved.
* (C) Copyright IBM Corp. 2019.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -40,6 +40,8 @@ public class ClassifyReturn extends GenericModel {
private List<ContractTerms> contractTerms;
@SerializedName("payment_terms")
private List<PaymentTerms> paymentTerms;
@SerializedName("contract_currencies")
private List<ContractCurrencies> contractCurrencies;
private List<Tables> tables;
@SerializedName("document_structure")
private DocStructure documentStructure;
Expand Down Expand Up @@ -116,7 +118,7 @@ public List<ContractAmts> getContractAmounts() {
/**
* Gets the terminationDates.
*
* The date or dates on which the document is to be terminated.
* The dates on which the document is to be terminated.
*
* @return the terminationDates
*/
Expand All @@ -127,7 +129,7 @@ public List<TerminationDates> getTerminationDates() {
/**
* Gets the contractTypes.
*
* The document's contract type or types as declared in the document.
* The contract type as declared in the document.
*
* @return the contractTypes
*/
Expand All @@ -138,7 +140,7 @@ public List<ContractTypes> getContractTypes() {
/**
* Gets the contractTerms.
*
* The duration or durations of the contract.
* The durations of the contract.
*
* @return the contractTerms
*/
Expand All @@ -149,14 +151,25 @@ public List<ContractTerms> getContractTerms() {
/**
* Gets the paymentTerms.
*
* The document's payment duration or durations.
* The document's payment durations.
*
* @return the paymentTerms
*/
public List<PaymentTerms> getPaymentTerms() {
return paymentTerms;
}

/**
* Gets the contractCurrencies.
*
* The contract currencies as declared in the document.
*
* @return the contractCurrencies
*/
public List<ContractCurrencies> getContractCurrencies() {
return contractCurrencies;
}

/**
* Gets the tables.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* (C) Copyright IBM Corp. 2019.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.ibm.watson.compare_comply.v1.model;

import java.util.List;

import com.google.gson.annotations.SerializedName;
import com.ibm.cloud.sdk.core.service.model.GenericModel;

/**
* The contract currencies that are declared in the document.
*/
public class ContractCurrencies extends GenericModel {

/**
* The confidence level in the identification of the contract currency.
*/
public interface ConfidenceLevel {
/** High. */
String HIGH = "High";
/** Medium. */
String MEDIUM = "Medium";
/** Low. */
String LOW = "Low";
}

@SerializedName("confidence_level")
private String confidenceLevel;
private String text;
@SerializedName("text_normalized")
private String textNormalized;
@SerializedName("provenance_ids")
private List<String> provenanceIds;
private Location location;

/**
* Gets the confidenceLevel.
*
* The confidence level in the identification of the contract currency.
*
* @return the confidenceLevel
*/
public String getConfidenceLevel() {
return confidenceLevel;
}

/**
* Gets the text.
*
* The contract currency.
*
* @return the text
*/
public String getText() {
return text;
}

/**
* Gets the textNormalized.
*
* The normalized form of the contract currency, which is listed as a string in
* [ISO-4217](https://www.iso.org/iso-4217-currency-codes.html) format. This element is optional; it is returned only
* if normalized text exists.
*
* @return the textNormalized
*/
public String getTextNormalized() {
return textNormalized;
}

/**
* Gets the provenanceIds.
*
* Hashed values that you can send to IBM to provide feedback or receive support.
*
* @return the provenanceIds
*/
public List<String> getProvenanceIds() {
return provenanceIds;
}

/**
* Gets the location.
*
* The numeric location of the identified element in the document, represented with two integers labeled `begin` and
* `end`.
*
* @return the location
*/
public Location getLocation() {
return location;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class CompareComplyServiceIT extends CompareComplyServiceTest {
private static final String RESOURCE = "src/test/resources/compare_comply/";
private static final File CONTRACT_A = new File(RESOURCE + "contract-a.pdf");
private static final File CONTRACT_B = new File(RESOURCE + "contract-b.pdf");
private static final File TABLE_FILE = new File(RESOURCE + "test-table.pdf");
private static final File TABLE_FILE = new File(RESOURCE + "test-table.png");
private static final File INPUT_CREDENTIALS_FILE =
new File(RESOURCE + "cloud-object-storage-credentials-input.json");
private static final File OUTPUT_CREDENTIALS_FILE =
Expand Down Expand Up @@ -92,7 +92,7 @@ public void testClassifyElements() throws FileNotFoundException {
public void testExtractTables() throws FileNotFoundException {
ExtractTablesOptions extractTablesOptions = new ExtractTablesOptions.Builder()
.file(TABLE_FILE)
.fileContentType(HttpMediaType.APPLICATION_PDF)
.fileContentType("image/png")
.build();
TableReturn response = service.extractTables(extractTablesOptions).execute().getResult();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.ibm.watson.compare_comply.v1.model.CompareDocumentsOptions;
import com.ibm.watson.compare_comply.v1.model.CompareReturn;
import com.ibm.watson.compare_comply.v1.model.ContractAmts;
import com.ibm.watson.compare_comply.v1.model.ContractCurrencies;
import com.ibm.watson.compare_comply.v1.model.ContractTerms;
import com.ibm.watson.compare_comply.v1.model.ContractType;
import com.ibm.watson.compare_comply.v1.model.ConvertToHtmlOptions;
Expand Down Expand Up @@ -618,14 +619,14 @@ public void testClassifyElements() throws FileNotFoundException, InterruptedExce
assertEquals(ROW_INDEX_END, response.getTables().get(0).getBodyCells().get(0).getRowIndexEnd());
assertEquals(COLUMN_INDEX_BEGIN, response.getTables().get(0).getBodyCells().get(0).getColumnIndexBegin());
assertEquals(COLUMN_INDEX_END, response.getTables().get(0).getBodyCells().get(0).getColumnIndexEnd());
assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getRowHeaderIds().get(0).getId());
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getRowHeaderTexts().get(0).getText());
assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getRowHeaderIds().get(0));
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getRowHeaderTexts().get(0));
assertEquals(TEXT_NORMALIZED,
response.getTables().get(0).getBodyCells().get(0).getRowHeaderTextsNormalized().get(0).getTextNormalized());
assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderIds().get(0).getId());
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTexts().get(0).getText());
response.getTables().get(0).getBodyCells().get(0).getRowHeaderTextsNormalized().get(0));
assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderIds().get(0));
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTexts().get(0));
assertEquals(TEXT_NORMALIZED,
response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTextsNormalized().get(0).getTextNormalized());
response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTextsNormalized().get(0));
assertEquals(TYPE, response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getType());
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getText());
assertEquals(BEGIN,
Expand Down Expand Up @@ -721,6 +722,12 @@ public void testClassifyElements() throws FileNotFoundException, InterruptedExce
assertEquals(PROVENANCE_ID, response.getPaymentTerms().get(0).getProvenanceIds().get(0));
assertEquals(BEGIN, response.getPaymentTerms().get(0).getLocation().getBegin());
assertEquals(END, response.getPaymentTerms().get(0).getLocation().getEnd());
assertEquals(ContractCurrencies.ConfidenceLevel.HIGH, response.getContractCurrencies().get(0).getConfidenceLevel());
assertEquals(TEXT, response.getContractCurrencies().get(0).getText());
assertEquals(TEXT_NORMALIZED, response.getContractCurrencies().get(0).getTextNormalized());
assertEquals(PROVENANCE_ID, response.getContractCurrencies().get(0).getProvenanceIds().get(0));
assertEquals(BEGIN, response.getContractCurrencies().get(0).getLocation().getBegin());
assertEquals(END, response.getContractCurrencies().get(0).getLocation().getEnd());
}

@Test
Expand Down Expand Up @@ -778,14 +785,14 @@ public void testExtractTables() throws FileNotFoundException, InterruptedExcepti
assertEquals(ROW_INDEX_END, response.getTables().get(0).getBodyCells().get(0).getRowIndexEnd());
assertEquals(COLUMN_INDEX_BEGIN, response.getTables().get(0).getBodyCells().get(0).getColumnIndexBegin());
assertEquals(COLUMN_INDEX_END, response.getTables().get(0).getBodyCells().get(0).getColumnIndexEnd());
assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getRowHeaderIds().get(0).getId());
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getRowHeaderTexts().get(0).getText());
assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getRowHeaderIds().get(0));
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getRowHeaderTexts().get(0));
assertEquals(TEXT_NORMALIZED,
response.getTables().get(0).getBodyCells().get(0).getRowHeaderTextsNormalized().get(0).getTextNormalized());
assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderIds().get(0).getId());
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTexts().get(0).getText());
response.getTables().get(0).getBodyCells().get(0).getRowHeaderTextsNormalized().get(0));
assertEquals(ID, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderIds().get(0));
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTexts().get(0));
assertEquals(TEXT_NORMALIZED,
response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTextsNormalized().get(0).getTextNormalized());
response.getTables().get(0).getBodyCells().get(0).getColumnHeaderTextsNormalized().get(0));
assertEquals(TYPE, response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getType());
assertEquals(TEXT, response.getTables().get(0).getBodyCells().get(0).getAttributes().get(0).getText());
assertEquals(BEGIN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,5 +350,19 @@
"end": 1
}
}
],
"contract_currencies": [
{
"confidence_level": "High",
"text": "text",
"text_normalized": "text_normalized",
"provenance_ids": [
"provenance_id"
],
"location": {
"begin": 0,
"end": 1
}
}
]
}

0 comments on commit 985b052

Please sign in to comment.