SlideShare ist ein Scribd-Unternehmen logo
1 von 55
Downloaden Sie, um offline zu lesen
Knowledge Representation
in
Digital Humanities
Antonio Jiménez Mavillard
Department of Modern Languages and Literatures
Western University
Lecture 3
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard
* Contents:
1. Why this lecture?
2. Discussion
3. Chapter 3
4. Assignment
5. Bibliography
2
Why this lecture?
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard
* This lecture...
· trains the problem solving skill by means
of algorithm formalization
· prepares the ground to write real
programs
3
Last assignment discussion
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard
* Time to...
· consolidate ideas and
concepts dealt in the readings
· discuss issues arised in the specific
solutions to the projects
4
Chapter 3
Fundamentals of Programming
1. Designing algorithms
2. Elements of a program
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard5
Chapter 3
1 Designing algorithms
1.1 The programming process
1.2 What is an algorithm?
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard6
Chapter 3
2 Elements of a program
2.1 What is a program?
2.2 Components of a program
2.3 Types of errors
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard7
Designing algorithms
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard8
The programming process
* Programming cycle:
1. Define the problem
2. Plan the solution
3. Code the program
4. Test the program
5. Document the process
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard9
The programming process
* Define the problem
· Identify the input data
(what we have)
· Determine the output information
(what we want to obtain)
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard10
The programming process
* Plan the solution
· Design an algorithm
+ by drawing a flow diagram
+ by writing pseudocode
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard11
The programming process
* Code the program
· Translate the algorithm into a
programming language
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard12
The programming process
* Test the program
· Verify if for certain input, the program
produces the correct output
· Find and fix errors (debugging):
+ syntax
+ runtime
+ semantic
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard13
The programming process
* Document the process
· Describe the problem and the solution
· Include pseudocode or flow diagrams
· Report testing results
· Comment the code
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard14
References
Glassborow, Francis. “Chapter 1: You Can Program.” You Can Do It!: A Beginner’s Introduction to Computer
Programming. Chichester, West Sussex, England; Hoboken, NJ: John Wiley, 2004. Print.
Mohd Harris. “PROG0101 - Fundamentals of Programming.” N. p., n.d. Web. 17 Jan. 2014.
Perry, Greg M. “Chapter 2: Anatomy of a Program.” Absolute Beginner’s Guide to Programming. Indianapolis, Ind.: Que
Pub., 2003. Print.
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard15
What is an algorithm?
* Definitions
· A detailed plan to solve a problem
· A step-by-step set of instructions for
solving a problem
· A finite process that if followed will
solve a problem
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard16
What is an algorithm?
* Characterized by 5 properties:
1. Input: initial data
2. Output: final result
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard17
What is an algorithm?
* Characterized by 5 properties:
3. Finiteness: has to terminate in a finite
number of steps
4. Definiteness: each step has to be
unambiguously specified
5. Effectiveness: each step should be
doable in a finite time by a human
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard18
What is an algorithm?
* Exercise 1
· A recipe is an algorithm that solve the
next problem: how to prepare a meal
· Search for the recipe of Green Tea
Berry Delight
(http://allrecipes.com/Recipe/Green-Tea-Berry-Delight/Detail.aspx)
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard19
What is an algorithm?
* Exercise 1
· Identify: input, output and steps
· Answer the following questions:
+ Is the recipe finite?
+ Is each step definite?
+ Is each step effective?
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard20
What is an algorithm?
* Exercise 1
(solution)
· Recipe:
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard21
What is an algorithm?
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard22
What is an algorithm?
* Exercise 1 (solution)
· Is the recipe finite?
Yes, it is done in 5 minutes
· Is each step definite?
Yes, they are not ambiguous
· Is each step effective?
Yes, in fact they are thought to be
done by a human
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard23
What is an algorithm?
* Exercise 2
· Design an algorithm to divide two
numbers by using only additions and
substractions
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard24
What is an algorithm?
* Exercise 2 (solution)
· Solve the specific case: divide 7 by 3
Hint: how many times is 3 contained in 7?
· Solve the general case: divide A by B
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard25
What is an algorithm?
* Exercise 2 (solution)
· How many times is 3 contained in 7?
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard26
What is an algorithm?
* Exercise 2 (solution)
· Count the number of sustractions
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard27
What is an algorithm?
* Exercise 2
(solution)
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard28
What is an algorithm?
* Exercise 2
(solution)
Is the
algorithm
correct?
Trace for
7/3
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard29
Step 0
  A is 7, B is 3, C is 0
Step 1
  Is 7 >= 3? Yes
    A is now 7 ­ 3 = 4
    C is now 0 + 1 = 1
Step 2
  Is 4 >= 3? Yes
    A is now 4 ­ 3 = 1
    C is now 1 + 1 = 2
Step 3
  Is 1 >= 3? No
Step 4
  Output C, that is 2
References
Cormen, Thomas H. “Chapter 1: The Role of Algorithms in Computing.” Introduction to Algorithms. Cambridge,
Masachusetts; London: The MIT Press, 2009. Print.
De la Rosa, Javier. “Computer Tools for Linguists.” Yutzu. N. p., n.d. Web. 16 Sept. 2013.
Knuth, Donald E. “Chapter 1: Basic Concepts.” The Art of Computer Programming. Volume 1: Fundamental Algorithms.
Vol. 1. Reading, Mass.: Addison-Wesley, 1997. Print.
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard30
Elements of a program
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard31
What is a program?
* Definition
“A program is an implementation of an
algorithm in a program language.”
(The concrete written program is called
source code or just code)
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard32
What is a program?
* Algorithm vs program
· Algorithm:
+ Abstract
+ Represented by a flow diagram,
pseudocode...
+ For human understanding
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard33
What is a program?
* Algorithm vs program
· Program:
+ Concrete
+ Represented by a program language
+ For computer processing
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard34
Components of a program
* The content and structure of a program
depend on the programming language
* Every programming language is formed by
a set of symbols
* The combination of these symbols defines
the programs
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard35
Components of a program
* Programming languages are defined by:
· Morphology
· Syntax
· Semantics
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard36
Components of a program
* Morphology
· Symbols: numbers, letters and special
characters
· Symbols are combined to form tokens:
the basic elements of a language
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard37
Components of a program
* Morphology
· Vocabulary: a set of keywords (special
tokens) with specific funcionality
· Examples in Python:
def, elif, except, print
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard38
Components of a program
* Syntax
· Grammar rules to write a program
+ Tokens
- How the symbols are combined
- Examples in Python:
correct: 3, counter, def
incorrect: $+1, (&variable
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard39
Components of a program
* Syntax
· Grammar rules to write a program
+ Structure
- Way that tokens are arranged
- Expressions, blocks...
- Examples in Python
correct: a += 1
incorrect: a $= 1
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard40
Components of a program
* Semantics
· Meaning of the program
· Examples: how to interpret the order of
the operators
+ Operator precedence
x - 2 * 3 ≡ x - (2 * 3)
+ Operator associativity
x - 2 + 3 ≡ (x - 2) + 3
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard41
Components of a program
* A program is a set of instructions
* An instruction is an statement
* A statement is an executable unit of code
formed by expressions
* An expression is a combination of tokens
* A token is a sequence of symbols
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard42
Components of a program
* Exercise 3
Given the next code...
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard43
fruit = 'banana'
counter = 0
index = 0
while index < len(fruit):
    char = fruit[index]
    if char == 'a':
        counter += 1
    index += 1
print counter
Components of a program
* Exercise 3
... identify:
· Symbols, tokens and keywords
· Some grammar rules
· Its semantics
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard44
Components of a program
* Exercise 3 (solution)
· symbols: letters, numbers, ', <, (, ), :,
=, [, ], and +
· tokens: fruit, =, 'banana', counter, 0,
index, while, <, len(fruit), :, char,
fruit[index], if, ==, 'a', +=, 1, print
· keywords: while, len, if, print
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard45
Components of a program
* Exercise 3 (solution)
· grammar rules: quotations for strings '',
colon after testings :, indentention for
blocks, closing parenthesis after opening
parenthesis (), closing bracket after
opening bracket []
· semantics: counts and print on screen
number of a's in the word “banana”
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard46
References
De la Rosa, Javier. “Computer Tools for Linguists.” Yutzu. N. p., n.d. Web. 16 Sept. 2013.
The Little Introduction To Programming. N. p. Web.
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard47
Types of errors
* Syntax error
The code of the program breaks the
syntax rules of the programming language
* Logic error
The code is syntactically correct but
results in illegal operations in execution
* Semantic error
The program does not behave as expected
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard48
Types of errors
* Examples in Python
· Syntax error
a + 1 = b Assignment malformed
· Logic error
a = 4
b = 0
c = a / b
Division by 0
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard49
my_list = [1, 2, 3, 4]
element = my_list[7]
Access to a non
existing object
Types of errors
* Examples in Python
· Semantic error
It does not print the number of a's
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard50
fruit = 'banana'
counter = 0
index = 0
while index < len(fruit):
    char = fruit[index]
    if char == 'a':
        counter += 1
    index += 1
print fruit
References
Severance, Dr Charles R. “Chapter 1: Why Should You Learn to Write Programs?” Python for Informatics: Exploring
Information. 1 edition. CreateSpace Independent Publishing Platform, 2013. Print.
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard51
Assignment
* Assignment 3: Playing with algorithms
· Readings
+ The Role of Algorithms in Computing
(Introduction to Algorithms)
+ Strings (Python for Informatics)
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard52
Assignment
* Assignment 3: Playing with algorithms
· Project
+ Write an algorithm in Python that
cleans a text of punctuations marks
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard53
O Romeo Romeo wherefore 
art thou Romeo Deny thy 
father and refuse thy 
name Or if thou wilt not 
be but sworn my love And 
I'll no longer be a 
Capulet
O Romeo, Romeo! wherefore 
art thou Romeo? Deny thy 
father and refuse thy 
name; Or, if thou wilt 
not, be but sworn my 
love, And I'll no longer 
be a Capulet.
»
References
Cormen, Thomas H. “Chapter 1: The Role of Algorithms in Computing.” Introduction to Algorithms. Cambridge,
Masachusetts; London: The MIT Press, 2009. Print.
Severance, Dr Charles R. “Chapter 6: Strings” Python for Informatics: Exploring Information. 1 edition. CreateSpace
Independent Publishing Platform, 2013. Print.
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard54
Bibliography
Cormen, Thomas H. Introduction to Algorithms. Cambridge, Masachusetts; London: The MIT Press, 2009. Print.
De la Rosa, Javier. “Computer Tools for Linguists.” Yutzu. N. p., n.d. Web. 16 Sept. 2013.
Glassborow, Francis. You Can Do It!: A Beginner’s Introduction to Computer Programming. Chichester, West Sussex,
England; Hoboken, NJ: John Wiley, 2004. Print.
Knuth, Donald E. The Art of Computer Programming. Volume 1: Fundamental Algorithms. Vol. 1. Reading, Mass.:
Addison-Wesley, 1997. Print.
Mohd Harris. “PROG0101 - Fundamentals of Programming.” N. p., n.d. Web. 17 Jan. 2014.
Perry, Greg M. Absolute Beginner’s Guide to Programming. Indianapolis, Ind.: Que Pub., 2003. Print.
Severance, Dr Charles R. Python for Informatics: Exploring Information. 1 edition. CreateSpace Independent Publishing
Platform, 2013. Print.
The Little Introduction To Programming. N. p. Print.
Knowledge Representation in Digital Humanities
Antonio Jiménez Mavillard55

Weitere ähnliche Inhalte

Ähnlich wie Lecture03

Programming for problem solving ppts unit 1
Programming for problem solving ppts unit 1Programming for problem solving ppts unit 1
Programming for problem solving ppts unit 1lakshmi lingutla
 
structured programming Introduction to c fundamentals
structured programming Introduction to c fundamentalsstructured programming Introduction to c fundamentals
structured programming Introduction to c fundamentalsOMWOMA JACKSON
 
Algorithm for computational problematic sit
Algorithm for computational problematic sitAlgorithm for computational problematic sit
Algorithm for computational problematic sitSaurabh846965
 
Programming Fundamentals using C++
Programming Fundamentals using C++Programming Fundamentals using C++
Programming Fundamentals using C++ALI RAZA
 
Csci101 lect00 introduction
Csci101 lect00 introductionCsci101 lect00 introduction
Csci101 lect00 introductionElsayed Hemayed
 
Teaching of computer programming
Teaching of  computer programmingTeaching of  computer programming
Teaching of computer programmingmarpasha
 
Keynote 1: Teaching and Learning Computational Thinking at Scale
Keynote 1: Teaching and Learning Computational Thinking at ScaleKeynote 1: Teaching and Learning Computational Thinking at Scale
Keynote 1: Teaching and Learning Computational Thinking at ScaleCITE
 
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHESC LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHESHarshJha34
 
James Langley presentation about Computer science & ICT curriculum
James Langley presentation about Computer science & ICT curriculumJames Langley presentation about Computer science & ICT curriculum
James Langley presentation about Computer science & ICT curriculumpetzanet.HR Kurikulum
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)praveena p
 
C programming .pptx
C programming .pptxC programming .pptx
C programming .pptxSuhaibKhan62
 
Programming For Problem Solving Lecture Notes
Programming For Problem Solving Lecture NotesProgramming For Problem Solving Lecture Notes
Programming For Problem Solving Lecture NotesSreedhar Chowdam
 
Meetup 29042015
Meetup 29042015Meetup 29042015
Meetup 29042015lbishal
 

Ähnlich wie Lecture03 (20)

Programming for problem solving ppts unit 1
Programming for problem solving ppts unit 1Programming for problem solving ppts unit 1
Programming for problem solving ppts unit 1
 
Problem solving methodology
Problem solving methodologyProblem solving methodology
Problem solving methodology
 
structured programming Introduction to c fundamentals
structured programming Introduction to c fundamentalsstructured programming Introduction to c fundamentals
structured programming Introduction to c fundamentals
 
Algorithm for computational problematic sit
Algorithm for computational problematic sitAlgorithm for computational problematic sit
Algorithm for computational problematic sit
 
Ch2.ppt
Ch2.pptCh2.ppt
Ch2.ppt
 
UNIT-1.pptx
UNIT-1.pptxUNIT-1.pptx
UNIT-1.pptx
 
01 Programming Fundamentals.pptx
01 Programming Fundamentals.pptx01 Programming Fundamentals.pptx
01 Programming Fundamentals.pptx
 
Lecture01
Lecture01Lecture01
Lecture01
 
Programming Fundamentals using C++
Programming Fundamentals using C++Programming Fundamentals using C++
Programming Fundamentals using C++
 
Csci101 lect00 introduction
Csci101 lect00 introductionCsci101 lect00 introduction
Csci101 lect00 introduction
 
Teaching of computer programming
Teaching of  computer programmingTeaching of  computer programming
Teaching of computer programming
 
Practical 01 (detailed)
Practical 01 (detailed)Practical 01 (detailed)
Practical 01 (detailed)
 
Keynote 1: Teaching and Learning Computational Thinking at Scale
Keynote 1: Teaching and Learning Computational Thinking at ScaleKeynote 1: Teaching and Learning Computational Thinking at Scale
Keynote 1: Teaching and Learning Computational Thinking at Scale
 
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHESC LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
C LANGUAGE-FLOWCHARTS,PSEUDOCODE,ALGORITHMS APPROCHES
 
James Langley presentation about Computer science & ICT curriculum
James Langley presentation about Computer science & ICT curriculumJames Langley presentation about Computer science & ICT curriculum
James Langley presentation about Computer science & ICT curriculum
 
Unit 1 python (2021 r)
Unit 1 python (2021 r)Unit 1 python (2021 r)
Unit 1 python (2021 r)
 
C programming .pptx
C programming .pptxC programming .pptx
C programming .pptx
 
Programming For Problem Solving Lecture Notes
Programming For Problem Solving Lecture NotesProgramming For Problem Solving Lecture Notes
Programming For Problem Solving Lecture Notes
 
Presentation1 (1).pptx
Presentation1 (1).pptxPresentation1 (1).pptx
Presentation1 (1).pptx
 
Meetup 29042015
Meetup 29042015Meetup 29042015
Meetup 29042015
 

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 

Kürzlich hochgeladen (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

Lecture03

  • 1. Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard Department of Modern Languages and Literatures Western University
  • 2. Lecture 3 Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard * Contents: 1. Why this lecture? 2. Discussion 3. Chapter 3 4. Assignment 5. Bibliography 2
  • 3. Why this lecture? Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard * This lecture... · trains the problem solving skill by means of algorithm formalization · prepares the ground to write real programs 3
  • 4. Last assignment discussion Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard * Time to... · consolidate ideas and concepts dealt in the readings · discuss issues arised in the specific solutions to the projects 4
  • 5. Chapter 3 Fundamentals of Programming 1. Designing algorithms 2. Elements of a program Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard5
  • 6. Chapter 3 1 Designing algorithms 1.1 The programming process 1.2 What is an algorithm? Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard6
  • 7. Chapter 3 2 Elements of a program 2.1 What is a program? 2.2 Components of a program 2.3 Types of errors Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard7
  • 8. Designing algorithms Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard8
  • 9. The programming process * Programming cycle: 1. Define the problem 2. Plan the solution 3. Code the program 4. Test the program 5. Document the process Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard9
  • 10. The programming process * Define the problem · Identify the input data (what we have) · Determine the output information (what we want to obtain) Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard10
  • 11. The programming process * Plan the solution · Design an algorithm + by drawing a flow diagram + by writing pseudocode Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard11
  • 12. The programming process * Code the program · Translate the algorithm into a programming language Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard12
  • 13. The programming process * Test the program · Verify if for certain input, the program produces the correct output · Find and fix errors (debugging): + syntax + runtime + semantic Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard13
  • 14. The programming process * Document the process · Describe the problem and the solution · Include pseudocode or flow diagrams · Report testing results · Comment the code Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard14
  • 15. References Glassborow, Francis. “Chapter 1: You Can Program.” You Can Do It!: A Beginner’s Introduction to Computer Programming. Chichester, West Sussex, England; Hoboken, NJ: John Wiley, 2004. Print. Mohd Harris. “PROG0101 - Fundamentals of Programming.” N. p., n.d. Web. 17 Jan. 2014. Perry, Greg M. “Chapter 2: Anatomy of a Program.” Absolute Beginner’s Guide to Programming. Indianapolis, Ind.: Que Pub., 2003. Print. Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard15
  • 16. What is an algorithm? * Definitions · A detailed plan to solve a problem · A step-by-step set of instructions for solving a problem · A finite process that if followed will solve a problem Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard16
  • 17. What is an algorithm? * Characterized by 5 properties: 1. Input: initial data 2. Output: final result Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard17
  • 18. What is an algorithm? * Characterized by 5 properties: 3. Finiteness: has to terminate in a finite number of steps 4. Definiteness: each step has to be unambiguously specified 5. Effectiveness: each step should be doable in a finite time by a human Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard18
  • 19. What is an algorithm? * Exercise 1 · A recipe is an algorithm that solve the next problem: how to prepare a meal · Search for the recipe of Green Tea Berry Delight (http://allrecipes.com/Recipe/Green-Tea-Berry-Delight/Detail.aspx) Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard19
  • 20. What is an algorithm? * Exercise 1 · Identify: input, output and steps · Answer the following questions: + Is the recipe finite? + Is each step definite? + Is each step effective? Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard20
  • 21. What is an algorithm? * Exercise 1 (solution) · Recipe: Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard21
  • 22. What is an algorithm? Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard22
  • 23. What is an algorithm? * Exercise 1 (solution) · Is the recipe finite? Yes, it is done in 5 minutes · Is each step definite? Yes, they are not ambiguous · Is each step effective? Yes, in fact they are thought to be done by a human Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard23
  • 24. What is an algorithm? * Exercise 2 · Design an algorithm to divide two numbers by using only additions and substractions Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard24
  • 25. What is an algorithm? * Exercise 2 (solution) · Solve the specific case: divide 7 by 3 Hint: how many times is 3 contained in 7? · Solve the general case: divide A by B Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard25
  • 26. What is an algorithm? * Exercise 2 (solution) · How many times is 3 contained in 7? Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard26
  • 27. What is an algorithm? * Exercise 2 (solution) · Count the number of sustractions Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard27
  • 28. What is an algorithm? * Exercise 2 (solution) Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard28
  • 29. What is an algorithm? * Exercise 2 (solution) Is the algorithm correct? Trace for 7/3 Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard29 Step 0   A is 7, B is 3, C is 0 Step 1   Is 7 >= 3? Yes     A is now 7 ­ 3 = 4     C is now 0 + 1 = 1 Step 2   Is 4 >= 3? Yes     A is now 4 ­ 3 = 1     C is now 1 + 1 = 2 Step 3   Is 1 >= 3? No Step 4   Output C, that is 2
  • 30. References Cormen, Thomas H. “Chapter 1: The Role of Algorithms in Computing.” Introduction to Algorithms. Cambridge, Masachusetts; London: The MIT Press, 2009. Print. De la Rosa, Javier. “Computer Tools for Linguists.” Yutzu. N. p., n.d. Web. 16 Sept. 2013. Knuth, Donald E. “Chapter 1: Basic Concepts.” The Art of Computer Programming. Volume 1: Fundamental Algorithms. Vol. 1. Reading, Mass.: Addison-Wesley, 1997. Print. Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard30
  • 31. Elements of a program Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard31
  • 32. What is a program? * Definition “A program is an implementation of an algorithm in a program language.” (The concrete written program is called source code or just code) Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard32
  • 33. What is a program? * Algorithm vs program · Algorithm: + Abstract + Represented by a flow diagram, pseudocode... + For human understanding Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard33
  • 34. What is a program? * Algorithm vs program · Program: + Concrete + Represented by a program language + For computer processing Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard34
  • 35. Components of a program * The content and structure of a program depend on the programming language * Every programming language is formed by a set of symbols * The combination of these symbols defines the programs Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard35
  • 36. Components of a program * Programming languages are defined by: · Morphology · Syntax · Semantics Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard36
  • 37. Components of a program * Morphology · Symbols: numbers, letters and special characters · Symbols are combined to form tokens: the basic elements of a language Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard37
  • 38. Components of a program * Morphology · Vocabulary: a set of keywords (special tokens) with specific funcionality · Examples in Python: def, elif, except, print Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard38
  • 39. Components of a program * Syntax · Grammar rules to write a program + Tokens - How the symbols are combined - Examples in Python: correct: 3, counter, def incorrect: $+1, (&variable Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard39
  • 40. Components of a program * Syntax · Grammar rules to write a program + Structure - Way that tokens are arranged - Expressions, blocks... - Examples in Python correct: a += 1 incorrect: a $= 1 Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard40
  • 41. Components of a program * Semantics · Meaning of the program · Examples: how to interpret the order of the operators + Operator precedence x - 2 * 3 ≡ x - (2 * 3) + Operator associativity x - 2 + 3 ≡ (x - 2) + 3 Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard41
  • 42. Components of a program * A program is a set of instructions * An instruction is an statement * A statement is an executable unit of code formed by expressions * An expression is a combination of tokens * A token is a sequence of symbols Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard42
  • 43. Components of a program * Exercise 3 Given the next code... Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard43 fruit = 'banana' counter = 0 index = 0 while index < len(fruit):     char = fruit[index]     if char == 'a':         counter += 1     index += 1 print counter
  • 44. Components of a program * Exercise 3 ... identify: · Symbols, tokens and keywords · Some grammar rules · Its semantics Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard44
  • 45. Components of a program * Exercise 3 (solution) · symbols: letters, numbers, ', <, (, ), :, =, [, ], and + · tokens: fruit, =, 'banana', counter, 0, index, while, <, len(fruit), :, char, fruit[index], if, ==, 'a', +=, 1, print · keywords: while, len, if, print Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard45
  • 46. Components of a program * Exercise 3 (solution) · grammar rules: quotations for strings '', colon after testings :, indentention for blocks, closing parenthesis after opening parenthesis (), closing bracket after opening bracket [] · semantics: counts and print on screen number of a's in the word “banana” Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard46
  • 47. References De la Rosa, Javier. “Computer Tools for Linguists.” Yutzu. N. p., n.d. Web. 16 Sept. 2013. The Little Introduction To Programming. N. p. Web. Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard47
  • 48. Types of errors * Syntax error The code of the program breaks the syntax rules of the programming language * Logic error The code is syntactically correct but results in illegal operations in execution * Semantic error The program does not behave as expected Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard48
  • 49. Types of errors * Examples in Python · Syntax error a + 1 = b Assignment malformed · Logic error a = 4 b = 0 c = a / b Division by 0 Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard49 my_list = [1, 2, 3, 4] element = my_list[7] Access to a non existing object
  • 50. Types of errors * Examples in Python · Semantic error It does not print the number of a's Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard50 fruit = 'banana' counter = 0 index = 0 while index < len(fruit):     char = fruit[index]     if char == 'a':         counter += 1     index += 1 print fruit
  • 51. References Severance, Dr Charles R. “Chapter 1: Why Should You Learn to Write Programs?” Python for Informatics: Exploring Information. 1 edition. CreateSpace Independent Publishing Platform, 2013. Print. Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard51
  • 52. Assignment * Assignment 3: Playing with algorithms · Readings + The Role of Algorithms in Computing (Introduction to Algorithms) + Strings (Python for Informatics) Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard52
  • 53. Assignment * Assignment 3: Playing with algorithms · Project + Write an algorithm in Python that cleans a text of punctuations marks Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard53 O Romeo Romeo wherefore  art thou Romeo Deny thy  father and refuse thy  name Or if thou wilt not  be but sworn my love And  I'll no longer be a  Capulet O Romeo, Romeo! wherefore  art thou Romeo? Deny thy  father and refuse thy  name; Or, if thou wilt  not, be but sworn my  love, And I'll no longer  be a Capulet. »
  • 54. References Cormen, Thomas H. “Chapter 1: The Role of Algorithms in Computing.” Introduction to Algorithms. Cambridge, Masachusetts; London: The MIT Press, 2009. Print. Severance, Dr Charles R. “Chapter 6: Strings” Python for Informatics: Exploring Information. 1 edition. CreateSpace Independent Publishing Platform, 2013. Print. Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard54
  • 55. Bibliography Cormen, Thomas H. Introduction to Algorithms. Cambridge, Masachusetts; London: The MIT Press, 2009. Print. De la Rosa, Javier. “Computer Tools for Linguists.” Yutzu. N. p., n.d. Web. 16 Sept. 2013. Glassborow, Francis. You Can Do It!: A Beginner’s Introduction to Computer Programming. Chichester, West Sussex, England; Hoboken, NJ: John Wiley, 2004. Print. Knuth, Donald E. The Art of Computer Programming. Volume 1: Fundamental Algorithms. Vol. 1. Reading, Mass.: Addison-Wesley, 1997. Print. Mohd Harris. “PROG0101 - Fundamentals of Programming.” N. p., n.d. Web. 17 Jan. 2014. Perry, Greg M. Absolute Beginner’s Guide to Programming. Indianapolis, Ind.: Que Pub., 2003. Print. Severance, Dr Charles R. Python for Informatics: Exploring Information. 1 edition. CreateSpace Independent Publishing Platform, 2013. Print. The Little Introduction To Programming. N. p. Print. Knowledge Representation in Digital Humanities Antonio Jiménez Mavillard55