This API will extract the KV pattern for the given word in the given input HOCR file.
Request Method POST
Input Parameters
Input Parameter | Values | Descriptions |
batchClassIdentifier | This should not be empty like BC10 | The parameter used to define the batch class |
fieldValue | This should not be empty. | This parameter is used for extracting the Key Value pattern for the word provided. |
Web Service URL: http://{serverName}:{port}/dcma/rest/extractFieldFromHocr
CheckList:
- fieldValue is provided for the word on which Key Value pattern would be found.
Sample client code using apache commons http client:-
private static void extractFieldFromHocr() { HttpClient client = new HttpClient(); String url = "http://localhost:8080/dcma/rest/extractFieldFromHocr"; PostMethod mPost = new PostMethod(url); // Adding HOCR file for extracting field File file1 = new File("C:\\sample\\US-Invoice_HOCR.xml"); Part[] parts = new Part[3]; try { parts[0] = new FilePart(file1.getName(), file1); // Adding field value for extracting Key Value Pattern. parts[1] = new StringPart("fieldValue", "APPLICATION"); String batchClassIdentifier = "BC4"; parts[2] = new StringPart("batchClassIdentifier", batchClassIdentifier); MultipartRequestEntity entity = new MultipartRequestEntity(parts, mPost.getParams()); mPost.setRequestEntity(entity); int statusCode = client.executeMethod(mPost); if (statusCode == 200) { System.out.println("Web service executed successfully."); String responseBody = mPost.getResponseBodyAsString(); System.out.println(statusCode + " *** " + responseBody); } else if (statusCode == 403) { System.out.println("Invalid username/password."); } else { System.out.println(mPost.getResponseBodyAsString()); } } catch (FileNotFoundException e) { System.err.println("File not found for processing."); } catch (HttpException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (mPost != null) { mPost.releaseConnection(); } } }