INFORMATICA UMANISTICA B DA DATI NON STRUTTURATI A DATI STRUTTURATI: LINGUAGGI DI MARCATURA XML TEI.

Post on 01-May-2015

221 views 1 download

transcript

INFORMATICA UMANISTICA B

DA DATI NON STRUTTURATI A DATI STRUTTURATI: LINGUAGGI DI

MARCATURAXMLTEI

AGGIUNGERE STRUTTURA A DATI NON STRUTTURATI USANDO LINGUAGGI DI MARCATURA

In questa lezione e la prossima discuteremo di come sia possibile usare LINGUAGGI DI MARCATURA come XML per rendere ‘parzialmente strutturati’ dati testuali Oggi: aggiungere struttura a testi Prossima lezione: aggiungere informazione

semantica

LINGUAGGI DI MARCATURA

Permettono di aggiungere informazione (‘annotare’) un testo

Due tipi di informazione: Aspetto (formattazione, disposizione degli

elementi sulla pagina) HTML

Struttura logica XML

TIPI DI LINGUAGGI DI MARCATURA

‘Procedurali’ (TeX, LaTeX, nroff, troff) Indicano alla macchina la procedura di

formattazione da seguire per un certo testo ‘Generici’ o ‘dichiarativi’ (SGML e

discendenti) Dichiarano la funzione LOGICA del testo

TeX e LaTeX

The quadratic formula is $-b \pm \sqrt{b^2 - 4ac} \over 2a$ \end

a

XMLXML

SGMLSGMLHTMLHTML

XHTMLXHTML

WMLWML MathMLMathML

……

SGML

Sviluppato nel 1986 da Charles Goldfarb Obiettivo: sviluppare uno standard per

l’INTERSCAMBIO di testi Consente di definire marcatori (‘TAGS’) che

permettono di strutturare un testo ed i loro ATTRIBUTI

Utilizzato per: BNC OED

STRUTTURA SGML NEL BNC

<div1 complete=y org=seq> <head> <s n=00040> <w NN2>TROUSERS <w VVB>SUIT </head> <caption> <s n=00041> <w EX0>There <w VBZ>is <w PNI>nothing <w AJ0>masculine <w PRP>about <w DT0>these <w AJ0>new <w NN1>trouser <w NN2-VVZ>suits <w PRP>in <w NN1>summer<w POS>'s <w AJ0>soft <w NN2>pastels<c PUN>. <s n=00042> <w NP0>Smart <w CJC>and <w AJ0>acceptable <w PRP>for <w NN1>city <w NN1-VVB>wear <w CJC>but <w AJ0>soft <w AV0>enough <w PRP>for <w AJ0>relaxed <w NN2>days </caption>

TAG

TAG

ATTRIBUTO

DTD

La specifica degli elementi e dei loro attributi in un documento SGML costituisce la DEFINIZIONE DEL TIPO DI DOCUMENTO o DTD

HTML

Un linguaggio di marcatura basato su SGML (una DTD SGML)

Tipo di elementi e’ fissato

LINGUAGGI DI MARCATURA: HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Draft//EN"> <html>

<head><title>My first HTML</title>

</head><body>

<p> Hello, World! </p></body>

</html>

XML

Una versione semplificata di SGML sviluppata dal W3C

Come in SGML, ed a differenza di HTML, le TAG non sono predefinite ma definite usando un DTD o SCHEMA

ALBERI

I documenti SGML, HTML ed XML hanno una struttura ad ALBERO

DOCUMENTI XML HANNO UNA STRUTTURA AD ALBERO

Must have a UNIQUE root element

LA STRUTTURA AD ALBERO DEI DOCUMENTI HTML (ED XML)

<html>

<head><title> My first HTML</title>

</head><body>

<p> Hello, World! </p></body>

</html>

LA STRUTTURA AD ALBERO DEI DOCUMENTI HTML

html

head body

title p

ACCESSO AD UN ALBERO

html

head body

title p

figlie

madre

XML PER LA STRUTTURA LOGICA DI TESTI

<recipe>

<title> Peanut butter on a spoon </title>

<ingredientlist>

<ingredient>Peanut butter </ingredient>

</ingredientlist>

<preparation>Stick a spoon in a jar of peanut butter, scoop and pull out a big glob of peanut butter.</preparation>

</recipe>

ALBERI + ATTRIBUTI IN XML

verse verse

Seest thou yon dreary Plain, forlorn and wild,

