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

45 lines
1.2 KiB
Go

package pipeline
import "testing"
func TestExtractRowFeaturesHeaderKeyword(t *testing.T) {
group := []indexedBox{
{Text: "FACTURA", X: 10, Y: 50, Cluster: 0},
{Text: "NIT", X: 100, Y: 50, Cluster: 0},
{Text: "123", X: 200, Y: 50, Cluster: 0},
}
row := extractRowFeatures(group, 1000, 2000)
if row.Features[3] != 1 {
t.Fatalf("has_header_keyword = %v, want 1", row.Features[3])
}
}
func TestExtractRowFeaturesServiceCode(t *testing.T) {
group := []indexedBox{
{Text: "AB12", X: 10, Y: 100, Cluster: 0},
{Text: "CONSULTA", X: 80, Y: 100, Cluster: 0},
}
row := extractRowFeatures(group, 1000, 2000)
if row.Features[1] != 1 {
t.Fatalf("first_token_is_service_code = %v, want 1", row.Features[1])
}
}
func TestBuildFeatureRowsEmpty(t *testing.T) {
rows := buildFeatureRows(nil, 1000, 2000)
if len(rows) != 0 {
t.Fatalf("rows = %d, want 0", len(rows))
}
}
func TestExtractRowFeaturesNoTablePattern(t *testing.T) {
group := []indexedBox{
{Text: "TEXTO", X: 10, Y: 100, Cluster: 0},
{Text: "LIBRE", X: 80, Y: 100, Cluster: 0},
}
row := extractRowFeatures(group, 1000, 2000)
if row.Features[2] != 0 {
t.Fatalf("has_service_table_pattern = %v, want 0", row.Features[2])
}
}