Monads in Haskell
Table of Contents
1. Task
Implement two syntax analyzers that solve the following tasks:
- 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.
- Read lines containing values and binary operations from a text
file (
- Develop a text parser and text continuation generator. Tasks:
- 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.
- Split the text into sentences using the following rules: words
consist only of letters; sentences consist of words and
separated by characters:
- 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).
- 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.
- 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.
- Read the text from the file, the name of which is entered by the
user, and perform its syntactic analysis:
Use works of art as texts for building models: Ilfa and Petrov
2. Documentation
The exported report can be found at this link.
3. Unlicense
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to https://unlicense.org/