poemtitle = Paradise Lostauthor = jmyear= 1667

verse

ATTRIBUTI IN XML

TITLE: Paradise Lost

AUTHOR: John Milton

YEAR: 1667

<poem title=“paradise lost” author="jm" year="1667"> <verse> Seest thou yon dreary Plain, forlorn and wild,</verse> <verse>The seat of desolation, void of light,</verse> <verse>Save what the glimmering of these livid flames</verse> <verse>Casts pale and dreadful?</verse> </poem>

ATTRIBUTI Elements can contain one or more attributes <phone area_code='0461'>881607</phone> Names are case sensitive The values of the attributes must be enclosed within

single or double quotes (either both single or both double)

Attributes cannot be empty (name only) No attribute can be repeated twice within an

element

BASI DATI IN XML: RUBRICA

<RUBRICA>   <PERSONA>      <DATI_ANAGRAFICI>         <NOME>Giulio</NOME>         <COGNOME>Cesare</COGNOME>         <INDIRIZZO>            <PIAZZA>Bruto</PIAZZA>            <N_CIVICO>10</N_CIVICO>            <CITTA>Roma</CITTA>            <CAP>10100</CAP>         </INDIRIZZO>      </DATI_ANAGRAFICI>      <TELEFONO>         <FISSO>            <NUMERO prefisso="06">321654</NUMERO>         </FISSO>         <MOBILE>            <NUMERO compagnia="blu">32557684785</NUMERO>         </MOBILE>      </TELEFONO>   </PERSONA>   <PERSONA>      <DATI_ANAGRAFICI>         <NOME>Giovanni</NOME>         <COGNOME>Pompeo</COGNOME>         <INDIRIZZO>            <PIAZZA>Catilina</PIAZZA>            <N_CIVICO>12</N_CIVICO>            <CITTA>Milano</CITTA>            <CAP>12100</CAP>         </INDIRIZZO>      </DATI_ANAGRAFICI>      <TELEFONO>         <FISSO>            <NUMERO prefisso="02">96877564</NUMERO>         </FISSO>         <MOBILE>            <NUMERO compagnia="tim">3356545342</NUMERO>         </MOBILE>      </TELEFONO>   </PERSONA></RUBRICA>

RUBRICA COME ALBERO

TEXT ENCODING INITIATIVE

Un’iniziativa internazionale per sviluppare standards per l’archiviazione di testi

Inizi: 1987 Standard basato su SGML agli inizi, ora XML Definizione:

http://www.tei-c.org/release/doc/tei-p5-doc/en/Guidelines.pdf

TESTI IN FORMATO TEI

