17
Explicit Semantics in Graph DBs Driving Digital Transformation With Neo4j Dr. Jesús Barrasa - Senior Consultant

Explicit Semantics in Graph DBs Driving Digital Transformation With Neo4j

Embed Size (px)

Citation preview

Explicit Semantics in Graph DBsDriving Digital Transformation With Neo4j

Dr. Jesús Barrasa - Senior Consultant

Me: Jesús Barrasa

:Researcher {

topic: Semantic Tech PhD Thesis : Mapping

RDBMS-RDF }

:HOLDS_POSITION {

from: 2002 to: 2007

}

:HOLDS_POSITION {

from: 2007 to: 2014

}

:Graph+SemanticsSpecialist {

sector: Telecoms useCases: [dependency modelling, impact analysis, root cause,…]

}

pecialist

cy modelling,cause,…]

:HOLDS_POSITION {

from: 2015 to: …

}

:GraphConsultant {

vendor:Neo4j useCases: [fraud detection, recommendation,MDM…]

}

ction,M…]

:Person {

name: J. Barrasa twitter: @BarrasaDV

mail: [email protected] }

My talk todayWhat do they mean when they call it semantics?

Semantics in Graph DBs. Is this a thing?

Explicit semantics in Neo4j: A 5 min experiment

And now what?

Quick show of hands: What do you mean when you say semantics?

Fragment Syntax Semantic?:JohnSmith :livesIn :London :London :cityIn :England RDF/Turtle Y/N{ uri: “JohnSmith”, livesIn: { uri:“London”, cityIn: { uri:”England”}}} JSON Y/N(j:Resource { uri:’JohnSmith’})-[:livesIn]->(l:Resource { uri:’London’}) (l)-[:cityIn]->(e:Resource { uri:’England’}) Cypher Y/N<rdf:RDF> <rdf:Description rdf:about=“Cljkfkojhg”> <fjoijlgkih rdf:resource=“lksdfjslkjghhhlkjsfd”/> </rdf:Description> </rdf:RDF>

RDF/XML Y/N

