dependency parsing-based qa system for rdf and sparql

56
Dependency Parsing-based QA System using RDF and SPARQL Fariz Darari [email protected]

Upload: fariz-darari

Post on 08-May-2015

1.194 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Dependency Parsing-based QA System for RDF and SPARQL

Dependency Parsing-based QA System using RDF and SPARQL

Fariz [email protected]

Page 2: Dependency Parsing-based QA System for RDF and SPARQL

2

Motivation

Page 3: Dependency Parsing-based QA System for RDF and SPARQL

3

Motivation

Page 4: Dependency Parsing-based QA System for RDF and SPARQL

4

Motivation

Page 5: Dependency Parsing-based QA System for RDF and SPARQL

5

BACKGROUND

Page 6: Dependency Parsing-based QA System for RDF and SPARQL

6

QA in General

• Finding an answer to natural language questions based on documents/facts

• Instead of documents, give answers• Factoid questions:– Who can dance Tango?– What did I eat this morning?– When Mahatma Gandhi was born?

Page 7: Dependency Parsing-based QA System for RDF and SPARQL

7

Dependency Parsing

Page 8: Dependency Parsing-based QA System for RDF and SPARQL

8

RDF & SPARQL

• RDF Data: :book1 :title "SPARQL Tutorial" .

• SPARQL Query:SELECT ?titleWHERE { :book1 :title ?title . }

Page 9: Dependency Parsing-based QA System for RDF and SPARQL

9

WordNet

• Large lexical database of English words• Words are grouped into synsets• Relations among synsets: Synonymy,

antonymy, hyponymy, meronymy, troponymy

Page 10: Dependency Parsing-based QA System for RDF and SPARQL

10

DBpedia• Knowledge base of Wikipedia in RDF• Data at dbpedia.org/resource/Italy:

Page 11: Dependency Parsing-based QA System for RDF and SPARQL

11

DEVELOPMENT

Page 12: Dependency Parsing-based QA System for RDF and SPARQL

NL Text(Facts)

NL Text(Questions)

Dependency Parser

Dependency Parser

RDFizer

SPARQLizer

RDF SPARQL

OWLOntology

Page 13: Dependency Parsing-based QA System for RDF and SPARQL

13

Facts Population

1. We parse the natural language facts using the Stanford dependency parser. The result will be typed dependencies.

2. The typed dependencies are then translated into RDF format using RDFizer. The RDFizer is built using Java with Apache Jena as the Semantic Web library.

3. The resulting RDF will be consulted with an OWL ontology that contains some WordNet and DBpedia axioms to infer some new facts.

Page 14: Dependency Parsing-based QA System for RDF and SPARQL

14

Query Execution

1. We parse the natural language questions using the Stanford dependency parser. The result will be typed dependencies.

2. We then translate the typed dependencies into SPARQL query format.

3. The SPARQL query is then executed over populated RDF data from the result of Facts Population.

Page 15: Dependency Parsing-based QA System for RDF and SPARQL

15

Background KnowledgeWordNet

Synonymy:<http://example.org/sentence/buy> owl:sameAs

<http://example.org/sentence/purchase> .

Page 16: Dependency Parsing-based QA System for RDF and SPARQL

16

Background KnowledgeWordNet

Hyponymy:• PREFIX : <http://example.org/sentence/>

CONSTRUCT {:vehicle ?y ?z} WHERE {:car ?y ?z}

• PREFIX : <http://example.org/sentence/>CONSTRUCT {?x ?y :vehicle} WHERE {?x ?y :car}

Page 17: Dependency Parsing-based QA System for RDF and SPARQL

17

Background KnowledgeWordNet

Troponymy:• PREFIX : <http://example.org/sentence/>

CONSTRUCT {:move ?y ?z} WHERE {:run ?y ?z}

• PREFIX : <http://example.org/sentence/>CONSTRUCT {?x ?y :move} WHERE {?x ?y :run}

Page 18: Dependency Parsing-based QA System for RDF and SPARQL

18

Background KnowledgeDBpedia

<http://example.org/sentence/italy> owl:sameAs <http://dbpedia.org/resource/Italy>

Page 19: Dependency Parsing-based QA System for RDF and SPARQL

19

IMPLEMENTATION AND RESULT

Page 20: Dependency Parsing-based QA System for RDF and SPARQL

20

Program

• Java-based• Reuse Apache Jena: SW library• Reuse Stanford Parser: Typed dependencies• MorphAdorner: Lemmatization and verb

conjugation

Page 21: Dependency Parsing-based QA System for RDF and SPARQL

21

A Detailed Example (1)

• Fact: Aliana bought a car• Question: Who purchased a vehicle?

Page 22: Dependency Parsing-based QA System for RDF and SPARQL

22

A Detailed Example (2)

• Typed Dependencies[nsubj(bought-2, Aliana-1), root(ROOT-0,

bought-2), det(car-4, a-3), dobj(bought-2, car-4)]

