This API will classify the input HOCR according to the batch class identifier provided. This API will require the following plugins “SEARCH_CLASSIFICATION_PLUGIN”, “DOCUMENT_ASSEMBLER_PLUGIN” and the learning must be done on the batch class. If any batch class doesn’t have the mentioned plugins then the API will not work.

Request Method POST

Input Parameters

Input Parameter Values Descriptions
batchClassId This value should not be empty and it should be batch class identifier like BC1. This parameter is used for providing batch class identifier on which HOCR classification will be performed.

 

Web Service URL: http://{serverName}:{port}/dcma/rest/classifyHocr

Checklist:

  1. Input file should be hocr xml file only.
  2. batchClassId should be valid batch class identifier and must have the plugins “SEARCH_CLASSIFICATION_PLUGIN” and “DOCUMENT_ASSEMBLER_PLUGIN” configured.

 

Sample client code using apache commons http client:-

private static void classifyHocr() {
		HttpClient client = new HttpClient();
		String url = "http://localhost:8080/dcma/rest/classifyHocr";
		PostMethod mPost = new PostMethod(url);
		File file1 = new File("C:\\sample\\US-Invoice_HOCR.xml");
		Part[] parts = new Part[2];
		try {
			parts[0] = new FilePart(file1.getName(), file1);
			String batchClass = "BC5";
			parts[1] = new StringPart("batchClassId", batchClass);
			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();
			}
		}
	}

Was this article helpful to you?

Engineering

Comments are closed.