Merged in feature/checkbox (pull request #145)
Checkbox Primary Edge Cases * hascheckboxlogic * gen * preppinggen * exploringcheckbox * removeunselected * tests * failingtest * failintests * nomockqueryapi * db * name * nocontainer * deleterow * cnc * extradocsandupdatetextracts * moretables * appndedtables * baseversion
This commit is contained in:
@@ -20,7 +20,6 @@ import (
|
||||
"time"
|
||||
|
||||
awstextract "github.com/aws/aws-sdk-go-v2/service/textract"
|
||||
"github.com/aws/aws-sdk-go-v2/service/textract/types"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
@@ -88,7 +87,8 @@ func main() {
|
||||
allResults := []map[string]*awstextract.AnalyzeDocumentOutput{}
|
||||
allResults = make([]map[string]*awstextract.AnalyzeDocumentOutput, count)
|
||||
var wg sync.WaitGroup
|
||||
for i := range count {
|
||||
for index := range count {
|
||||
i := index
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
slog.Info("getting page", "index", i)
|
||||
@@ -103,36 +103,22 @@ func main() {
|
||||
"base": &baseResult,
|
||||
}
|
||||
|
||||
hasTable := false
|
||||
for _, block := range baseResult.Blocks {
|
||||
if block.BlockType == types.BlockTypeLayoutTable {
|
||||
hasTable = true
|
||||
}
|
||||
features, err := textSvc.ListRequiredFeatures(ctx, baseResult.Blocks, i)
|
||||
if err != nil {
|
||||
slog.Error("error listing features", "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if hasTable {
|
||||
slog.Info("getting table", "index", i)
|
||||
pageBytes, err := pdf.GetPageAsPNG(ctx, i)
|
||||
if len(features) > 0 {
|
||||
fullFeaturesResult, err := textSvc.GetPageWithFeatures(ctx, pdf, i, features)
|
||||
if err != nil {
|
||||
slog.Error("error getting page", "error", err)
|
||||
slog.Error("error getting features", "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
tableResult, err := cfg.GetTextractClient().AnalyzeDocument(ctx, &awstextract.AnalyzeDocumentInput{
|
||||
Document: &types.Document{
|
||||
Bytes: pageBytes,
|
||||
},
|
||||
FeatureTypes: []types.FeatureType{
|
||||
types.FeatureTypeTables,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
slog.Error("error detecting table", "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
allResults[i]["table"] = tableResult
|
||||
allResults[i]["full_features"] = &fullFeaturesResult
|
||||
}
|
||||
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user