diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/wikiarticle.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/wikiarticle.go b/src/wikiarticle.go index 5f7aaa1..09c2da8 100644 --- a/src/wikiarticle.go +++ b/src/wikiarticle.go @@ -206,18 +206,36 @@ func extractAccolades(article map[string]interface{}) int { if !ok { return 0 } + total := 0 for _, t := range tables { tab, ok := t.(map[string]interface{}) if !ok { continue } + + // Only count tables whose headers mention "Award" or "award" + if !hasAwardHeader(tab) { + continue + } + rows, _ := tab["rows"].([]interface{}) total += len(rows) } return total } +// hasAwardHeader checks if a table's headers contain award-related columns. +func hasAwardHeader(tab map[string]interface{}) bool { + headers, ok := tab["headers"].([]interface{}) + if !ok || len(headers) == 0 { + return false + } + + headerStr := strings.ToLower(fmt.Sprintf("%v", headers)) + return strings.Contains(headerStr, "award") +} + // extractPeople extracts actors, directors, and screenwriters from the article. func extractPeople(article map[string]interface{}) []wikiPerson { var people []wikiPerson |
