Search RDF graph for partial matches

How would I search the RDF database to find the chart segments that overlap with the sample most?

For example, let's say my database stores the following arbitrary graphs:

entity1 [
    type "TOP" ;
    attr1 [
        attr11 [
            attr111 "apple" ;
        ] ;
        attr12 [
            attr121 "orange" ;
        ] ;
        attr13 [
            attr131 "banana" ;
        ] ;
    ] ;
    attr2 [
        attr21 [
            attr211 "falcon" ;
        ] ;
        attr22 [
            attr221 "pigeon" ;
        ] ;
        attr23 [
            attr231 "parrot" ;
        ] ;
    ] ;
] .
entity2 [
    type "TOP" ;
    attr11 [
        attr111 "apple" ;
    ] ;
    attr12 [
        attr121 "orange" ;
    ] ;
] .
entity3 [
    type "TOP" ;
    attr2 [
        attr_middle [
            attr21 [
                attr211 "falcon" ;
            ] ;
            attr22 [
                attr221 "pigeon" ;
            ] ;
            attr23 [
                attr231 "parrot" ;
            ] ;
        ] ;
    ] ;
] .

Now tell me that I have an example graph:

sample [
    type "TOP" ;
    attr11 [
        attr111 "apple" ;
    ] ;
    attr12 [
        attr121 "orange" ;
    ] ;
    attr13 [
        attr131 "banana" ;
    ] ;
    attr21 [
        attr211 "falcon" ;
    ] ;
    attr22 [
        attr221 "pigeon" ;
    ] ;
    attr23 [
        attr231 "parrot" ;
    ] ;
] .

It is clear that nothing in the database matches the pattern perfectly, but each object partially matches it, even if in each graph there are different levels of the trend at different levels.

How do I find the closest match to a pattern? In this case, I expect that the query will return at first sorted the best result [entity1, entity3, entity2].

RDF, , . RDF, , , , . , "" attr111 = "apple", SPARQL, , , "" . ?

+3
1

, , SPARQL . , , . , , .

. , ASK. SELECT, , , , , . ASK true, false , WHERE

SPARQL SPARQL 1.1, .e.g

SELECT * WHERE { ?s ex:predicate / ex:predicate / ex:predicate "value" }

SPARQL 1.0, :

SELECT * WHERE
{
  ?s ex:predicate _:b1 .
  _:b1 ex:predicate _:b2 .
  _:b2 ex:predicate "value" .
}

, - SPARQL 1.1 SPARQL 1.0.

, , , SPARQL.

+2

Source: https://habr.com/ru/post/1792249/


All Articles