Page 23: Dependency Parsing-based QA System for RDF and SPARQL

23

A Detailed Example (3)RDF:<http://example.org/sentence/car> <http://example.org/sentence/det> <http://example.org/sentence/a> . <http://example.org/sentence/root> <http://example.org/sentence/root> <http://example.org/sentence/bought> . <http://example.org/sentence/bought> <http://example.org/sentence/dobj> <http://example.org/sentence/car> ; <http://example.org/sentence/nsubj> <http://example.org/sentence/aliana> .

Page 24: Dependency Parsing-based QA System for RDF and SPARQL

24

A Detailed Example (4)

KB has:We have the following triple in the knowledge base

already::bought owl:sameAs :purchased .

and also the following rules:PREFIX : <http://example.org/sentence/>CONSTRUCT {:vehicle ?y ?z} WHERE {:car ?y ?z}PREFIX : <http://example.org/sentence/>CONSTRUCT {?x ?y :vehicle} WHERE {?x ?y :car}

Page 25: Dependency Parsing-based QA System for RDF and SPARQL

25

A Detailed Example (5)

Inferred facts:<http://example.org/sentence/purchased> <http://example.org/sentence/dobj> <http://example.org/sentence/vehicle> ;<http://example.org/sentence/nsubj> <http://example.org/sentence/aliana> .

Page 26: Dependency Parsing-based QA System for RDF and SPARQL

26

A Detailed Example (6)

Typed dependencies of question:[nsubj(purchased-2, Who-1), root(ROOT-0,

purchased-2), det(vehicle-4, a-3), dobj(purchased-2, vehicle-4)]

Page 27: Dependency Parsing-based QA System for RDF and SPARQL

27

A Detailed Example (7)

SPARQL form of question:SELECT ?x WHERE {

:vehicle :det :a .:purchased :nsubj ?x .:purchased :dobj :vehicle .:root :root :purchased }

Answer: “aliana”

Page 28: Dependency Parsing-based QA System for RDF and SPARQL

28

DBpedia Integration

• By adding some background knowledge from DBpedia, one can ask more questions.

• Example of Italy data::italy owl:sameAs dbpedia:Italy .

dbpedia:Italy dbpprop:capital "Rome" .dbpedia:Enzo_Ferrari dbpedia-owl:nationality

dbpedia:Italy ; dbpprop:deathPlacedbpedia:Maranello .dbpedia:Enzo_Ferrari dbpedia-owl:childdbpedia:Piero_Ferrari ,dbpedia:Alfredo_Ferrari .

Page 29: Dependency Parsing-based QA System for RDF and SPARQL

29

Example Case

• Fact = “Fariz loves Italy.”• Question = “Does Fariz love a country, whose

capital is Rome, which was the nationality of a person who passed away in Maranello and whose sons are Piero Ferrari and Alfredo Ferrari?”

• Thus the answer will be: YES, eventhough we only have a fact, Fariz loves Italy.

Page 30: Dependency Parsing-based QA System for RDF and SPARQL

30

Example Case (cont.)

• Note that, the previous example, the fact is translated automatically by the system but the question is translated manually to be the following SPARQL query:ASK WHERE { :love :nsubj :fariz . :root :root :love . :love :dobj ?x . ?x dbpprop:capital "Rome" . ?y dbpedia-owl:nationality ?x ; dbpprop:deathPlacedbpedia:Maranello .?y dbpedia-owl:childdbpedia:Piero_Ferrari , dbpedia:Alfredo_Ferrari }

Page 31: Dependency Parsing-based QA System for RDF and SPARQL

31

How to handle negation? (1)• Fact: I did not buy it.• RDF:<http://example.org/sentence/root> <http://example.org/sentence/root> <http://example.org/sentence/bought> .

<http://example.org/sentence/bought> <http://example.org/sentence/dobj> <http://example.org/sentence/it> ; <http://example.org/sentence/neg> <http://example.org/sentence/not> ; <http://example.org/sentence/nsubj> <http://example.org/sentence/i> .

Page 32: Dependency Parsing-based QA System for RDF and SPARQL

32

How to handle negation? (2)

• Question: Who bought it?• SPARQL:SELECT ?x WHERE {:bought :nsubj ?

x . :bought :dobj :it . :root :root :bought . FILTER NOT EXISTS { [] :neg ?z . } }

Page 33: Dependency Parsing-based QA System for RDF and SPARQL

33

How to handle negation? (3)

• Who did not buy it? I.QUERY: SELECT ?x WHERE

{:bought :dobj :it . :bought :neg :not . :bought :nsubj ?x . :root :root :bought }

Page 34: Dependency Parsing-based QA System for RDF and SPARQL

34

How to handle tenses? (1)

• Fact (I will buy it):<http://example.org/sentence/buy> <http://example.org/sentence/aux> <http://example.org/sentence/will> ; <http://example.org/sentence/dobj> <http://example.org/sentence/it> ; <http://example.org/sentence/nsubj> <http://example.org/sentence/i> .

Page 35: Dependency Parsing-based QA System for RDF and SPARQL

35

How to handle tenses? (2)

• Who buys it?• SELECT ?x WHERE

{:root :root :buys . :buys :nsubj ?x . :buys :dobj :it . FILTER NOT EXISTS { [] :aux :will . } }

Page 36: Dependency Parsing-based QA System for RDF and SPARQL

36

How to handle passive sentences?

Fact: Juliet was killed by Romeo.<http://example.org/sentence/root> <http://example.org/sentence/root> <http://example.org/sentence/killed> .

<http://example.org/sentence/killed> <http://example.org/sentence/agent> <http://example.org/sentence/romeo> ; <http://example.org/sentence/nsubjpass> <http://example.org/sentence/juliet> .

Page 37: Dependency Parsing-based QA System for RDF and SPARQL

37

How to handle passive sentences?

• Ontology::nsubjpass owl:equivalentProperty :dobj .

:agent owl:equivalentProperty :nsubj .

Page 38: Dependency Parsing-based QA System for RDF and SPARQL

38

How to handle passive sentences?

• Who killed Juliet?SELECT ?x WHERE {:killed :nsubj ?

x . :killed :dobj :juliet . :root :root :killed . FILTER NOT EXISTS { [] :neg ?z . }}

Page 39: Dependency Parsing-based QA System for RDF and SPARQL

39

DEMO - A Story about Antonio

Antonio is a famous and cool doctor. Antonio has been working for 10 years. Antonio is in Italy. Antonio can dance Salsa well. Antonio loves Maria and Karina. Antonio is also loved by Karina. Antonio never cooks. But Maria always cooks. Antonio just bought a car. Antonio must fly to Indonesia tomorrow.

Page 40: Dependency Parsing-based QA System for RDF and SPARQL

40

Conclusions

• Dependency parsing-based QA system with RDF and SPARQL

• The system is also aware of negations, tenses and passive sentences

• Improvements: More advanced parsing method, more efficient inference system, richer background knowledge

Page 41: Dependency Parsing-based QA System for RDF and SPARQL

41

APPENDIX: EXAMPLES

Page 42: Dependency Parsing-based QA System for RDF and SPARQL

42

Working Examples

• "The Japanese girl sang the song beautifully."

• "Who sang the song beautifully?" • "Who sang the song?"• "Who sang?"

Page 43: Dependency Parsing-based QA System for RDF and SPARQL

43

Working Examples

• "The Beatles do sing the song perfectly.“

• "How do The Beatles sing the song?"

Page 44: Dependency Parsing-based QA System for RDF and SPARQL

44

Working Examples

• "They should sing the song well.“

• "How should they sing the song?"

Page 45: Dependency Parsing-based QA System for RDF and SPARQL

45

Working Examples

• "I did buy the book, the pencil and the ruler yesterday.“

• "What did I buy?"

Page 46: Dependency Parsing-based QA System for RDF and SPARQL

46

Working Examples

• "Microsoft is located in Redmond.“

• "What is located in Redmond?"

Page 47: Dependency Parsing-based QA System for RDF and SPARQL

47

Working Examples

• "The man was killed by the police."

• "Who killed the man?"

Page 48: Dependency Parsing-based QA System for RDF and SPARQL

48

Working Examples

• "Sam is genius, honest and big."

• "Who is big?"

Page 49: Dependency Parsing-based QA System for RDF and SPARQL

49

Working Examples

• "John is rude.";

• "Is John good?"• "Is John rude?"

Page 50: Dependency Parsing-based QA System for RDF and SPARQL

50

Working Examples

• "John, that is the founder of Microsoft and the initiator of Greenpeace movement, is genius, honest and cool."

• "Who is honest?"

Page 51: Dependency Parsing-based QA System for RDF and SPARQL

51

Working Examples

• "Farid wants to go to Rome.“

• "Who wants to go to Rome?"• "Who wants to go?"• "Who wants?"

Page 52: Dependency Parsing-based QA System for RDF and SPARQL

52

Working Examples

• "Jorge ate 10 delicious apples."

• "Who ate 10 delicious apples?"• "Who ate 10 apples?"• "Who ate apples?"

Page 53: Dependency Parsing-based QA System for RDF and SPARQL

53

Working Examples

• "John is a doctor.“

• "Is John a doctor?"• "Is John a teacher?"

Page 54: Dependency Parsing-based QA System for RDF and SPARQL

54

Working Examples

• "John is a good doctor."

• "Who is John?"• "What is John?"

Page 55: Dependency Parsing-based QA System for RDF and SPARQL

55

Working Examples

• "John is in Alaska."• "John is at home."• "John is on the street."

• "Where is John?"

Page 56: Dependency Parsing-based QA System for RDF and SPARQL

56

Working Examples

• "Apples are good for health.“

• "What are good for health?"