Sparql group_concat - abbreviations - sparql

In protege using group_concat returns the unabbreviated IRI.
Is there a way to just return the abbreviated names?

Related

why an URL appears in my query results using the SPARQL?

The query that is in the picture is done using the SPARQL and Protege, it is used to retrieve the phases names but an URL appear beside the name how can I remove this URL? Or is there any mistake found in the query that makes this happen?
query and result's picture
The literal values you are retrieving are typed literals.
As #AKSW commented, use the STR() function to get the untyped lexical form.

User-defined SPARQL aggregation functions in Virtuoso

I want to implement a user-defined boolean aggregation function in SPARQL and I am checking whether how easy/feasible is this in different SPARQL engines. In regards to Virtuoso, is it possible? If so, where could I find further information about it? By googling I found how to do it for SQL but not for SPARQL: http://docs.openlinksw.com/virtuoso/aggregates/
Thanks your attention and help,
Luis
You're more than halfway there.
Virtuoso lets you use SQL functions, both built-in (bif:) and user-defined (sql:), within SPARQL queries, as discussed in the documentation:
A SPARQL expression can contain calls to Virtuoso/PL functions and built-in SQL functions in both the WHERE clause and in the result set. Two namespace prefixes, bif and sql are reserved for these purposes. When a function name starts with the bif: namespace prefix, the rest of the name is treated as the name of a SQL BIF (Built-In Function). When a function name starts with the sql: namespace prefix, the rest of the name is treated as the name of a Virtuoso/PL function owned by DBA with database qualifier DB, e.g., sql:example(...) is converted into DB.DBA."example"(...).
ObDisclaimer: OpenLink Software produces Virtuoso, and employs me.

Is there a way to sort SPARQL query results by relevance score in MarkLogic 8?

We're running SPARQL queries on some clinical ontology data in our MarkLogic server. Our queries look like the following:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX cts: <http://marklogic.com/cts#>
SELECT *
FROM <http://example/ontologies/snomedct>
WHERE {
?s rdfs:label ?o .
FILTER cts:contains(?o, cts:word-query("Smoke*", "wildcarded"))
}
LIMIT 10
We expected to get sorted results based off of relevance score, but instead they seemed to be in some random order. Tried many ways with the query but nothing worked. After some research we found this statement in the MarkLogic docs:
When understanding the order an expression returns in, there are two
main rules to consider:
cts:search expressions always return in relevance order (the most relevant to the least relevant).
XPath expressions always return in document order.
Does this mean that cts:contains is a XPath expression that always return in document order? If that's the case, how can we construct a SPARQL query that returns in relevance order?
Thanks,
Kevin
In the example you have, the language you are using is SPARQL - with a fragment filter of the cts:contains.
IN this case, the cts:contains is only useful in isolating fragment IDs that match - thus filtering the candidate documents used in the SPARQL query. Therefore, I do not believe that the the cts relevance is taken into account.
However, you could possibly get results you are looking for in a different way: Do an actual cts:search on the documents in question - then filter them using a cts:triple-range-query.
https://docs.marklogic.com/cts:triple-range-query

How to implement "like" in BigQuery?

I am trying to run a simple query making a restriction of like % in BigQuery, but LIKE is not in their syntax, so how can it be implemented?
You can use the REGEXP_MATCH function (see the query reference page):
REGEXP_MATCH('str', 'reg_exp')
Instead of using the % syntax used by LIKE, you should use regular expressions (detailed syntax definition here)
LIKE is officially supported in BigQuery Standard SQL -
https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#comparison_operators
And I think it also works in Legacy SQL!
REGEXP_MATCH returns true if str matches the regular expression. For string matching without regular expressions, use CONTAINS instead of REGEXP_MATCH.
https://developers.google.com/bigquery/docs/query-reference#stringfunctions
REGEXP_MATCH is great if you know how to use it, but for those who aren't sure there won't be any commonly used special characters such as '.','$' or '?' in the lookup string, you can use LEFT('str', numeric_expr) or RIGHT('str', numeric_expr).
ie if you had a list of names and wanted to return all those that are LIKE 'sa%'
you'd use:
select name from list where LEFT(name,2)='sa'; (with 2 being the length of 'sa')
Additionally, if you wanted to say where one column's values are LIKE another's, you could swap out the 2 for LENGTH(column_with_lookup_strings) and ='sa' for =column_with_lookup_strings, leaving it looking something like this:
select name from list where LEFT(name,LENGTH(column_with_lookup_strings))= column_with_lookup_strings;
https://cloud.google.com/bigquery/query-reference

SPARQL Finding the average?

I'm using a SPARQL query tool called Twinkle that doesn't seem to support functions like AVG() and SUM(). So far, only the COUNT() ARQ function works. Is there an alternative way to sum numbers so that I can at least divide using COUNT()?
I don't think so. Switch tools and use something that supports SPARQL 1.1.