extracting structure from the web

21
Extracting structure from the web 1 Extracting structure from the web Maarten Marx GODDAG workshop Dec 2008,GODDAG workshop

Upload: others

Post on 09-Feb-2022

4 views

Category:

Documents


0 download

TRANSCRIPT

Extracting structure from the web 1

Extracting structure from the webMaarten Marx

GODDAG workshop

Dec 2008,GODDAG workshop

Extracting structure from the web 2

Summary

Extracting structure from the web 3

Take home messages

• There is a $%&*# lot of structured data on the web,

unfortunately not in XML.

• Extra task: exemelification

• Chosen representation may have

weird and unexpected conseqyences

• Formal methods can really help.

Extracting structure from the web 4

Modelling data as XML

• Structured data on the web can (almost) always be represented as

trees.

• Choice of representation determines

? query processing costs

? needed expressive power for your

∗ query language

∗ constraint language

? robustness for changes in the data-structures

Extracting structure from the web 5

Example: interviews

• Sigmod Record Distinguished DB Profiles

• Simple model:

An interview consists of a list of questions each followed by

a list of answers.

Extracting structure from the web 6

exemelify this

Extracting structure from the web 7

TREE model

• Query: return all Question–Answer pairs

• In XPath 2.0:

• for $q in //Q return ($q,$q/A)

Extracting structure from the web 8

Same query on the FLAT model

• Query: return all A-nodes answering a give Q node

• Flat tree model:

? use the document-order or the sibling-order

? all A nodes after the given Q, but before the next Q

? 3 variables . . .

? not Core XPath expressible . . .

? the wanted A-nodes must satisfy A ∧ since($q,¬Q)

Extracting structure from the web 9

Same query on the FLAT model: XPath 2.0

• Query: return all A-nodes answering a give Q node

for $Q in //Q return ($Q,$Q(following-sibling::A exceptfollowing-sibling::Q/following-sibling::A))

Extracting structure from the web 10

Constraining the models: tree vs flat

• XML constraint languages are based on tree-automata

Flat model interview -> (Q,A+)+

Tree model interview -> Q+. Q -> A+

Data Actual question and answer text is stored in attribute nodes.

Extracting structure from the web 11

Constraining the models: tree vs flat: robustness

• Example: Extend our constraints: every interview ends with a

bye-bye question which receives no answer.

• In all models this is expressible as a FO sentence: thus a regular

tree language.

New Flat model Easy: interview -> (Q,A+)+,Q

New Tree model Hard! Not expressible in XML Schema. (proof

later)

Extracting structure from the web 12

Bad!

• Difficult to accept and understand non-expressibility by

practitioners

• leads to underspecified documents

• leads to frustration and unsafe coupling

Extracting structure from the web 13

New Tree model

• We need types to express the last answerless question.

• Specialized DTD’s = MSO = regular tree languages

[Papakonstantinou, Vianu 00]

• NormalQ and EndQ are types of Q

• interview -> NormalQ+,EndQ

• NormalQ -> A+

• EndQ -> EMPTY

Extracting structure from the web 13

New Tree model

• We need types to express the last answerless question.

• Specialized DTD’s = MSO = regular tree languages

[Papakonstantinou, Vianu 00]

• NormalQ and EndQ are types of Q

• interview -> NormalQ+,EndQ

• NormalQ -> A+

• EndQ -> EMPTY

Extracting structure from the web 14

Non–robustness proof

• XML schema’s are single-typed SDTD’s [Murata, Lee, Mani ’01]

• [Martens, Neven, Schwentick 05] For T a regular tree language, T

is definable by a single type SDTD iff T is closed under

ancestor-guarded subtree exchange.

Extracting structure from the web 15

(QA+)+Q is not definable on hierarchical models

• Interviews ending in a Q without an A.

• We could not find a DTD specifying this in the hierarchical model.

• Now we can prove it:

Extracting structure from the web 16

Main points

• Textual data leads to flat linearly structured XML.

• Flat XML is easy to constrain: just regular expressions

• but difficult to query: simple XPath 1.0 is not sufficient

Extracting structure from the web 17

Difficult to query????

QUERY: Return all QA pairs in the flat model.

Extracting structure from the web 17

Difficult to query????

QUERY: Return all QA pairs in the flat model.

for $Q in //Q return($Q,$Q(next-sibling::A)*)

Extracting structure from the web 18

KR on the web: wrap up

• Most information on the web is in implicitly structured text.

• Asking complex queries to the web thus means to extract and

make this structure explicit.

• This often leads to rather flat (“reading text-ordered”) XML.

• KR languages are important to describe, constrain and validate

the XML,

• because these XML files are themselves often input to other

knowledge-extraction programs (tree-transformations, queries)

Extracting structure from the web 19

End