formrecognizer

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2023 License: Apache-2.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Go FormRecognizer

Early release of Golang wrapper for Microsoft's Form Recognizer API.

This library provides a Go client for Microsoft Form Recognizer API.

Installation:

go get github.com/coggsfl/formrecognizer

Form Recognier example usage:

package main

import (
	"context"
	"fmt"
	formrecognizer "github.com/coggsfl/formrecognizer"
)

func main() {

	form_recognizer_client := formrecognizer.NewClient("your Form Recognizer Key", "https://your Form Recognizer Endpoint", "api version - ie. 2023-02-28-preview")
	filename = "./local_document.pdf"
	form_recognizer_results := form_recognizer_client.Begin_analyze_document("prebuilt-layout", filename, "32")

	for pageNbr, pageContent := range form_recognizer_results.AnalyzeResult.Pages {
	fmt.Printf("\nPage: %v\n", pageNbr+1)
	for _, line := range pageContent.Lines {
		fmt.Printf("Line: %v\n", line.Content)
	}

	}

	for _, tableContent := range form_recognizer_results.AnalyzeResult.Tables {
		for _, cell := range tableContent.Cells {
			fmt.Printf("Table: %v\n", cell.Content)
		}
	}

}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnalyzeResult added in v0.0.2

type AnalyzeResult struct {
	APIVersion      string `json:"apiVersion"`
	ModelID         string `json:"modelId"`
	StringIndexType string `json:"stringIndexType"`
	Content         string `json:"content"`
	Pages           `json:"pages"`
	Tables          `json:"tables"`
	Paragraphs      `json:"paragraphs"`
	Styles          []any `json:"styles"`
}

type Cell added in v0.0.2

type Cell struct {
	Kind            string `json:"kind,omitempty"`
	RowIndex        int    `json:"rowIndex"`
	ColumnIndex     int    `json:"columnIndex"`
	Content         string `json:"content"`
	BoundingRegions []struct {
		PageNumber int       `json:"pageNumber"`
		Polygon    []float64 `json:"polygon"`
	} `json:"boundingRegions"`
	Spans []struct {
		Offset int `json:"offset"`
		Length int `json:"length"`
	} `json:"spans"`
	RowSpan int `json:"rowSpan,omitempty"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is Forms Recognizer client.

func DocumentAnalysisClient added in v0.0.2

func DocumentAnalysisClient(apiKey string, endpoint string, api_version string) *Client

NewClient creates new Forms Recognizer API client.

func (*Client) Begin_analyze_document

func (c *Client) Begin_analyze_document(model_id string, document *bufio.Reader, pages string) AnalyzeResult

type ClientConfig

type ClientConfig struct {
	Endpoint   string
	APIVersion string
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

Client is Forms Recognizer client.

func DefaultConfig

func DefaultConfig(credential string, endpoint string, api_version string) ClientConfig

type FormGenResponse

type FormGenResponse struct {
	Status              string        `json:"status"`
	CreatedDateTime     time.Time     `json:"createdDateTime"`
	LastUpdatedDateTime time.Time     `json:"lastUpdatedDateTime"`
	AnalyzeResults      AnalyzeResult `json:"analyzeResult"`
}

type Page added in v0.0.2

type Page struct {
	PageNumber int     `json:"pageNumber"`
	Angle      float64 `json:"angle"`
	Width      float64 `json:"width"`
	Height     float64 `json:"height"`
	Unit       string  `json:"unit"`
	Words      []struct {
		Content    string    `json:"content"`
		Polygon    []float64 `json:"polygon"`
		Confidence float64   `json:"confidence"`
		Span       struct {
			Offset int `json:"offset"`
			Length int `json:"length"`
		} `json:"span"`
	} `json:"words"`
	SelectionMarks []struct {
		State      string    `json:"state"`
		Polygon    []float64 `json:"polygon"`
		Confidence float64   `json:"confidence"`
		Span       struct {
			Offset int `json:"offset"`
			Length int `json:"length"`
		} `json:"span"`
	} `json:"selectionMarks"`
	Lines []struct {
		Content string    `json:"content"`
		Polygon []float64 `json:"polygon"`
		Spans   []struct {
			Offset int `json:"offset"`
			Length int `json:"length"`
		} `json:"spans"`
	} `json:"lines"`
	Spans []struct {
		Offset int `json:"offset"`
		Length int `json:"length"`
	} `json:"spans"`
	Kind string `json:"kind"`
}

type Pages added in v0.0.2

type Pages []Page

type Paragraph added in v0.0.2

type Paragraph struct {
	Spans []struct {
		Offset int `json:"offset"`
		Length int `json:"length"`
	} `json:"spans"`
	BoundingRegions []struct {
		PageNumber int       `json:"pageNumber"`
		Polygon    []float64 `json:"polygon"`
	} `json:"boundingRegions"`
	Role    string `json:"role,omitempty"`
	Content string `json:"content"`
}

type Paragraphs added in v0.0.2

type Paragraphs []Paragraph

type Table added in v0.0.2

type Table struct {
	RowCount        int    `json:"rowCount"`
	ColumnCount     int    `json:"columnCount"`
	Cells           []Cell `json:"cells"`
	BoundingRegions []struct {
		PageNumber int       `json:"pageNumber"`
		Polygon    []float64 `json:"polygon"`
	} `json:"boundingRegions"`
	Spans []struct {
		Offset int `json:"offset"`
		Length int `json:"length"`
	} `json:"spans"`
}

type Tables added in v0.0.2

type Tables []Table

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL