6 WetPancake Project Breakdown
Craig Oates edited this page 4 years ago

This section focuses on the source code within WetPancake. It is the main project within the solution/repository.

wetpancake selected

Project Breakdown

Within the project, you will see eleven files and one folder. Before we look in "TextFiles" (I.E. the folder), I will focus on the files outside of it.

Of the eleven files, you will see three files which are standard files found in F# projects. They are "WetPancake.fsproj", "packages.config", and "AssemblyInfo.fs". Because of the regularity of these files, I will refrain from going into detail about them.

Amongst the remaining eight files, I will leave "Script.fsx" until the end. This is because it is not part of the main set of files but it does contain code specific to this project. Having said that, if you are familiar with .fsx files and F# Interactive (FSI), feel free to jump right into it.

wetpancake file structure Instead of running through every line of code in the project, I will provide a summary of what each file aims to do. That way, you should find how the pieces fit together in a more intuitive way. That's the plan at least.

ProductServices.fs (public)

  • Name-space: WetPancake
  • module: Pancake

This is the public facing part of the library -- the A.P.I. if you will. When people add WetPancake (W.P.) to their project, they will call the functions in this file. The function called in this file will then call the private/internal functions within the rest of the library.

DataAccess.fs (internal)

  • Name-space: N/A
  • Module: DataAccess

The functions in this file deals with file access. The most notable type is the built-in sample files. These samples consist of plain-text (.txt) files and live in the "TextFiles" folder. DataAccess.fs, also, provides functions for selecting one of the sample files at random.

DataCleaning.fs (internal)

  • Name-space: N/A
  • Module: DataCleaning`

This file provides functions which "cleans" the (plain) text of a file when loaded in memory. The functions available include trimming/splitting text and replacing/removing characters.

DataProcessing.fs (internal)

  • Name-space: N/A
  • Module: DataProcessing

This file is the work-horse of the library. It is the one which does all the work but the "higher-ups" above take all the credit. I sure you can relate...

The main purpose of this file is to process the data after it has entered the system, usually plain-text. Alongside that, it deals with things like checking file paths and gibberish-levels.

Before any data (I.E. plain-text) reaches the functions in this file, I will have already ran it through "DataCleaning.fs" and its appropriate functions.

DataServices.fs (internal)

  • Name-space: N/A
  • Module: DataServices

If you have not read any of the project's source code, I recommend you do for this file. The reason why is because it has a large amount so far of comments in it. The comments are not XML-comments so you will have no intellisense to fallback on.

I tend to look at this file like it is a head of department. "ProductServices.fs" delegates its big tasks to this file which, inturn, breaks it down even further. In this instance, "DataServices.fs" is overseeing the creation of the the final result (I.E. the Markov text). This is because it is a task it received from "ProductServices.fs".

DataStructuring.fs (internal)

  • Name-space: N/A
  • Module: DataStructuring

When you load a .txt file, DataStructuring.fs cleans and processes it. This is in preparation for its transformation.

The code in this file constructs the map which other parts of the system uses to generate the final text. I will not go into detail about how it does it here. Instead, I will provide links to other pages in this wiki. This will explain how a Markov Chain works and how it relates to the creation of a map. The links are as follows:

SystemServices.fs (internal)

  • Name-space: N/A
  • Module: SystemServices

This is a small file but far reaching. The functions in here are accessible to any file within the project. It is a glorified "helper class". With that said, the module residing in this file is an internal one. So, it is important to remember, developers will not have access to anything in here when they use W.P. as a NuGet package.

TextFiles folder

The main purpose of this folder is to store the sample/template .txt files. This allows W.P. to generate text without the user of W.P. needing to supply a .txt file.

As an aside, when a developer adds W.P. to their project, "TextFiles" is also added. If the developer wants to, he/she is free to add their sample (.txt) files to "TextFiles". Because of this, I recommend keeping this folder clean and focused -- no storing of none .txt files.

There is nothing special about these files. They are files I had lying around on my computer.

To get the best results, I recommend you stick to a set of guidelines when creating your own .txt files. You can find them at the following link:

Script.fsx

This script file was/is my initial testing area. If you work your way through it, you will see how individual pieces work in isolation and together.

I have broke the file down into the sections which mimics the file structure/general flow of the project. There are comments within the file to help highlight where each section stop/starts. I have, also, written comments to help explain the more complicated bits of code. All I can say at this point is build the project and run "Script.fsx" through F# Interactive (FSI). If you are unsure what FSI is or how to use it, please use the following links:

If you are unsure what the bindings refer to (at the top of the file), they are paths to the sample/template files in "TextFiles". For more information on the files in "TextFiles", please use the following link: