Download presentation
Presentation is loading. Please wait.
Published byAlexina Boone Modified over 9 years ago
1
Logics for Data and Knowledge Representation Exercises: Languages Fausto Giunchiglia, Rui Zhang and Vincenzo Maltese
2
Outline BNF grammars Basic exercises BNF for ER diagrams BNF for natural languages (POS tagging) 2
3
Backus–Naur Form (BNF) BNF is a syntax used to express context-free grammars: that is, a formal way to describe formal languages. Optional items are enclosed in square brackets: [ ] Items repeating 0 or more times are enclosed in curly brackets and/or suffixed with an asterisk: { }* Items repeating 1 or more times are followed by a + Terminals may appear in bold and Non-Terminals in plain text rather than using italics and angle brackets <> Alternative choices in a production are separated by the | symbol Where items need to be grouped they are enclosed in simple parentheses (). 3 BNF GRAMMARS :: BASIC EXERCISES :: BNF AND ER DIAGRAMS :: POS TAGGING
4
Example of BNF: A mathematical expression 1. ::= [ ] 2. ::= [ ] [. ] 3. ::= { }* 4. ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 5. ::= + | - 6. ::= + | - | * | / 4 BNF GRAMMARS :: BASIC EXERCISES :: BNF AND ER DIAGRAMS :: POS TAGGING
5
Exercises of BNF: mathematical expressions Are the following well-formed formulas of expression? 1. 123 2. 00123 3. 199 + 299 4. + 20 * 200 5. + - 345 / (123 + 456) 1. YES 2. YES 3. YES 4. YES 5. NO 5 BNF GRAMMARS :: BASIC EXERCISES :: BNF AND ER DIAGRAMS :: POS TAGGING
6
Exercises of BNF: PL language Consider the BNF for the PL language above: ::= A | B |... | P | Q |... | ⊥ | ⊤ ::= | ¬ | ∧ | ∨ Differentiate wff from others below: 1. A ⊔ B ⊒ A 2. A ⊓ B ⊑ B 3. A ∧ ¬ B 4. A ∧ B ⊨ A ∨ B 5. ¬ A ∨ B ∧ ⊤ 1. NO 2. NO 3. YES 4. NO 5.YES 6 BNF GRAMMARS :: BASIC EXERCISES :: BNF AND ER DIAGRAMS :: POS TAGGING
7
In software engineering, an Entity-Relationship (ER) Model is an abstract and conceptual representation of data. The basic components of ER: Entity Relation Cardinality of Relation Cardinality of Attribute Attribute Primary Key Recall: ER Diagram 7 MonkeyBox Climb 0..10..n Banana Height ID BNF GRAMMARS :: BASIC EXERCISES :: BNF AND ER DIAGRAMS :: POS TAGGING
8
The BNF for ER Diagrams ::= ::= [ “..” ] ::= 0 | 1 | n | m ::= { }* | { }* :: = { }* 8 Entity Relation Attribute BNF GRAMMARS :: BASIC EXERCISES :: BNF AND ER DIAGRAMS :: POS TAGGING
9
BNF of Yahoo! Directory The Yahoo! Directory is an online guide to the World Wide Web. It is a catalog of sites created by a staff of editors who visit and evaluate web sites, and then organize them into subject-based categories and sub-categories. Yahoo! editors distinguish between a number of factors when organizing web sites, including commercial vs. non-commercial, regional vs. global, and so forth. All of the site listings in the Directory are contained in an appropriate place within the 14 main categories seen on the front page of the Yahoo! Directory. 9 BNF GRAMMARS :: BASIC EXERCISES :: BNF AND ER DIAGRAMS :: POS TAGGING
10
So take a look! 10 BNF GRAMMARS :: BASIC EXERCISES :: BNF AND ER DIAGRAMS :: POS TAGGING
11
Preliminaries: Open/Close Word Class In linguistics, an open class (or open word class) is a word class that accepts the addition of new items, through such processes as compounding, derivation, coining, borrowing, etc. Typical open word classes are nouns, verbs and adjectives. A closed class (or closed word class) is a word class to which no new items can normally be added, and that usually contains a relatively small number of items. Typical closed classes found in many languages are adpositions (prepositions and postpositions), determiners, conjunctions, and pronouns. 11 BNF GRAMMARS :: BASIC EXERCISES :: BNF AND ER DIAGRAMS :: POS TAGGING
12
Parts of Speech: open word class OPEN WORD CLASSEXAMPLE JJ//Adjective blue / green / soft NN//Noun, singular or mass apple / sugar NNS//Noun, plural apples NNP//Proper noun, singular Fausto RB//Adverb slowly VB//Verb, base form go VBD//Verb, past tense went VBZ//Verb, 3rd person singular present goes 12 BNF GRAMMARS :: BASIC EXERCISES :: BNF AND ER DIAGRAMS :: POS TAGGING
13
Parts of Speech: closed word class CLOSED WORD CLASSEXAMPLE CC//Coordinating conjunction and / or CD//Cardinal number DT//Determiner the / an / a IN//Preposition or subordinating conjunction in / for / but POS//Possessive ending TO//toto 13 BNF GRAMMARS :: BASIC EXERCISES :: BNF AND ER DIAGRAMS :: POS TAGGING
14
BNF for Yahoo Directory (1) ForwardPhrase::= [VB] [IN] DisPhrase {Conn } DisPhrase (2) DisPhrase::= Phrase [“(”ProperDis | NounDis“)”] [“(”Period“)”][“:” Phrase] (3) Phrase::=[DT] Adjectives [Nouns] | [Proper] Nouns (4) Adjectives::= Adjective|CD {[CC] Adjective} (5) Nouns::= Noun {Noun} (6) Conn::= ConjunctionConn | PrepositionConn (7) Noun::= NN [POS] | NNS [POS] (8) Adjective::= JJ (9) ConjunctionConn::= CC | “,” (10) PrepositionConn::= IN | TO (11) Proper::= NNP {NNP|POS} (12) NounDis::= Period|Nouns|Adjectives [Nouns] (13) ProperDis::= ProperSeq [CC ProperSeq] (14) Period::= [NN] CD [“-”] [CD] [NN] (15) ProperSeq::= Proper [“,” Proper] 14 BNF GRAMMARS :: BASIC EXERCISES :: BNF AND ER DIAGRAMS :: POS TAGGING
15
Example: Provinces and Districts 15 ForwardPhrase DisPhrase Phrase Nouns Noun NNS Conn ConjunctionConn CC ForwardPhrase DisPhrase Provinces and Districts Phrase Nouns Noun NNS BNF GRAMMARS :: BASIC EXERCISES :: BNF AND ER DIAGRAMS :: POS TAGGING
16
Examples Science > Computer Science > Artificial Intelligence > Natural Language Processing > Web Directories Computer Science NN Artificial Intelligence JJ NN Natural Language Processing JJ NN VBG Web Directories NN NNS 16 BNF GRAMMARS :: BASIC EXERCISES :: BNF AND ER DIAGRAMS :: POS TAGGING
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.