2 Replies Latest reply: Apr 29, 2013 7:05 PM by user571093 RSS

    user-defined function in FILTER clause

    user571093
      hi,

      can i create the user-defined functions and use them in the FILTER clause in the sem_match function? there are some built-in functions for the FILTER clasue. however, only one function (DATATYPE(literal)) support for date/time in the built-in functions. i want to implement some user-defined funcitons in the FILTER clause which can check time intervals in ontology. there are some functions about valid time in the WorkSpace Manager such as WM_OVERLAPS, WM_CONTAINS,WM_MEETS, etc. so, can i write some functions using the these valid time functions in WM and use them in the FILTER clause? thanks a lot in advance.

      hong
        • 1. Re: user-defined function in FILTER clause
          matperry
          Hi Hong,

          You don't need user-defined functions to do time interval comparisons. You can directly compare xsd:dateTime values with the built-in comparison operators: <, >, =, !=, <=, >=

          For example, the query pattern below could find events that happened during event1 if we have data such as:

          :event1 :startTime "2013-01-01T03:15:00Z"^^xsd:dateTime .
          :event1 :endTime "2013-02-01T02:15:00Z"^^xsd:dateTime .
          :event2 :startTime "2013-01-11T14:15:00Z"^^xsd:dateTime .
          :event2 :startTime "2013-01-14T12:15:00Z"^^xsd:dateTime .

          SELECT ?e2
          WHERE
          { :event1 :startTime ?e1_st; :endTime ?e1_et .
          ?e2 :startTime ?e2_st; endTime ?e2_et .
          FILTER (?e1_st < ?e2_st && ?e2_et < ?e1_et) }

          In general, it is trivial to convert interval relations such as meets and overlaps to conditions on start and end times.

          Hope this helps.

          - Matt
          • 2. Re: user-defined function in FILTER clause
            user571093
            hi matt,

            that's very helpful. thanks a lot.

            hong