Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] Modify Pages type #18260

Merged
4 commits merged into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sdk/formrecognizer/Azure.AI.FormRecognizer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Renamed the model `Appearance` to `TextAppearance`.
- Renamed the model `Style` to `TextStyle`.
- Renamed the extensible enum `TextStyle` to `TextStyleName`.
- Changed object type for property `Pages` under `RecognizeContentOptions` from `IEnumerable` to `IList`.
maririos marked this conversation as resolved.
Show resolved Hide resolved

## 3.1.0-beta.1 (2020-11-23)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public partial class RecognizeContentOptions
public RecognizeContentOptions() { }
public Azure.AI.FormRecognizer.FormContentType? ContentType { get { throw null; } set { } }
public string Language { get { throw null; } set { } }
public System.Collections.Generic.IEnumerable<string> Pages { get { throw null; } set { } }
public System.Collections.Generic.IList<string> Pages { get { throw null; } }
}
public partial class RecognizeCustomFormsOptions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public virtual RecognizeContentOperation StartRecognizeContent(Stream form, Reco
formContentType.ConvertToContentType1(),
form,
recognizeContentOptions.Language == null ? (Language?)null : recognizeContentOptions.Language,
recognizeContentOptions.Pages,
recognizeContentOptions.Pages.Count == 0 ? null : recognizeContentOptions.Pages,
cancellationToken);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);

Expand Down Expand Up @@ -181,7 +181,7 @@ public virtual async Task<RecognizeContentOperation> StartRecognizeContentAsync(
formContentType.ConvertToContentType1(),
form,
recognizeContentOptions.Language == null ? (Language?)null : recognizeContentOptions.Language,
recognizeContentOptions.Pages,
recognizeContentOptions.Pages.Count == 0 ? null : recognizeContentOptions.Pages,
cancellationToken).ConfigureAwait(false);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);

Expand Down Expand Up @@ -217,7 +217,7 @@ public virtual RecognizeContentOperation StartRecognizeContentFromUri(Uri formUr
SourcePath sourcePath = new SourcePath() { Source = formUri.AbsoluteUri };
Response response = ServiceClient.AnalyzeLayoutAsync(
recognizeContentOptions.Language == null ? (Language?)null : recognizeContentOptions.Language,
recognizeContentOptions.Pages,
recognizeContentOptions.Pages.Count == 0 ? null : recognizeContentOptions.Pages,
sourcePath,
cancellationToken);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
Expand Down Expand Up @@ -254,7 +254,7 @@ public virtual async Task<RecognizeContentOperation> StartRecognizeContentFromUr
SourcePath sourcePath = new SourcePath() { Source = formUri.AbsoluteUri };
Response response = await ServiceClient.AnalyzeLayoutAsyncAsync(
recognizeContentOptions.Language == null ? (Language?)null : recognizeContentOptions.Language,
recognizeContentOptions.Pages,
recognizeContentOptions.Pages.Count == 0 ? null : recognizeContentOptions.Pages,
samvaity marked this conversation as resolved.
Show resolved Hide resolved
sourcePath,
cancellationToken).ConfigureAwait(false);
string location = ClientCommon.GetResponseHeader(response.Headers, Constants.OperationLocationHeader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@ public RecognizeContentOptions()
public string Language { get; set; }

/// <summary>
/// Custom page numbers for multi-page documents(PDF/TIFF). Input the number of the
/// pages you want to get OCR result. For a range of pages, use a hyphen.
/// Separate each page or range with a comma.
/// <para>
/// Custom page numbers for multi-page documents(PDF/TIFF). Input the page numbers
/// and/or ranges of pages you want to get in the result.For a range of pages, use a hyphen, like
maririos marked this conversation as resolved.
Show resolved Hide resolved
/// `Pages = {"1-3", "5-6" }`. Separate each page number or range with a comma.
maririos marked this conversation as resolved.
Show resolved Hide resolved
/// </para>
/// <para>
/// Although this collection cannot be set, it can be modified.
samvaity marked this conversation as resolved.
Show resolved Hide resolved
/// See <a href="https://docs.microsoft.com/dotnet/csharp/programming-guide/classes-and-structs/object-and-collection-initializers#collection-initializers">collection initializer</a>.
/// </para>
/// </summary>
public IEnumerable<string> Pages { get; set; }
public IList<string> Pages { get; } = new List<string>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ public async Task StartRecognizeContentWithOnePageArgument(string pages, int exp
using var stream = FormRecognizerTestEnvironment.CreateStream(TestFile.InvoiceMultipageBlank);
using (Recording.DisableRequestBodyRecording())
{
operation = await client.StartRecognizeContentAsync(stream, new RecognizeContentOptions() { Pages = new List<string> { pages } });
operation = await client.StartRecognizeContentAsync(stream, new RecognizeContentOptions() { Pages = { pages } });
}

FormPageCollection formPages = await operation.WaitForCompletionAsync(PollingInterval);
Expand All @@ -480,7 +480,7 @@ public async Task StartRecognizeContentWithMultiplePageArgument(string page1, st
using var stream = FormRecognizerTestEnvironment.CreateStream(TestFile.InvoiceMultipageBlank);
using (Recording.DisableRequestBodyRecording())
{
operation = await client.StartRecognizeContentAsync(stream, new RecognizeContentOptions() { Pages = new List<string> { page1, page2 } });
operation = await client.StartRecognizeContentAsync(stream, new RecognizeContentOptions() { Pages = { page1, page2 } });
maririos marked this conversation as resolved.
Show resolved Hide resolved
}

FormPageCollection formPages = await operation.WaitForCompletionAsync(PollingInterval);
Expand Down