Skip to content

Commit 80be9a0

Browse files
author
Karthikeyan
authored
Add support for Amazon Textract (#1049)
* Add support for Amazon Textract * [CircleCIScripts] Add support for Amazon Textract
1 parent 05800d0 commit 80be9a0

File tree

110 files changed

+16493
-49
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+16493
-49
lines changed

.circleci/config.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,6 +1408,16 @@ workflows:
14081408
only:
14091409
- master
14101410
- develop
1411+
- integrationtest:
1412+
name: textract
1413+
testmodule: aws-android-sdk-textract-test
1414+
requires:
1415+
- pre_integrationtest
1416+
filters:
1417+
branches:
1418+
only:
1419+
- master
1420+
- develop
14111421
- integrationtest:
14121422
name: mobile-client
14131423
testmodule: aws-android-sdk-mobile-client
@@ -1493,6 +1503,7 @@ workflows:
14931503
# - kinesisvideo-archivedmedia
14941504
# - kinesisvideo
14951505
- mobile-client
1506+
- textract
14961507
- translate
14971508
- transcribe
14981509
- sqs
@@ -1761,6 +1772,16 @@ workflows:
17611772
ignore: /.*/
17621773
tags:
17631774
only: /^(release|beta)_v[0-9]+.[0-9]+.[0-9]+$/
1775+
- integrationtest:
1776+
name: textract
1777+
testmodule: aws-android-sdk-textract-test
1778+
requires:
1779+
- pre_integrationtest
1780+
filters:
1781+
branches:
1782+
ignore: /.*/
1783+
tags:
1784+
only: /^(release|beta)_v[0-9]+.[0-9]+.[0-9]+$/
17641785
- integrationtest:
17651786
name: translate
17661787
testmodule: aws-android-sdk-translate-test
@@ -1856,6 +1877,7 @@ workflows:
18561877
# - kinesisvideo-archivedmedia
18571878
# - kinesisvideo
18581879
- mobile-client
1880+
- textract
18591881
- translate
18601882
- transcribe
18611883
- sqs

.idea/modules.xml

Lines changed: 71 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
* **Amazon SageMaker**
88
* Amazon SageMaker provides every developer and data scientist with the ability to build, train, and deploy machine learning models quickly. Amazon SageMaker is a fully-managed service that covers the entire machine learning workflow to label and prepare your data, choose an algorithm, train the model, tune and optimize it for deployment, make predictions, and take action. Your models get to production faster with much less effort and lower cost. See [Amazon SageMaker Documentation](https://aws.amazon.com/sagemaker/) for more details.
9+
10+
* **Amazon Textract**
11+
* Amazon Textract is a service that automatically extracts text and data from scanned documents. Amazon Textract goes beyond simple optical character recognition (OCR) to also identify the contents of fields in forms and information stored in tables. See [Amazon Textract Documentation](https://aws.amazon.com/textract/) for more details.
912

1013
### Bug Fixes
1114

CircleciScripts/ReleaseConfiguration.json

Lines changed: 55 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,47 @@
66
"javdoc.doctitle" : "AWS SDK for Android - $sdkVersion"
77
},
88
modules:[
9-
"aws-android-sdk-apigateway-core",
10-
"aws-android-sdk-auth-core",
11-
"aws-android-sdk-auth-facebook",
12-
"aws-android-sdk-auth-google",
13-
// "aws-android-sdk-auth-ui",
14-
"aws-android-sdk-auth-userpools",
15-
"aws-android-sdk-autoscaling",
16-
"aws-android-sdk-cloudwatch",
17-
"aws-android-sdk-cognito",
18-
// "aws-android-sdk-cognitoauth",
19-
"aws-android-sdk-cognitoidentityprovider",
20-
"aws-android-sdk-comprehend",
21-
"aws-android-sdk-core",
22-
"aws-android-sdk-ddb",
23-
"aws-android-sdk-ddb-document",
24-
"aws-android-sdk-ddb-mapper",
25-
"aws-android-sdk-ec2",
26-
"aws-android-sdk-elb",
27-
"aws-android-sdk-iot",
28-
"aws-android-sdk-kinesis",
29-
"aws-android-sdk-kinesisvideo",
30-
"aws-android-sdk-kinesisvideo-archivedmedia",
31-
"aws-android-sdk-kms",
32-
"aws-android-sdk-lambda",
33-
"aws-android-sdk-lex",
34-
"aws-android-sdk-logs",
35-
"aws-android-sdk-machinelearning",
36-
"aws-android-sdk-mobile-client",
37-
"aws-android-sdk-pinpoint",
38-
"aws-android-sdk-polly",
39-
"aws-android-sdk-rekognition",
40-
"aws-android-sdk-s3",
41-
"aws-android-sdk-sdb",
42-
"aws-android-sdk-ses",
43-
"aws-android-sdk-sns",
44-
"aws-android-sdk-sqs",
45-
"aws-android-sdk-transcribe",
46-
"aws-android-sdk-translate",
47-
"aws-android-sdk-mobileanalytics",
48-
"aws-android-sdk-sagemaker-runtime"
9+
"aws-android-sdk-apigateway-core",
10+
"aws-android-sdk-auth-core",
11+
"aws-android-sdk-auth-facebook",
12+
"aws-android-sdk-auth-google",
13+
// "aws-android-sdk-auth-ui",
14+
"aws-android-sdk-auth-userpools",
15+
"aws-android-sdk-autoscaling",
16+
"aws-android-sdk-cloudwatch",
17+
"aws-android-sdk-cognito",
18+
// "aws-android-sdk-cognitoauth",
19+
"aws-android-sdk-cognitoidentityprovider",
20+
"aws-android-sdk-comprehend",
21+
"aws-android-sdk-core",
22+
"aws-android-sdk-ddb",
23+
"aws-android-sdk-ddb-document",
24+
"aws-android-sdk-ddb-mapper",
25+
"aws-android-sdk-ec2",
26+
"aws-android-sdk-elb",
27+
"aws-android-sdk-iot",
28+
"aws-android-sdk-kinesis",
29+
"aws-android-sdk-kinesisvideo",
30+
"aws-android-sdk-kinesisvideo-archivedmedia",
31+
"aws-android-sdk-kms",
32+
"aws-android-sdk-lambda",
33+
"aws-android-sdk-lex",
34+
"aws-android-sdk-logs",
35+
"aws-android-sdk-machinelearning",
36+
"aws-android-sdk-mobile-client",
37+
"aws-android-sdk-pinpoint",
38+
"aws-android-sdk-polly",
39+
"aws-android-sdk-rekognition",
40+
"aws-android-sdk-s3",
41+
"aws-android-sdk-sagemaker-runtime",
42+
"aws-android-sdk-sdb",
43+
"aws-android-sdk-ses",
44+
"aws-android-sdk-sns",
45+
"aws-android-sdk-sqs",
46+
"aws-android-sdk-textract",
47+
"aws-android-sdk-transcribe",
48+
"aws-android-sdk-translate",
49+
"aws-android-sdk-mobileanalytics"
4950
],
5051
packages : [
5152
"com.amazonaws",
@@ -238,6 +239,12 @@
238239
"${service.prefix}.rekognition*"
239240
]
240241
},
242+
{
243+
title : "Amazon SageMaker Runtime" ,
244+
packages : [
245+
"${service.prefix}.sagemakerruntime*"
246+
]
247+
},
241248
{
242249
title : "Amazon SNS" ,
243250
packages : [
@@ -266,7 +273,14 @@
266273
title : "Amazon SimpleDB" ,
267274
packages : [
268275
"${service.prefix}.simpledb*"
269-
] },
276+
]
277+
},
278+
{
279+
title : "Amazon Textract" ,
280+
packages : [
281+
"${service.prefix}.textract*"
282+
]
283+
},
270284
{
271285
title : "Amazon Transcribe" ,
272286
packages : [
@@ -296,12 +310,6 @@
296310
packages : [
297311
"com.amazonaws*"
298312
]
299-
},
300-
{
301-
title : "Amazon SageMaker Runtime" ,
302-
packages : [
303-
"${service.prefix}.sagemakerruntime*"
304-
]
305313
}
306314
],
307315
otheroptions : {

aws-android-sdk-core/src/main/java/com/amazonaws/internal/config/InternalConfig.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ private static Map<String, HttpClientConfig> getDefaultHttpClients() {
126126
ret.put("AWSKinesisVideoArchivedMediaClient", new HttpClientConfig("kinesisvideo"));
127127
//signer uses the servicename 'sagemaker' for Sagemaker Runtime
128128
ret.put("AmazonSageMakerRuntimeClient", new HttpClientConfig("sagemaker"));
129+
ret.put("AmazonTextractClient", new HttpClientConfig("textract"));
129130
return ret;
130131
}
131132

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
apply plugin: 'com.android.library'
2+
3+
android {
4+
compileSdkVersion 27
5+
6+
defaultConfig {
7+
minSdkVersion 14
8+
targetSdkVersion 27
9+
versionCode 1
10+
versionName "1.0"
11+
12+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13+
}
14+
15+
buildTypes {
16+
release {
17+
minifyEnabled false
18+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
19+
}
20+
}
21+
}
22+
23+
dependencies {
24+
implementation fileTree(dir: 'libs', include: ['*.jar'])
25+
26+
implementation 'com.android.support:appcompat-v7:27.0.0'
27+
testImplementation 'junit:junit:4.12'
28+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
29+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
30+
31+
api (project(":aws-android-sdk-textract")) {
32+
exclude group: "com.google.android", module: "android"
33+
}
34+
androidTestImplementation project(":aws-android-sdk-testutils")
35+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright 2019-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package com.amazonaws.services.textract;
17+
18+
import android.support.test.InstrumentationRegistry;
19+
import android.support.test.runner.AndroidJUnit4;
20+
21+
import com.amazonaws.services.textract.model.AnalyzeDocumentRequest;
22+
import com.amazonaws.services.textract.model.AnalyzeDocumentResult;
23+
import com.amazonaws.services.textract.model.Block;
24+
import com.amazonaws.services.textract.model.Document;
25+
import com.amazonaws.services.textract.model.S3Object;
26+
import com.amazonaws.testutils.AWSTestBase;
27+
28+
import org.json.JSONException;
29+
import org.json.JSONObject;
30+
import org.junit.Before;
31+
import org.junit.Test;
32+
import org.junit.runner.RunWith;
33+
34+
import java.nio.ByteBuffer;
35+
import java.nio.charset.StandardCharsets;
36+
import java.util.List;
37+
38+
import static org.junit.Assert.assertEquals;
39+
40+
/**
41+
* Instrumented test, which will execute on an Android device.
42+
*
43+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
44+
*/
45+
@RunWith(AndroidJUnit4.class)
46+
public class AmazonTextractIntegrationTest extends AWSTestBase {
47+
48+
private AmazonTextractClient textractClient;
49+
50+
/** Package name in testconfiguration.json */
51+
protected static final String PACKAGE_NAME = InstrumentationRegistry.getTargetContext().
52+
getResources().getString(R.string.package_name);
53+
54+
public static JSONObject getPackageConfigure() {
55+
return getPackageConfigure(PACKAGE_NAME);
56+
}
57+
58+
@Before
59+
public void setUp() {
60+
setUpCredentials();
61+
textractClient = new AmazonTextractClient(credentials);
62+
}
63+
64+
@Test
65+
public void testAnalyzeDocumentInS3() throws JSONException {
66+
AnalyzeDocumentRequest request = new AnalyzeDocumentRequest()
67+
.withFeatureTypes("TABLES", "FORMS")
68+
.withDocument(new Document().withS3Object(new S3Object()
69+
.withName(getPackageConfigure().getString("s3_key_name"))
70+
.withBucket(getPackageConfigure().getString("s3_bucket_name"))));
71+
72+
AnalyzeDocumentResult result = textractClient.analyzeDocument(request);
73+
assertEquals(new Integer(1), result.getDocumentMetadata().getPages());
74+
75+
List<Block> blocks = result.getBlocks();
76+
assert blocks.size() > 0;
77+
}
78+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.amazonaws.services.textract" >
3+
<uses-permission android:name="android.permission.INTERNET"/>
4+
</manifest>

0 commit comments

Comments
 (0)