comp-think / 2018-2019

The GitHub repository containing all the material related to the Computational Thinking and Programming course of the Digital Humanities and Digital Knowledge degree at the University of Bologna (a.a. 2018/2019).
Other
30 stars 8 forks source link

Lecture "Introduction to Computational Thinking", exercise 1 #1

Open essepuntato opened 5 years ago

essepuntato commented 5 years ago

What are all the possible sentences that can be produced by using the regular grammar introduced in Section "Historic hero: Noam Chomsky"?

MattiaSpadoni commented 5 years ago

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")

ilsamoano commented 5 years ago

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'))

VittoriaMoccia commented 5 years ago

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")

delfimpandiani commented 5 years ago

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"))

tceron commented 5 years ago

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")

friendlynihilist commented 5 years ago

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.

Ioanna96 commented 5 years ago

<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> )

lisasiurina commented 5 years ago

 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”)

mchiaraf commented 5 years ago

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:

  1. I run - <pronoun> ::= "I" and <verb> ::= "run"
  2. I walk - <pronoun> ::= "I" and <verb> ::= "walk"
  3. we run - <pronoun> ::= "we" and <verb> ::= "run"
  4. we walk - <pronoun> ::= "we" and <verb> ::= "walk"
SeverinJB commented 5 years ago

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.

  1. I write
  2. I read
  3. You write
  4. You read
essepuntato commented 5 years ago

@MattiaSpadoni and @ilsamoano and @lisasiurina

<sentence> ::= "I" <sentence> ::= "you"

There is something strange here... maybe you wanted to refer to <pronoun> instead of <sentence>?