Skip to content

Commit 41d9074

Browse files
committed
Add and use new function findTitleInTriples()
1 parent 561fa05 commit 41d9074

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

main.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -494,16 +494,8 @@ func (p *TripleAggregateToWikiPageConverter) convertUriToWikiTitle(uri string, u
494494
// Conversion strategies:
495495
// 1. Existing wiki title (in wiki, or cache)
496496
// 2. Use configured title-deciding properties
497-
for _, titleProp := range titleProperties {
498-
if aggr != nil {
499-
for _, tr := range aggr.Triples {
500-
if tr.Pred.String() == titleProp {
501-
factTitle = tr.Obj.String()
502-
}
503-
}
504-
} else {
505-
factTitle = ""
506-
}
497+
if aggr != nil {
498+
factTitle = p.findTitleInTriples(aggr.Triples)
507499
}
508500

509501
// 3. Shorten URI namespace to alias (e.g. http://purl.org/dc -> dc:)
@@ -535,6 +527,17 @@ func (p *TripleAggregateToWikiPageConverter) convertUriToWikiTitle(uri string, u
535527
return pageTitle, factTitle
536528
}
537529

530+
func (p *TripleAggregateToWikiPageConverter) findTitleInTriples(triples []rdf.Triple) string {
531+
for _, titleProp := range titleProperties {
532+
for _, tr := range triples {
533+
if tr.Pred.String() == titleProp {
534+
return tr.Obj.String()
535+
}
536+
}
537+
}
538+
return ""
539+
}
540+
538541
// --------------------------------------------------------------------------------
539542
// CategoryFilterer
540543
// --------------------------------------------------------------------------------

0 commit comments

Comments
 (0)