how to call the current time NOW() in protege SPARQL? - sparql

I am trying to calculate the duration time in SPARQL protege
I need to call the NOW() so that I can find the difference time.
I tried
PREFIX ofn:http://www.ontotext.com/sparql/functions/
afn:now(), I get error unknown
I am using Protege version 5.5.0
Also I have tried
ofn:millis-from-duration()
also it is unknow function
what else can I try?

Just NOW(). It's core built-in function in SPARQL 1.1, there's no need to use a custom prefixed function.

Related

Solr Dismax using % in mm parameter give error

I am trying to use the mm (Minimum Should Match) parameter with the dismax parser. If I do just mm=2 or any other int value it seems to work fine. But if I try and add a percent as shown in the able, say mm=60%, then I get an "invalid digit" error for the query. How do I actually use the percentage for mm?
Solr ref guide mm table
(running solr 7.6 btw)

Momentjs returns date in wrong timezone

I'm having a problem with momentjs. I'm trying to generate all days from a specific month by using the startOf and endOf methods on my moment object like this:
moment('2017-07-17').startOf('month')
However, when I log the return value in the console it returns "2017-06-30T22:00:00.000Z".
I expect it to just be "2017-07-01T00:00:00.000Z".
I am using vue 2.x if that makes any difference, and I'm importing moment like import moment from 'moment';.
Its because of timezone moment('2017-07-17') will take your local timezone which looks to be CEST.
instead do
moment.utc('2017-07-17')

later.js every nth weekday of every month

I am using later.js (meteor package, voidale:later-js-tz#1.1.9) to schedule events, using the later.parse.text() parser.
I can schedule weekly events on a given weekday with no problem, with strings like 'at 11:00 on Monday'.
But I get parse errors trying things like 'at 11:00 on every second Monday of every month'.
Q: Is there a way to do this in later.js, or if not, is there a javascript library available that does support this?
Thanks.
I found moment-recur, which supports this nth-weekday of a month in its API, but doesn't have a text parser.
I then used PEGjs to build a text parser which outputs the necessary parameters, which I use in a straightforward way to call the moment-recur API.

Date range search using Google Custom Search API

I am using the Google Custom Search API to search for images. My implementation is using Java, and this is how I build my search string:
URL url = new URL("https://ajax.googleapis.com/ajax/services/search/images?"
+ "v=1.0&q=barack%20obama&userip=INSERT-USER-IP");
How would I modify the URL to limit search results, for example, to: 2014-08-15 and 2014-09-31?
You can specify a date range using the sort parameter. For your example, you would add this to your query string: sort=date:r:20140815:20140931.
This is documented at https://developers.google.com/custom-search/docs/structured_data#page_dates
Also if you use Google's Java API you can use the Query class and its setSort() method rather than building the URL by hand.
I think the better way is to put this into query itself. Query parameter contains 'after' flag which can be used like:
https://customsearch.googleapis.com/customsearch/v1?
key=<api_key>&
cx=<search_engine_id>&
q="<your_search_word> after:<YYYY-MM-DD>"

slash in property name sparql

I'm working on a project using sparql & dbpedia.
I 'm currently having an issue with a textuel property with a slash on it.
Here is a working query with the property "discharge" which express the amount of water per time of a river:
PREFIX dbp: <http://dbpedia.org/property/>
SELECT ?discharge
WHERE
{
<http://dbpedia.org/resource/Nile> dbp:discharge ?discharge .
FILTER(ISLITERAL(?discharge))
}
LIMIT 200
This request is working fine.
Still if use, a similar property called "discharge_m3/s", it"s not working anymore and I got this error which increminates the slash on the property name:
Virtuoso 37000 Error SP030: SPARQL compiler, line 3: syntax error at
'/' before 's'
Any idea to go through this ?
Do you mean you are trying to use the property in prefixed name form i.e. dbp:discharge_m3/s?
If that is the case you can't do that because that is not a valid prefixed name according to the SPARQL grammer hence the compiler error.
You would have to include the full URI instead of the prefixed name form e.g.
<http://dbpedia.org/property/discharge_m3/s>
In compliant SPARQL 1.1 systems, you can backslash-escape the slash: dbp:discharge_m3\/s. I'm not sure if Virtuoso supports that syntax yet. In the meantime, #RobV's solution will work.