Comments (11)
regular grammar
<sentence> ::= "I"
<sentence> ::= "you"
<verb> ::= "write"
<verb> ::= "read"
Possible sentences:
I write (terminal "I"+ non terminal <verb> in this case "write")
I read (terminal "I"+ non terminal <verb> in this case "read")
you write (terminal "You"+ non terminal <verb> in this case "write")
you read (terminal "you"+ non terminal <verb> in this case "read")
from 2018-2019.
Regular grammar possible generic sentence:
<non terminal>
::= "terminal"
<non terminal>
::= "terminal" <non terminal>
i.e.
<sentence>
::= "I"
<sentence>
::= "you"
<verb>
::= "write"
<verb>
::= "read"
possible example sentences
I write ("terminal" = "I" and <non terminal>
= <verb>
('write'))
I read ("terminal" = "I" and <non terminal>
= <verb>
('read'))
you write ("terminal" = "you" and <non terminal>
= <verb>
('write'))
you read ("terminal" = "you" and <non terminal>
= <verb>
('read'))
from 2018-2019.
From regular grammar with production rules:
<sentence>
::= "I" <verb>
<sentence>
::= "you" <verb>
<verb>
::= "write"
<verb>
::= "read"
Possible sentences:
I write ( <terminal>
= "I"; <non-terminal>=<verb>("write"))
I read( <terminal>
= "I"; <non-terminal>=<verb>("read"))
you write ( <terminal>
= "you"; <non-terminal>=<verb>("write"))
you read ( <terminal>
= "you"; <non-terminal>=<verb>("read"))
from 2018-2019.
Regular grammar rules can be summarized in:
<non-terminal>
::= "terminal"
<non-terminal>
::= "terminal"
For example, in order to create a sentence, this could be the combination:
<sentence>
::= "I" <verb>
<verb>
::= "eat"
<verb>
::= "sleep"
Possible combinations:
I eat (composed by the terminal "I" and the <non-terminal>
/<verb>
"eat")
I sleep (composed by the terminal "I" and the <non-terminal>
/<verb>
"sleep")
from 2018-2019.
Forms of production:
<non terminal>
::= "terminal"
<non terminal>
::= "terminal" <non terminal>
For instance:
<sentence>
::= "He" <verb>
<sentence>
::= "She" <verb>
<verb>
::= "runs"
<verb>
::= "works"
Possible combinations:
He runs ("terminal" = "He" and = <verb>
"runs")
He works ("terminal" = "He" and = <verb>
"works")
She runs ("terminal" = "She" and = <verb>
"runs")
She works ("terminal" = "She" and = <verb>
"works")
from 2018-2019.
Form of production rules for regular grammar:
<non-terminal>
::="terminal" and <non-terminal>
::="terminal" <non-terminal>
<sentence>
::="I" <verb>
<sentence>
::="We" <verb>
<verb>
::="cry"
<verb>
::="die"
I cry ("terminal" = I and <verb>
, specifically <verb>
= cry)
I die ("terminal" = I and <verb>
, specifically <verb>
= die)
We cry ("terminal" = We and <verb>
, specifically <verb>
= cry)
We die ("terminal" = We and <verb>
, specifically <verb>
= die)
That allows me to create all the two-word sentences having as a terminal either the first person singular or the first person plural pronoun accompanied by either the (non-terminal part) <verb>
"cry" or the <verb>
"die", for a total of four combinations.
from 2018-2019.
<sentence>::
= "I" <verb>
<sentence>::
= "They" <verb>
<verb>::
= "walk"
<verb>::
="fly"
I walk (terminal: "I", terminal: "walk", non-terminal: <verb>
)
I fly (terminal: "I", terminal: "fly", non-terminal: <verb>
)
They walk (terminal:"They", terminal: "walk", non-terminal: <verb>
)
They fly (terminal:"they", terminal:"fly", non-terminal: <verb>
)
from 2018-2019.
Possible sentences that can be produced by using the regular grammar:
<non terminal> ::= "terminal"
<non terminal> ::= "terminal"
Examples:
<sentence> ::= “I”
<sentence> ::= “You”
<verb> ::= “write”
<verb> ::= “read”
Possible example sentences:
I write ("terminal" = "I" and = “write”) I read ("terminal" = "I" and = “read”) You write ("terminal" = “You" and = “write”) You read ("terminal" = “You" and = “read”)
from 2018-2019.
Form of production rules of regular grammars:
non-terminal ::= "terminal"
and <non-terminal> ::= "terminal" <non-terminal>
.
i.e.
<sentence> ::= "I" <verb>
<sentence> ::= "we" <verb>
<verb> ::= "run"
<verb> ::= "walk"
Considering these non-terminal elements we can produce four possible sentences:
- I run -
<pronoun> ::= "I"
and<verb> ::= "run"
- I walk -
<pronoun> ::= "I"
and<verb> ::= "walk"
- we run -
<pronoun> ::= "we"
and<verb> ::= "run"
- we walk -
<pronoun> ::= "we"
and<verb> ::= "walk"
from 2018-2019.
A sentence can either contain "I" plus a verb or "You" plus a verb. There are two defined verbs: "write" and "read". Hence, four constellations are possible.
- I write
- I read
- You write
- You read
from 2018-2019.
@MattiaSpadoni and @ilsamoano and @lisasiurina
<sentence>
::= "I"
<sentence>
::= "you"
There is something strange here... maybe you wanted to refer to <pronoun>
instead of <sentence>
?
from 2018-2019.
Related Issues (20)
- Lecture "Brute-force algorithms", exercise 3 HOT 13
- Lecture "Brute-force algorithms", exercise 4 HOT 16
- Lecture "Brute-force algorithms", exercise 5 HOT 12
- Lecture "Organising information: unordered structures", exercise 1 HOT 21
- Lecture "Organising information: unordered structures", exercise 2 HOT 19
- Lecture "Organising information: unordered structures", exercise 3 HOT 17
- Lecture "Recursion", exercise 1 HOT 18
- Lecture "Recursion", exercise 2 HOT 20
- Lecture "Divide and conquer algorithm", exercise 1 HOT 12
- Lecture "Divide and conquer algorithm", exercise 2 HOT 5
- Lecture "Dynamic programming algorithms", exercise 1 HOT 15
- Lecture "Dynamic programming algorithms", exercise 2 HOT 8
- Lecture "Organising information: trees", exercise 1 HOT 4
- Lecture "Organising information: trees", exercise 2 HOT 4
- Lecture "Organising information: graphs", exercise 1 HOT 14
- Lecture "Organising information: graphs", exercise 2 HOT 12
- Christmas present game + bonus Python exercise
- Lecture "Backtracking algorithms", exercise 1 HOT 3
- Lecture "Greedy algorithms", exercise 1 HOT 2
- Question about an exercise from last year
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 2018-2019.