4 Replies Latest reply on Aug 21, 2009 1:59 PM by Matperry-Oracle

    filter on lang @en @fr ...

    SailLabs
      hello,
      I have imported this triple
      +<http://dbpedia.org/resource/Vienna> <http://www.w3.org/2000/01/rdf-schema#label> "'Vienna"@en+
      +<http://dbpedia.org/resource/Vienna> <http://www.w3.org/2000/01/rdf-schema#label> "'Wien"@de+
      +<http://dbpedia.org/resource/Vienna> <http://www.w3.org/2000/01/rdf-schema#label> "'Vienne"@fr+

      I use this query to retrieve all labels:

      SELECT o
      from table(sem_match ('(<http://dbpedia.org/resource/Vienna> <http://www.w3.org/2000/01/rdf-schema#label> ?o)',
      sem_models('dbpedia'),
      null,
      null,
      null));

      But I want to filter results to get only label with lang "fr" (or "de"). I try various syntaxe (like +'LANG(o) = en'+ ) for the filter clause without be able to load get the right result.

      Did Oracle support this kind of filter clause ?
        • 1. Re: filter on lang @en @fr ...
          Matperry-Oracle
          Hi,

          You can try

          SELECT o, o$rdflang
          from table(sem_match ('(<http://dbpedia.org/resource/Vienna> <http://www.w3.org/2000/01/rdf-schema#label> ?o)',
          sem_models('dbpedia'),
          null,
          null,
          ' o$rdflang = ''fr'' '));

          Note that there are 2 single quotes before and after fr not double quotes.

          Edited by: matperry on Aug 21, 2009 6:16 AM
          1 person found this helpful
          • 2. Re: filter on lang @en @fr ...
            SailLabs
            Thank you !

            Additional question:
            Is there a page somewhere describing the "filter" clause syntaxe ? (With examples)
            • 3. Re: filter on lang @en @fr ...
              Sdas-Oracle
              You could also try the SQL WHERE clause to more easily specify the FILTER:

              SELECT o, o$rdflang
              from table(sem_match ('(<http://dbpedia.org/resource/Vienna> <http://www.w3.org/2000/01/rdf-schema#label> ?o)',
              sem_models('dbpedia'),
              null,
              null,
              null))
              WHERE o$rdflang = 'fr';
              • 4. Re: filter on lang @en @fr ...
                Matperry-Oracle
                The SEM_MATCH table function is described in the documentation here:
                [http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28397/sdo_rdf_concepts.htm#CHDJACII]

                The filter clause is expressed in SQL (not SPARQL) syntax, so any valid SQL that can appear in a WHERE clause can be used here. You can use the return columns from SEM_MATCH to build the filter expression. The available columns are: var, var$RDFVID, var$_PREFIX, var$_SUFFIX, var$RDFVTYP, var$RDFCLOB, var$RDFLTYP, var$RDFVID, var$_PREFIX, var$_SUFFIX, and var$RDFLANG for variables that appear only in the object position and var, var$RDFVID, var$RDFVTYP for other variables.

                Because these are SQL expressions, Oracle SQL functions can be used, for example: 'regexp_instr(email, ''@oracle\.com'') > 0'

                Some other examples:

                to get (DATATYPE(?x) = <http://www.w3.org/2001/XMLSchema#decimal>) you could use (x$rdfltyp = ''http://www.w3.org/2001/XMLSchema#decimal'')

                and to get (isURI(?x)) you could use (x$rdfvtyp = ''URI'')