humanitiesplusdesign / data-pen

Personal modeling application for Linked Data.
http://hdlab.stanford.edu/fibra
26 stars 0 forks source link

Incorporate full-name lookup query as an autoCompleteService option #99

Open esjewett opened 7 years ago

esjewett commented 7 years ago

Eetu pulled this query out of recon and we should use to drive the verification lookup:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX text: <http://jena.apache.org/text#>
PREFIX pf: <http://jena.hpl.hp.com/ARQ/property#>
PREFIX sf: <http://ldf.fi/similarity-functions#>

     SELECT ?e (SUM(?s)/COUNT(?s) AS ?sc) {
        {
          SELECT DISTINCT ?e {
            BIND(REPLACE(REPLACE(REPLACE(REPLACE(<QUERY>,"([\\+\\-\\&\\|\\!\\(\\)\\{\\}\\[\\]\\^\\\"\\~\\*\\?\\:\\\\])","\\\\$1"),"^ +| +$", ""),", *"," "),"\\. ","* ") AS ?escapedQuery)
            BIND(CONCAT("(",?escapedQuery,") OR (",REPLACE(?escapedQuery,"([^*]) +","$1~ "),"~)") AS ?queryTerm)
            ?e text:query ?queryTerm .
            # CONSTRAINTS
          }
          LIMIT <LIMIT>
        }
        ?e rdfs:label|skos:prefLabel|skos:altLabel ?mlabel .
        ?str pf:strSplit (<QUERY> " ")
        BIND(sf:levenshteinSubstring(?str,STR(?mlabel)) AS ?s)
      } GROUP BY ?e
esjewett commented 7 years ago

Putting this on the back-burner as it appears that this kind of works currently.