Skip to content

Commit adc6969

Browse files
committed
Don't add duplicate facts or categories
1 parent 41d9074 commit adc6969

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

main.go

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,33 @@ func (p *TripleAggregateToWikiPageConverter) Run() {
449449
_, valueStr := p.convertUriToWikiTitle(tr.Obj.String(), valueUriType, resourceIndex)
450450

451451
if tr.Pred.String() == typePropertyURI || tr.Pred.String() == subClassPropertyURI {
452-
page.AddCategory(valueStr)
452+
453+
catExists := false
454+
for _, existingCat := range page.Categories {
455+
if valueStr == existingCat {
456+
catExists = true
457+
break
458+
}
459+
}
460+
461+
if !catExists {
462+
page.AddCategory(valueStr)
463+
}
464+
453465
} else {
454-
fact := NewFact(propertyStr, valueStr)
455-
page.AddFact(fact)
466+
467+
factExists := false
468+
for _, existingFact := range page.Facts {
469+
if propertyStr == existingFact.Property && valueStr == existingFact.Value {
470+
factExists = true
471+
break
472+
}
473+
}
474+
475+
if !factExists {
476+
fact := NewFact(propertyStr, valueStr)
477+
page.AddFact(fact)
478+
}
456479
}
457480
}
458481

0 commit comments

Comments
 (0)