Skip to content
Snippets Groups Projects
Commit 2fa880a2 authored by Frank Lange's avatar Frank Lange
Browse files

use unordered authors set in text search instead of iterating over the linked...

use unordered authors set in text search instead of iterating over the linked list (RDF collection) of authors
parent 01556ba4
Branches
No related tags found
No related merge requests found
Pipeline #1632605 passed
...@@ -2,18 +2,17 @@ from typing import Dict, List ...@@ -2,18 +2,17 @@ from typing import Dict, List
from rdflib import BNode, Graph, Literal, RDF, Variable from rdflib import BNode, Graph, Literal, RDF, Variable
from rdflib.collection import Collection from rdflib.collection import Collection
from rdflib.term import Node from rdflib.term import Node, URIRef
from project.dalia.query.items.facets.facet_objects import FacetObject from project.dalia.query.items.facets.facet_objects import FacetObject
from project.dalia.query_builder.query_builder import ( from project.dalia.query_builder.query_builder import (
BIND, BIND,
FILTER, FILTER,
FILTER_EXISTS, FILTER_EXISTS,
FunctionExpressions,
OPTIONAL, OPTIONAL,
Operators, Operators,
) )
from project.dalia.rdf.namespace import Dalia_text, Jena_ARQ_list, Jena_text, MoDalia, SCHEMA, educor from project.dalia.rdf.namespace import Dalia_text, Jena_text, MoDalia, SCHEMA, educor
def prepare_where_for_text_search_for_learning_resources( def prepare_where_for_text_search_for_learning_resources(
...@@ -25,7 +24,6 @@ def prepare_where_for_text_search_for_learning_resources( ...@@ -25,7 +24,6 @@ def prepare_where_for_text_search_for_learning_resources(
): ):
var_s = Variable("s") var_s = Variable("s")
var_type = Variable("type") var_type = Variable("type")
var_list = Variable("list")
left_list = Collection(Graph(), BNode(), [var_s, var_score]) left_list = Collection(Graph(), BNode(), [var_s, var_score])
right_list = Collection(Graph(), BNode(), [Dalia_text.learningResourceTexts, Literal(query)]) right_list = Collection(Graph(), BNode(), [Dalia_text.learningResourceTexts, Literal(query)])
...@@ -40,8 +38,7 @@ def prepare_where_for_text_search_for_learning_resources( ...@@ -40,8 +38,7 @@ def prepare_where_for_text_search_for_learning_resources(
Operators.EQ(var_type, SCHEMA.Organization), Operators.EQ(var_type, SCHEMA.Organization),
) )
), ),
(var_list, Jena_ARQ_list.member, var_s), (var_lr, URIRef("https://dalia.education/authorUnordered"), var_s),
(var_lr, SCHEMA.author, var_list),
OPTIONAL( OPTIONAL(
(var_lr, SCHEMA.datePublished, var_created) (var_lr, SCHEMA.datePublished, var_created)
) )
......
...@@ -27,8 +27,7 @@ def test_prepare_query_for_count_in_text_search(): ...@@ -27,8 +27,7 @@ def test_prepare_query_for_count_in_text_search():
OPTIONAL { OPTIONAL {
?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type . ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type .
FILTER ( ?type = <https://schema.org/Person> || ?type = <https://schema.org/Organization> ) . FILTER ( ?type = <https://schema.org/Person> || ?type = <https://schema.org/Organization> ) .
?list <http://jena.apache.org/ARQ/list#member> ?s . ?lr <https://dalia.education/authorUnordered> ?s .
?lr <https://schema.org/author> ?list .
OPTIONAL { OPTIONAL {
?lr <https://schema.org/datePublished> ?created . ?lr <https://schema.org/datePublished> ?created .
} . } .
...@@ -60,8 +59,7 @@ def test_prepare_query_for_count_in_text_search_with_target_audience_facet(): ...@@ -60,8 +59,7 @@ def test_prepare_query_for_count_in_text_search_with_target_audience_facet():
OPTIONAL { OPTIONAL {
?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type . ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type .
FILTER ( ?type = <https://schema.org/Person> || ?type = <https://schema.org/Organization> ) . FILTER ( ?type = <https://schema.org/Person> || ?type = <https://schema.org/Organization> ) .
?list <http://jena.apache.org/ARQ/list#member> ?s . ?lr <https://dalia.education/authorUnordered> ?s .
?lr <https://schema.org/author> ?list .
OPTIONAL { OPTIONAL {
?lr <https://schema.org/datePublished> ?created . ?lr <https://schema.org/datePublished> ?created .
} . } .
......
...@@ -35,8 +35,7 @@ def test_prepare_query_for_text_search_for_learning_resources_order_by_relevance ...@@ -35,8 +35,7 @@ def test_prepare_query_for_text_search_for_learning_resources_order_by_relevance
OPTIONAL { OPTIONAL {
?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type . ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type .
FILTER ( ?type = <https://schema.org/Person> || ?type = <https://schema.org/Organization> ) . FILTER ( ?type = <https://schema.org/Person> || ?type = <https://schema.org/Organization> ) .
?list <http://jena.apache.org/ARQ/list#member> ?s . ?lr <https://dalia.education/authorUnordered> ?s .
?lr <https://schema.org/author> ?list .
OPTIONAL { OPTIONAL {
?lr <https://schema.org/datePublished> ?created . ?lr <https://schema.org/datePublished> ?created .
} . } .
...@@ -75,8 +74,7 @@ def test_prepare_query_for_text_search_for_learning_resources_order_by_created_d ...@@ -75,8 +74,7 @@ def test_prepare_query_for_text_search_for_learning_resources_order_by_created_d
OPTIONAL { OPTIONAL {
?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type . ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type .
FILTER ( ?type = <https://schema.org/Person> || ?type = <https://schema.org/Organization> ) . FILTER ( ?type = <https://schema.org/Person> || ?type = <https://schema.org/Organization> ) .
?list <http://jena.apache.org/ARQ/list#member> ?s . ?lr <https://dalia.education/authorUnordered> ?s .
?lr <https://schema.org/author> ?list .
OPTIONAL { OPTIONAL {
?lr <https://schema.org/datePublished> ?created . ?lr <https://schema.org/datePublished> ?created .
} . } .
...@@ -122,8 +120,7 @@ def test_prepare_query_for_text_search_for_learning_resources_order_by_relevance ...@@ -122,8 +120,7 @@ def test_prepare_query_for_text_search_for_learning_resources_order_by_relevance
OPTIONAL { OPTIONAL {
?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type . ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type .
FILTER ( ?type = <https://schema.org/Person> || ?type = <https://schema.org/Organization> ) . FILTER ( ?type = <https://schema.org/Person> || ?type = <https://schema.org/Organization> ) .
?list <http://jena.apache.org/ARQ/list#member> ?s . ?lr <https://dalia.education/authorUnordered> ?s .
?lr <https://schema.org/author> ?list .
OPTIONAL { OPTIONAL {
?lr <https://schema.org/datePublished> ?created . ?lr <https://schema.org/datePublished> ?created .
} . } .
...@@ -168,8 +165,7 @@ def test_prepare_query_for_text_search_for_learning_resources_order_by_created_a ...@@ -168,8 +165,7 @@ def test_prepare_query_for_text_search_for_learning_resources_order_by_created_a
OPTIONAL { OPTIONAL {
?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type . ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type .
FILTER ( ?type = <https://schema.org/Person> || ?type = <https://schema.org/Organization> ) . FILTER ( ?type = <https://schema.org/Person> || ?type = <https://schema.org/Organization> ) .
?list <http://jena.apache.org/ARQ/list#member> ?s . ?lr <https://dalia.education/authorUnordered> ?s .
?lr <https://schema.org/author> ?list .
OPTIONAL { OPTIONAL {
?lr <https://schema.org/datePublished> ?created . ?lr <https://schema.org/datePublished> ?created .
} . } .
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment