-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom calculator function #612
Comments
Pseudocode PREFIX grace: <http://www.graceful17.org/ontology/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?book ?sentences ?pages ?sentencesPerPage WHERE {
?book a grace:Book ;
grace:numberOfSentences ?sentences ;
grace:numberOfPages ?pages .
BIND(xsd:decimal(?sentences) / xsd:decimal(?pages) AS ?sentencesPerPage)
} |
I might be wrong but custom data sources seem to cover only object properties, not literals, as range. But I imagine that there is a runtime variable that could bind |
No. This is clearly out of scope of what Sparnatural can do. We are not trying to cover 100% of SPARQL; there is currently no plan to support this.
Yes, you can write a custom datasource that returns a literal. And yes, you can use a BIND and do some calculation in this custom datasource. But this will not allow a user to do this calculation in the final query. |
I think I found the function in the JavaScript that replaces I also realized that in the yasgui plugins library exist many custom calculation functions that don't seem to be included in the aggregate widget either, but I didn't look closely, tbh. |
Great. |
Suppose I want to display certain mathematical functions as a value in a separate column in the query result that cannot be defined dynamically by the user in the aggregate widget. Can I define a class with a SPARQL query that performs the calculation and returns the result as a number?
Imagine I want the logarithm or some specific fraction calculated on the basis of some domain URI, e.g. the number of sentences divided by the number of pages in some book. The
BOOK
URI would be the domain andSENTENCES PER PAGE
the property, the result aXSD:DECIMAL
. So, the table should have the columnsBOOK
andSENTENCES PER PAGE
.The text was updated successfully, but these errors were encountered: