55 lines
1.1 KiB
Go
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
|
||
|
|
}
|