Browse Source

Added checks for start and end words.

master
Craig Oates 6 years ago
parent
commit
652e6627a9
  1. 13
      WetPancake/MapProcessing.fs
  2. 8
      WetPancake/Script.fsx
  3. 6
      WetPancake/Textprocessing.fs
  4. 2
      WetPancake/WetPancake.fs
  5. 2
      WetPancakeCLI/ConsoleCommands.cs

13
WetPancake/MapProcessing.fs

@ -1,12 +1 @@
module internal MapProcessing
// You are up to here craig
// starting to build a markov map using the functions in text and file procssing...
(*
Notes for possible way forward
let random = defaultArg random (Random().Next)
let isStartOfSentence = defaultArg isStartOfSentence (Regex(@"^[A-Z]").IsMatch)
let isEndOfSentence = defaultArg isEndOfSentence (Regex(@"\.").IsMatch)
let startWords, otherWords = map |> Map.partition (fun k _ -> isStartOfSentence k)
*)
module internal MapProcessing

8
WetPancake/Script.fsx

@ -1,8 +1,8 @@
// Learn more about F# at http://fsharp.org
// See the 'F# Tutorial' project for more help.
#load "Library1.fs"
open WetPancake
// Define your library scripting code here
#load "TextProcessing.fs"
open TextProcessing
IsStartOfSentence "bob"
IsEndOfSentence "bill."

6
WetPancake/Textprocessing.fs

@ -3,8 +3,14 @@
open System.Text.RegularExpressions
open System
let PickRandomNumber max = Random().Next(0, max);
let SplitIntoWords text = Regex.Split(text, @"\@s+")
let IsStartOfSentence word = Regex(@"^[A-Z]").IsMatch(word)
let IsEndOfSentence word = Regex(@"\.").IsMatch(word)
let JoinWords words = String.concat " " words
let GetWordPairs pairSize = SplitIntoWords >> Seq.windowed pairSize

2
WetPancake/WetPancake.fs

@ -1,6 +1,6 @@
namespace WetPancake
module PancakeWetter =
module Pancake =
open CoOrdinator

2
WetPancakeCLI/ConsoleCommands.cs

@ -32,7 +32,7 @@ namespace WetPancakeCLI
[Usage("> GenerateRandomText")]
public static string GenerateRandomText(int sentences)
{
var result = PancakeWetter.RequestRandomText;
var result = Pancake.RequestRandomText;
return "Not implemented yet.";
}

Loading…
Cancel
Save