Skip to main content

Oracle Text Thesaurus (ISO-2788)

This report creates a thesaurus to improve the query application in Oracle text. The named query in the PoolParty configuration (SesameSetup.xml) for the report looks like the following:

<namedQueries>
...
       <entry>
        <key>OracleReport</key>
        <value>
         <sparqlQueryParameterMap>
          <entry>
           <key>language</key>
           <value>en</value>
          </entry>
         </sparqlQueryParameterMap>
         <sparqlQueryTemplate>
PREFIX rdf:&lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;
PREFIX skos:&lt;http://www.w3.org/2004/02/skos/core#&gt;
SELECT
 ?cLabel
 (GROUP_CONCAT(DISTINCT ?aLabel ; separator=" | ") AS ?aLabels)
 (GROUP_CONCAT(DISTINCT ?nLabel ; separator=" | ") AS ?nLabels)
 (GROUP_CONCAT(DISTINCT ?bLabel ; separator=" | ") AS ?bLabels)
 (GROUP_CONCAT(DISTINCT ?rLabel ; separator=" | ") AS ?rLabels)
 (GROUP_CONCAT(DISTINCT ?def ; separator=" | ") AS ?definition)
 WHERE {
  ?c a skos:Concept .
  ?c skos:prefLabel ?cLabel FILTER(lang(?cLabel)="%%%language%%%")
  OPTIONAL {
   ?c skos:altLabel ?aLabel FILTER(lang(?aLabel)="%%%language%%%").
  }
  OPTIONAL {
   ?c skos:narrower/skos:prefLabel ?nLabel FILTER(lang(?nLabel)="%%%language%%%").
  }
  OPTIONAL {
   ?c skos:broader/skos:prefLabel ?bLabel FILTER(lang(?bLabel)="%%%language%%%").
  }
  OPTIONAL {
   ?c skos:related/skos:prefLabel ?rLabel FILTER(lang(?rLabel)="%%%language%%%").
  }
  OPTIONAL {
   ?c skos:definition ?def FILTER(lang(?def)="%%%language%%%").
  }
} GROUP BY ?cLabel
     </sparqlQueryTemplate>
    </value>
       </entry>      
...
    </namedQueries>

The velocity template for the report looks like the following:

Key,Synonym,Language
#foreach($row in $result)
$row.get("pref").stringValue(),$row.get("alt").stringValue(),$parameters.get('Lang').get(0)
#end

The report entry in the PoolParty configuration (SesameSetup.xml) for the report looks like the following:

   <reports>
...
        <entry>
         <key>Oracle Text Report</key>
         <value>
          <contentType>text/plain;charset=UTF-8</contentType>
          <namedQuery>OracleReport</namedQuery>
          <suffix>.txt</suffix>
          <template>oracle.vm</template>
         </value>
       </entry>  
...
    </reports>