Files
IPSExtractor/services/services-count-facturas-medicas-serving/internal/pipeline/features_test.go
T

49 lines
1.4 KiB
Go

package pipeline
import "testing"
func TestExtractRowFeaturesServiceTablePattern(t *testing.T) {
group := []indexedBox{
{Text: "890701", X: 10, Y: 200, Cluster: 0},
{Text: "CONSULTA", X: 100, Y: 201, Cluster: 0},
{Text: "16,277.00", X: 400, Y: 200, Cluster: 0},
{Text: "1", X: 500, Y: 201, Cluster: 0},
{Text: "16,277.00", X: 600, Y: 200, Cluster: 0},
}
row := extractRowFeatures(group, 1000, 2000)
if row.Features[2] != 1 {
t.Fatalf("has_service_table_pattern = %v, want 1", row.Features[2])
}
if row.Features[4] != 1 {
t.Fatalf("currency_at_row_end = %v, want 1", row.Features[4])
}
}
func TestBuildFeaturesContinuation(t *testing.T) {
boxes := []indexedBox{
{Text: "890701", X: 10, Y: 100, Cluster: 0},
{Text: "CONSULTA", X: 100, Y: 100, Cluster: 0},
{Text: "16,277.00", X: 400, Y: 100, Cluster: 0},
{Text: "1", X: 500, Y: 100, Cluster: 0},
{Text: "16,277.00", X: 600, Y: 100, Cluster: 0},
{Text: "DE", X: 100, Y: 120, Cluster: 1},
{Text: "SEGUIMIENTO", X: 200, Y: 120, Cluster: 1},
}
rows := buildFeatureRows(boxes, 1000, 2000)
if len(rows) != 2 {
t.Fatalf("rows = %d, want 2", len(rows))
}
if rows[0].Features[2] != 1 {
t.Fatal("first row should have service table pattern")
}
if rows[1].Features[6] != 1 {
t.Fatal("second row should be likely continuation")
}
}
func TestFeatureCount(t *testing.T) {
if FeatureCount != 14 {
t.Fatalf("FeatureCount = %d, want 14", FeatureCount)
}
}