#+title: Monads in Haskell #+date: 2024H2 * Task :PROPERTIES: :CUSTOM_ID: task :END: Implement two syntax analyzers that solve the following tasks: 1. Develop a parser for processing strings from a text file. It has to: - Read lines containing values and binary operations from a text file (=.txt=), the name of which is entered by the user. - Parse values represented by integers in decimal the number system. - Process binary operations: addition, subtraction, multiplication. division. - Calculate the result of an expression and display it on the screen. 2. Develop a text parser and text continuation generator. Tasks: 1. Read the text from the file, the name of which is entered by the user, and perform its syntactic analysis: - Split the text into sentences using the following rules: words consist only of letters; sentences consist of words and separated by characters: =.!?;:()=. - Remove all punctuation characters and numbers from the text. 2. Build an N-gram model: - Use bigrams and trigrams. - Create a dictionary where the keys are one word or a pair words, and values --- lists of all unique possible continuations. - Save the dictionary to a text file (=.txt=). 3. Implement user interaction: - When entering one or a couple of words, return a random string. a text of 2 to 15 words, based on the created dictionary. - If the entered word is not in the dictionary keys, display a message indicating this. 4. Organize a dialogue between two N‑gram models created based on two different texts: - The user specifies an initial word or a pair of words and the number of messages (the depth of the dialogue). - The answer of each model is based on the last word (or the penultimate one, if the latter is not in the dictionary) of the opponent's previous message. Use works of art as texts for building models: *Ilfa and Petrov* * Documentation :PROPERTIES: :CUSTOM_ID: documentation :END: The exported report can be found at [[https://git.michalec.dev/files/uni/term-05/func-prog/coursework/report.pdf][this link]]. * Unlicense :PROPERTIES: :CUSTOM_ID: unlicense :END: #+include: UNLICENSE verse