Skip to content

Commit

Permalink
Update changes
Browse files Browse the repository at this point in the history
  • Loading branch information
atir-naveed-geeksltd committed May 30, 2023
1 parent 85306b3 commit da75f4c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
44 changes: 43 additions & 1 deletion Olive.Aws.Textract/AmazonTextract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ public static async Task<string> StartAnalyzeDocument(string documentKey, string
{
S3Bucket = outputBucket,
S3Prefix = prefix,

},
FeatureTypes = featureTypes,
};
Expand All @@ -274,5 +273,48 @@ public static async Task<string> StartAnalyzeDocument(string documentKey, string
throw e;
}
}

/// <summary>
/// Returns an Object containing the job status blocks and next token of the job.
/// </summary>
public static async Task<TextDetectionBlockResults> GetAnalyzeJobResultBlocks(string jobId, string nextToken = null)
{
var detectRequest = new GetDocumentAnalysisRequest()
{
JobId = jobId,
NextToken = nextToken
};
try
{
var detectTextResponse = await Client.GetDocumentAnalysisAsync(detectRequest);
return new TextDetectionBlockResults(detectTextResponse);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
throw e;
}
}
/// <summary>
/// Returns an Object containing the job status, text and next token of the job.
/// </summary>
public static async Task<TextDetectionTextResults> GetAnalyzeJobResultText(string jobId, string nextToken = null)
{
var detectTextRequest = new GetDocumentAnalysisRequest()
{
JobId = jobId,
NextToken = nextToken
};
try
{
var detectTextResponse = await Client.GetDocumentAnalysisAsync(detectTextRequest);
return new TextDetectionTextResults(detectTextResponse); ;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
throw e;
}
}
}
}
13 changes: 13 additions & 0 deletions Olive.Aws.Textract/Models.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ internal TextDetectionBlockResults(GetDocumentTextDetectionResponse response)
NextToken= response.NextToken;
JobStatus= response.JobStatus;
}
internal TextDetectionBlockResults(GetDocumentAnalysisResponse response)
{
Blocks = response.Blocks;
NextToken = response.NextToken;
JobStatus = response.JobStatus;
}
public IEnumerable<Block> Blocks { get; set; }
public string NextToken { get; set; }
public JobStatus JobStatus { get; set; }
Expand All @@ -28,6 +34,13 @@ internal TextDetectionTextResults(GetDocumentTextDetectionResponse response)
JobStatus = response.JobStatus;
}

internal TextDetectionTextResults(GetDocumentAnalysisResponse response)
{
Text = response.Blocks.Select(x => x.Text).ExceptNull().ToString("\n");
NextToken = response.NextToken;
JobStatus = response.JobStatus;
}

public string Text { get; set; }
public string NextToken { get; set; }
public JobStatus JobStatus { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Olive.Aws.Textract/Olive.Aws.Textract.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>1.0.9</Version>
<Version>1.0.10</Version>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit da75f4c

Please sign in to comment.