/// <summary> /// Initializes a new instance of the <see cref="RecognizedForm"/> class. /// </summary> /// <param name="formType">The type of form the model identified the submitted form to be.</param> /// <param name="pageRange">The range of pages this form spans.</param> /// <param name="fields">A dictionary of the fields recognized from the input document.</param> /// <param name="pages">A list of pages describing the recognized form elements present in the input document.</param> internal RecognizedForm(string formType, FormPageRange pageRange, IReadOnlyDictionary <string, FormField> fields, IReadOnlyList <FormPage> pages) { FormType = formType; PageRange = pageRange; Fields = fields; Pages = pages; }
/// <summary> /// Initializes a new instance of the <see cref="FormRecognizer.Models.RecognizedForm"/> class. /// </summary> /// <param name="formType">The type of form the model identified the submitted form to be.</param> /// <param name="pageRange">The range of pages this form spans.</param> /// <param name="fields">A dictionary of the fields recognized from the input document.</param> /// <param name="pages">A list of pages describing the recognized form elements present in the input document.</param> /// <param name="modelId">Model identifier of model used to analyze form if not using a prebuilt model.</param> /// <param name="formTypeConfidence">Confidence on the type of form the labeled model identified the submitted form to be.</param> /// <returns>A new <see cref="FormRecognizer.Models.RecognizedForm"/> instance for mocking.</returns> public static RecognizedForm RecognizedForm(string formType, FormPageRange pageRange, IReadOnlyDictionary <string, FormField> fields, IReadOnlyList <FormPage> pages, string modelId, float?formTypeConfidence) { fields = fields?.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); pages = pages?.ToList(); return(new RecognizedForm(formType, pageRange, fields, pages, modelId, formTypeConfidence)); }
internal RecognizedForm(DocumentResult_internal documentResult, IReadOnlyList <PageResult_internal> pageResults, IReadOnlyList <ReadResult_internal> readResults) { // Recognized form from a model trained with labels. FormType = documentResult.DocType; PageRange = new FormPageRange(documentResult.PageRange); Fields = PopulateFields(documentResult.Fields, readResults); Pages = PopulatePages(pageResults, readResults); }
/// <summary> /// Initializes a new instance of the <see cref="RecognizedForm"/> class. /// </summary> /// <param name="formType">The type of form the model identified the submitted form to be.</param> /// <param name="pageRange">The range of pages this form spans.</param> /// <param name="fields">A dictionary of the fields recognized from the input document.</param> /// <param name="pages">A list of pages describing the recognized form elements present in the input document.</param> /// <param name="modelId">Model identifier of model used to analyze form if not using a prebuilt model.</param> /// <param name="confidence">Confidence on the type of form the model identified the submitted form to be.</param> internal RecognizedForm(string formType, FormPageRange pageRange, IReadOnlyDictionary <string, FormField> fields, IReadOnlyList <FormPage> pages, string modelId, float?confidence) { FormType = formType; PageRange = pageRange; Fields = fields; Pages = pages; ModelId = modelId; FormTypeConfidence = confidence; }
internal RecognizedForm(PageResult_internal pageResult, IReadOnlyList <ReadResult_internal> readResults) { // Recognized form from a model trained without labels. FormType = $"form-{pageResult.ClusterId}"; PageRange = new FormPageRange(pageResult.Page, pageResult.Page); Fields = ConvertFields(pageResult.Page, pageResult.KeyValuePairs, readResults); Pages = ConvertPages(new List <PageResult_internal>() { pageResult }, readResults); }
internal RecognizedForm(DocumentResult_internal documentResult, IReadOnlyList <PageResult_internal> pageResults, IReadOnlyList <ReadResult_internal> readResults) { // Recognized form from a model trained with labels. FormType = documentResult.DocType; // TODO: validate that PageRange.Length == 2. // https://github.com/Azure/azure-sdk-for-net/issues/10547 PageRange = new FormPageRange(documentResult.PageRange[0], documentResult.PageRange[1]); Fields = ConvertSupervisedFields(documentResult.Fields, readResults); Pages = ConvertSupervisedPages(pageResults, readResults); }
internal RecognizedForm(PageResult_internal pageResult, IReadOnlyList <ReadResult_internal> readResults, int pageIndex) { // Recognized form from a model trained without labels. FormType = $"form-{pageResult.ClusterId}"; PageRange = new FormPageRange(pageResult.Page, pageResult.Page); Fields = ConvertUnsupervisedFields(pageResult.Page, pageResult.KeyValuePairs, readResults); // For models trained without labels, the service treats every page as a separate form, so // we end up with a single page per form. Pages = new List <FormPage> { new FormPage(pageResult, readResults, pageIndex) }; }
internal RecognizedForm(DocumentResult documentResult, IReadOnlyList <PageResult> pageResults, IReadOnlyList <ReadResult> readResults, string modelId) { // Recognized form from a model trained with labels. FormType = documentResult.DocType; PageRange = new FormPageRange(documentResult.PageRange[0], documentResult.PageRange[1]); // documentResult.Fields is required and not null, according to the swagger file, but it's not // present when a blank receipt is submitted for recognition. Fields = documentResult.Fields == null ? new Dictionary <string, FormField>() : ConvertSupervisedFields(documentResult.Fields, readResults); Pages = ConvertSupervisedPages(pageResults, readResults); ModelId = documentResult.ModelId.HasValue ? documentResult.ModelId.Value.ToString() : modelId; FormTypeConfidence = documentResult.DocTypeConfidence ?? Constants.DefaultConfidenceValue; }
internal RecognizedForm(DocumentResult_internal documentResult, IReadOnlyList <PageResult_internal> pageResults, IReadOnlyList <ReadResult_internal> readResults) { // Recognized form from a model trained with labels. FormType = documentResult.DocType; // TODO: validate that PageRange.Length == 2. // https://github.com/Azure/azure-sdk-for-net/issues/10547 PageRange = new FormPageRange(documentResult.PageRange[0], documentResult.PageRange[1]); // documentResult.Fields is required and not null, according to the swagger file, but it's not // present when a blank receipt is submitted for recognition. Fields = documentResult.Fields == null ? new Dictionary <string, FormField>() : ConvertSupervisedFields(documentResult.Fields, readResults); Pages = ConvertSupervisedPages(pageResults, readResults); }
internal RecognizedForm(DocumentResult documentResult, IReadOnlyList <PageResult> pageResults, IReadOnlyList <ReadResult> readResults, string modelId, bool isBusinessCards) { // Recognized form from a model trained with labels. FormType = documentResult.DocType; // TODO: validate that PageRange.Length == 2. // https://github.com/Azure/azure-sdk-for-net/issues/10547 PageRange = new FormPageRange(documentResult.PageRange[0], documentResult.PageRange[1]); // documentResult.Fields is required and not null, according to the swagger file, but it's not // present when a blank receipt is submitted for recognition. Fields = documentResult.Fields == null ? new Dictionary <string, FormField>() : ConvertSupervisedFields(documentResult.Fields, readResults, isBusinessCards); Pages = ConvertSupervisedPages(pageResults, readResults); ModelId = documentResult.ModelId.HasValue ? documentResult.ModelId.Value.ToString() : modelId; FormTypeConfidence = documentResult.DocTypeConfidence ?? Constants.DefaultConfidenceValue; }
public static RecognizedForm RecognizedForm(string formType, FormPageRange pageRange, IReadOnlyDictionary <string, FormField> fields, IReadOnlyList <FormPage> pages) => RecognizedForm(formType, pageRange, fields, pages, default, default);