Files
query-orchestration/internal/document/text/checkbox.go
T
Michael McGuinness 61d12bf8df 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
2025-05-20 12:47:22 +00:00

55 lines
1.1 KiB
Go

package documenttext
import (
"strings"
)
func (s *Service) hasCheckboxKeywords(text string) bool {
conditions := []func(string) bool{
s.hasExhibit,
s.hasBenefit,
s.hasPlans,
s.hasServices,
}
elementsContained := 0
for _, hasCondition := range conditions {
if hasCondition(text) {
elementsContained++
}
}
return elementsContained >= 3
}
func (s *Service) hasExhibit(text string) bool {
return strings.Contains(text, "exhibit")
}
func (s *Service) hasBenefit(text string) bool {
keywords := []string{"benefit plan", "applicable benefit", "benefits"}
return orKeywords(text, keywords)
}
func (s *Service) hasPlans(text string) bool {
keywords := []string{"plan/program:", "plan(s)", "plans"}
return orKeywords(text, keywords)
}
func (s *Service) hasServices(text string) bool {
keywords := []string{"service:", "services", "service(s)"}
return orKeywords(text, keywords)
}
func orKeywords(text string, keywords []string) bool {
for _, keyword := range keywords {
if strings.Contains(text, keyword) {
return true
}
}
return false
}