<TEI.2><teiHeader>[informazioni della testata TEI] </teiHeader><text><front> [materiali dell'avantesto] </front><body> [testo unitario] </body><back> [materiali annessi] </back></text><TEI.2>

TEXT ENCODING INITIATIVE una testata TEI, codificata come <teiHeader> (frontespizio

elettronico), che raccoglie la serie delle informazioni paratestuali e metatestuali di riferimento (descrizione dell'esemplare elettronico, di quello cartaceo di riferimento, delle norme di codifica seguite e delle revisioni effettuate)

il testo vero e proprio, marcato con l'elemento <text>, suddiviso in tre elementi: <front> (avantesto: frontespizio dell'esemplare cartaceo di

riferimento e materiali introduttivi come prefazioni, dediche, sommari, introduzioni, indici etc.)

<body> (corpo del documento, a sua volta strutturato in partizioni significative del componimento, variabili a seconda della tipologia: testo in prosa, in versi, testo teatrale, ecc.)

<back> (materiali annessi come glossari, indici, note, bibliografie, colophon etc.)

TEI Header

<teiHeader> <fileDesc> <titleStmt> ... </titleStmt> <publicationStmt> ... <publicationStmt> <sourceDesc> ... <sourceDesc> </fileDesc> </teiHeader>

<fileDesc>

L’elemento <fileDesc> contiene tutte le informazioni bibliografiche

TEI HEADER: titleStmt

<titleStmt> <title>Two stories by Edgar Allen Poe: a machine readable transcription</title> <author>Poe, Edgar Allen (1809-1849) <respStmt><resp>compiled by</resp> <name>James D. Benson</name></respStmt> </titleStmt>

TEI HEADER: publicationStmt

<publicationStmt> <publisher>Oxford University Press</publisher> <pubPlace>Oxford</pubPlace> <date>1989</date> <idno type="ISBN"> 0-19-254705-5</idno> <availability>Copyright 1989, Oxford University Press</availability> </publicationStmt>

TEI HEADER: IL PRINCIPE<teiheader type="ISBD(M)"><filedesc> <titlestmt> <title type="princ">Il Principe</title> <author> <persname key="Machiavelli"> <surname>Machiavelli</surname> <forename>Niccolò</forename> </persname> </author> …. </titlestmt> <editionstmt> <edition>Prima edizione</edition></editionstmt> <extent>ca. 200 kb</extent> <publicationstmt> <publisher> ….. </publisher> <pubplace>Bologna</pubplace> <idno type="1">1</idno> …. </publicationstmt>

KING LEAR IN FORMATO PROJECT GUTENBERG

Kent. Now by Apollo, king, Thou swear'st thy gods in vain.

Lear. O vassal! miscreant!

[Laying his hand on his sword.]

Alb. and Corn. Dear sir, forbear!

Kent. Do; Kill thy physician, and the fee bestow Upon the foul disease. Revoke thy gift, Or, whilst I can vent clamour from my throat, I'll tell thee thou dost evil.

KING LEAR IN FORMATO TEI

<sp><speaker>Kent</speaker> <p>Now by Apollo, king,<lb/> Thou swear'st thy gods in vain.<lb/></p></sp>

<sp><speaker>Lear</speaker> <p>O vassal! miscreant!<lb/></p></sp>

<p><stage>Laying his hand on his sword.</stage><p>

<sp><speaker>Alb. and Corn.</speaker> <p>Dear sir, forbear!<lb/></p></sp>

<sp><speaker>Kent.</speaker> <p>Do;<lb/> Kill thy physician, and the fee bestow<lb/> Upon the foul disease. Revoke thy gift,<lb/> Or, whilst I can vent clamour from my throat,<lb/>I'll tell thee thou dost evil.<lb/></p></sp>

TEI: JANE EYRE

CHAPTER 38

READER, I married him. A quiet wedding we had: he and I, the par- son and clerk, were alone present. When we got back from church, I went into the kitchen of the manor-house, where Mary was cooking the dinner, and John cleaning the knives, and I said –

'Mary, I have been married to Mr Rochester this morning.' The housekeeper and her husband were of that decent, phlegmatic order of people, to whom one may at any time safely communicate a remarkable piece of news without incurring the danger of having one's ears pierced by some shrill ejaculation and subsequently stunned by a torrent of wordy wonderment. Mary did look up, and she did stare at me; the ladle with which she was basting a pair of chickens roasting at the fire, did for some three minutes hang suspended in air, and for the same space of time John's knives also had rest from the polishing process; but Mary, bending again over the roast, said only --

Text markup

<pb n='474'/>

<div1 type="chapter" n='38'>

<p>Reader, I married him. A quiet wedding we had: he and I, the parson and clerk, were alone present. When we got back from church, I went into the kitchen of the manor-house, where Mary was cooking the dinner, and John cleaning the knives, and I said &mdash;</p>

<p><q>Mary, I have been married to Mr Rochester this morning.</q> The housekeeper and her husband were of that decent, phlegmatic order of people, to whom one may at any time safely communicate a remarkable piece of news without incurring the danger of having one's ears pierced by some shrill ejaculation and subsequently stunned by a torrent of wordy wonderment. Mary did look up, … </p>

ARCHIVI BASATI SULLA TEI

Biblioteca Italiana: www.bibliotecaitaliana.it

Electronic Text Center: etext.lib.virginia.edu

Humanities Text Initiative: www.hti.umich.edu

Oxford Text Archive ota.ahds.ac.uk

LA BIBLIOTECA ITALIANA

XML – DTD – XSL

Un file XML specifica il contenuto

Un DTD o SCHEMA specifica la SINTASSI

Un file XSL specifica come VISUALIZZARE

IDEE PRINCIPALI LEZIONE DI OGGI

Linguaggi di marcatura XML

Struttura ad albero Attributi

Text Encoding Initiative Archivi basati sulla TEI

LETTURE

Tomasi, cap. 4 Linguaggi di Marcatura XML TEI:

Tutorials: Gentle introduction to XML

http://www.tei-c.org/release/doc/tei-p5-doc/en/html/SG.html

TEI-LITE http://www.tei-c.org/Guidelines/Customization/Lite/teiu5_split_en.html