{"@graph": [{ "@id": "http://places.com/London", "v:cityIn": { "@id": “http://places.com/England" } },{ "@id": "v:cityIn", "rdfs:domain": { "@id": “v:Location"}, "rdfs:range": { "@id": "v:Location"} }]}

RDFS (RDF/JSON-LD) Y/N

| who | livesIn | | what | cityIn |

|JohnSmith | London | | London | England |

CSV Y/N

Misconception… that some cheeky RDF vendors keep alive.

Two facts:

John Smith lives in London and London is a city in England.

And magic will happen…

Two triples:

:JohnSmith :livesIn :London

:London :cityIn :England

One Question:

Who lives in England?

The Query:

SELECT ?who WHERE { ?who :LivesIn :England }

huh? what’s going on ?!?

A little detail is missing…If someone lives in a city and that city is in a country, then we can derive that this someone lives in that country.

But someone has to EXPLICITLY state this for an “intelligent semantic DB” to apply it to the data

?x :livesIn ?city ^ ?city :cityIn ?ctry => ?x :LivesIn ?ctry

Making the semantics of your data explicit is what operates the ‘magic’

Now we can try again: Who lives in England? ANSWER: JohnSmith

more “magic”...

Now with a reasoning engine that understands RDFS semantics we can ask: What locations do we know?

:cityIn rdfs:domain :Location :cityIn rdfs:range :Location

:cityIn is a relationship stated between two locations

ANSWER: London and England

I’m a purist (and have a PhD in description logics) so I’m not writing rules, I use a set of primitives with well defined

meaning like InverseFunctional, Domain, Disjoint, Range and a generic rules engine will apply them for me on my data.

back to the origins: The Semantic Web

(1) https://www.w3.org/DesignIssues/RDFnot.html

TBL in 1998: The Semantic Web is not AI

[…] it does not imply some magical artificial intelligence which allows machines to comprehend human mumblings. It only indicates a machine's ability to solve a well-defined problem by performing well-defined operations on existing well-defined data. Instead of asking machines to understand people's language, it involves asking people to make the extra effort. (1)

:JohnSmith :livesIn :London :London :cityIn :England …

:JohnSmith :livesIn :London :London :cityIn :England …

An example with (a bit of) code

:JohnSmith :livesIn :London :London :cityIn :England …

Implicit Semantics

Application SELECt ?loc WHERE { ?loc a :Location}

SELECt ?loc WHERE { ?loc a :Location}

Application

Explicit SemanticsSELECt ?loc WHERE {

}

Application{ ?loc a :Location } union { [] :livesIn ?loc } union { ?loc :cityIn [] } union { [] :cityIn ?loc }

?x :livesIn ?place => ?place a :Location

OWL/RDFS Ontology:cityIn rdfs:domain :Location :cityIn rdfs:range :Location

OWL/RDFS Reasoner ?prop refs:domain ?class ^ ?res ?prop [] => ?res a ?class(FC/BC/H) Rules Engine

So a semantic DB is…

• A graph database (often based on the RDF model, but…)

• Some explicit description of the data in the graph (typically RDFS/OWL or rule based)

• An (often rules based) domain-independent processor that applies the explicit semantics

Two consequences:

No, but don’t worry. It’s a GRAPH!

1. Is my DB still semantic if I just use RDF but don’t make my semantics explicit?

2. RDF is not the only way to build a semantic DB?

You got it!

After all… RDF Triple store (!)• Graph based data/knowledge/… exchange model

• Using RDF as an exchange format does not necessarily imply using tiple storage: Think of Linked Data

• Neo4j for instance can expose graph data as RDF as do other stores or middleware (DV, D2R).

Indeed, one of the main driving forces for the Semantic web, has always been the expression, on the Web, of the vast amount of relational database information in a way that can be processed by machines (1).

(1) https://www.w3.org/DesignIssues/RDB-RDF.html

RDF is a standard model for data interchange on the Web.

https://www.w3.org/TR/2004/REC-rdf-primer-20040210/

RDF is a directed, labeled graph data format for representing information in the Web.

https://www.w3.org/TR/rdf-sparql-query/

So…Linked data, semantic data, graph data…

Graph Data

LPG Data RDF Data

Explicit Semantics

:abc :custId :def({id:’abc’})-[:custId]->(id:’def’)

:custId a owl:InverseFunctionalProperty :custId rdfs:domain :Customer :Customer rdfs:subClassOf :Person

({id: ‘custId’})-[:domain]->({id: ‘Customer’}) ({id: ‘Customer’})-[:subClassOf]->({id: ‘Person’})

:abc :def

:custId

:abc :def

:custId

Build a Semantic Graph DB in 5’

• Learn an Ontology from a data set (3’)

• Formalize the ontology -> make semantics explicit (1’)

• Use these semantics to drive your ‘intelligent’ application (1’)

The dataset• 230K+ article summaries from the Financial Times

Demo...

articleDate articleTitle articleUrl keywords description storySummary 2012-12-17 “Vintage performance” http://… "EU integration, economies, natural resources, energy policy, industry, entrepreneurs, investment, restaurants, filmmaking, central and eastern Europe”

2013-01-09 "Google and the US economy”

"On a warm autumn afternoon in Tokaj, Laszlo Kalocsai waits patiently for his grapes to turn mouldy. On the edge of the Carpathian mountains, the best wines are only possible once the fog-borne fungus Botrytis cinerea has risen from the wetlands"

"Thanks to investment and a focus on quality eastern European wines are now much in demand”

http://… “Lex” ”A nice easy question: is the US economy growing or shrinking? The majority view, to simplify slightly, is that increasing employment and rising house prices must amount to an expansion. Dissident pessimists have a more complicated story. The current"

"Bullish investors should look at world’s biggest internet search group"

More on explicit semantics in Non-RDF graph DBs

https://jesusbarrasa.wordpress.com

THANK YOU!