aboutsummaryrefslogtreecommitdiff
path: root/README.org
diff options
context:
space:
mode:
Diffstat (limited to 'README.org')
-rw-r--r--README.org134
1 files changed, 134 insertions, 0 deletions
diff --git a/README.org b/README.org
new file mode 100644
index 0000000..d99ae1e
--- /dev/null
+++ b/README.org
@@ -0,0 +1,134 @@
1#+title: Context-free grammar for a subset of a natural language
2#+subtitle: Slovak language -- future tense
3#+date: 2025H1
4
5* Task
6:PROPERTIES:
7:CUSTOM_ID: task
8:END:
9Construct a context‑free grammar for a subset of natural language
10sentences, defined by a certain time. Based on the created grammar,
11implement the generation of random sentences belonging to the grammar
12and an algorithm for recognizing entered sentences.
13
14* Problem statement
15:PROPERTIES:
16:CUSTOM_ID: problem-statement
17:END:
18The future tense in the Slovak language is called /budúci čas/ or
19/futúrum/. The word order in the Slovak language is more or less free;
20changing it does not alter the meaning of the sentence, but changing
21the word order can be used to emphasize certain words. The usual word
22order is: subject + predicate + other members of the sentence + final
23punctuation mark (end mark).
24
25In the Slovak language, it is possible to build complex sentences (or
26compound sentences) --- these are sentences consisting of several
27simple sentences and expressing one complete thought. They can be
28both simple and complex.:
29- A simple complex sentence:
30- Contains two predicative units (two grammatical bases).
31 - Example: Jano sadol do auta a odišiel.
32 - Translation: Jano got into the car and drove away.
33- Compound complex sentence:
34 - Contains more than two predicative units (three or more
35 grammatical bases).
36 - Example: Mama vedela, že príde, lebo mu verila.
37 - Translation: Mom knew that he would come because she believed in him.
38
39There are many different types of compound sentences, but they always
40use conjunctions or connective expressions to join the parts of the
41sentence.
42
43To examine the applicability of context-free grammars in working with
44morphologically correct sentences, we will implement the agreement of
45person and number between the subject and the verb of the sentence
46fragment.
47
48To display the result of the syntax analyzer’s operation, we'll
49automatically generate a parse tree.
50
51* Documentation
52:PROPERTIES:
53:CUSTOM_ID: documentation
54:END:
55The exported report can be found at [[https://git.michalec.dev/files/uni/term-06/math-logic/lab-03/report.pdf][this link]].
56
57* Showcase
58:PROPERTIES:
59:CUSTOM_ID: showcase
60:END:
61I wrote a custom BNF parser for this, [[https://git.michalec.dev/uni/term-06/math-logic/lab-03/tree/src/slovak-sentence.bnf][here]] is an example of what it
62can parse.
63
64Listing [[generated]] shows the generated sentences. You can see that
65they consist of a different number of fragments, have different
66endings, and in some fragments the subject is omitted.
67
68#+name: generated
69#+caption: Generated sentences
70#+begin_src text
71Ty preľúbiš Kraskov, ona bude vedieť počítači, podliečíte dážď, cibuľa vyhľadá kuratá, ale oni ovaria morami, ty očítaš knihe, ono bude vedieť umenieie.
72Ja načítam Kraskovi, ty budeš mať ruka, keď budeš vedieť stretnutia, ty prelietaš huslu, ale ono bude vedieť princeznej, keď vy učítate mláďatá, ale ty budeš plávať bruchom?
73My budeme rozumieť dlaňe, bude robiť oleja.
74Púšť bude páliť chlápät, keď ono podrozumie úskalia, keď my budeme mať orchideu, vy budete maľovať lístím, ale oni budú vedieť chlápäťu, keď ukupuje vysvedčeniach, ja utelefonujem pozadím.
75Ty budeš telefonovať Nikaragua, keď ono bude vedieť Kraskovi, my budeme rozumieť noci, ale budem maľovať dážďmi?
76Vy zaľúbite stromoch, budeš páliť bratoch...
77Ty budeš tancovať uja.
78Ty ukúpiš huslovi, lístia budú fotografovať Kraskovi, vy opálite umenieia, polia budú učiť mláďa, keď obľúbim knihe, keď my budeme tancovať chvíľe, vy privaríte trolejbusy, ony budú liečiť kosťou, vy budete liečiť vodopádi, bude učiť chvíľou!
79Vy budete kupovať pieseňi, ale dážďe budú prerábovať nástupištia, my budeme robiť huslom?
80Budú robiť rodiny, keď ja pohľadám bratoch.
81Budem umývať sluhami, keď ty obliečíš kráľovnej.
82My vypracujeme reportáž, keď ony budú ľúbiť úskaliam, vy budete rozumieť šľachtičnej, zarobia auto?
83Nástupište opozná brata, keď ja ukúpim dlaňi, ale ja budem ľúbiť vodopád, ona prevedie kuliami, ona preliečí pážaťa...
84Vody obhľadajú kôša, ale vy budete rozumieť zmesiach, ale vyčítam báseňiach, vy budete rozumieť košeľíc...
85Vy obrozumiete huslov...
86My oučíme stromi, keď obtancuje pecou, ty budeš liečiť hrdinovi?
87Ty budeš mailovať stredám?
88#+end_src
89
90In listing [[no-match-first]], an example is provided that does not comply
91with the grammar rules because the sentence starts with a lowercase
92letter instead of a capital one.
93
94#+name: no-match-first
95#+caption: A sentence that does not follow the rules of grammar -- does not start with a capital letter
96#+begin_src text
97Enter string to parse: my oučíme stromi, keď obtancuje pecou, ty budeš liečiť hrdinovi?
98didn't match!
99#+end_src
100
101Lisiting [[no-match-number]] shows an example that does not conform to the
102grammar due to a mismatch in number between the subject and the verb.
103/"My oučím"/ can be matched in number in the following ways: /"My
104oučíme"/, /"Ja oučím"/.
105
106#+name: no-match-number
107#+caption: A sentence that does not conform to grammar -- an inconsistent number.
108#+begin_src text
109Enter string to parse: My oučím stromi, keď obtancuje pecou, ty budeš liečiť hrdinovi?
110didn't match!
111#+end_src
112
113Listing [[match]] shows an example of a sentence that complies with the
114grammar. And figure [[tree]] presents the automatically generated parse tree
115for it.
116
117#+name: match
118#+caption: A sentence that complies with the grammar
119#+begin_src text
120Enter string to parse: My oučíme stromi, keď obtancuje pecou, ty budeš liečiť hrdinovi?
121matched
122./tmp/tree.dot:1:0: info: generated parsing tree
123#+end_src
124
125#+name: tree
126#+caption: Parsing tree of the complient sentence
127#+attr_html: :width 100%
128[[https://git.michalec.dev/files/uni/term-06/math-logic/lab-03/tree.png][https://git.michalec.dev/files/uni/term-06/math-logic/lab-03/tree.png]]
129
130* Unlicense
131:PROPERTIES:
132:CUSTOM_ID: unlicense
133:END:
134#+include: UNLICENSE verse