Google Custom Synonyms Report
The report creates a synonym list which can be used to extend Google's Customized Search Engine (CSE) . The named query in the PoolParty configuration (SesameSetup.xml) for the report looks like the following:
<namedQueries>
...
<entry>
<key>GoogleSynonyms</key>
<value>
<sparqlQueryParameterMap/>
<sparqlQueryTemplate>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT ?term ?synonym
WHERE {
?x a ?Concept.
?x skos:prefLabel ?term.
OPTIONAL { ?x skos:altLabel ?synonym }
OPTIONAL { ?x skos:hiddenLabel ?synonym }
FILTER (bound(?synonym) && lang(?term) = lang(?synonym))
}
</sparqlQueryTemplate>
</value>
</entry>
...
</namedQueries>The velocity template for the report looks like the following:
<?xml version="1.0" encoding="UTF-8"?>
<Synonyms>
#set ($lastTerm = '')
#set ($numVariants = 0)
#set ($firstTerm = true)
#foreach ($row in $result)
#if ($lastTerm != $row.get('term').getLabel())
#if ($firstTerm)
#set ($firstTerm = false)
#else
</Synonym>
#end
<Synonym term="$row.get('term').getLabel().replaceAll('&','&')">
#set ($numVariants = 0)
#end
#if ($numVariants < 10)
<Variant>$row.get('synonym').getLabel().replaceAll('&','&')</Variant>
#set($lastTerm = $row.get('term').getLabel())
#set($numVariants = $numVariants + 1)
#end
#end
</Synonym>
</Synonyms>The report entry in the PoolParty configuration (SesameSetup.xml) for the report looks like the following:
<reports>
...
<entry>
<key>Google Custom Synonyms</key>
<value>
<contentType>application/xml</contentType>
<namedQuery>GoogleSynonyms</namedQuery>
<template>synonyms.vm</template>
</value>
</entry>
...
</reports>