The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

octavio08 (8) [Avatar] Offline
#1
Hi

I tried the code but it doesn't work (The value or constructor 'word' is not defined).

I added a parameter to the nested function (partialFuzzyMatch) and simplified the last line:

let fuzzyMatch (words:string list) =
let wordSet = new HashSet<string>(words)
let partialFuzzyMatch word =
query { for w in wordSet.AsParallel() do select (JaroWinkler.Match(w, word)) }
|> Seq.sortBy(fun x -> -x)
|> Seq.head

partialFuzzyMatch
Riccardo Terrell (31) [Avatar] Offline
#2
Correct, the word construct is not defined in the code sample.
There are few code typos that I am fixing that were introduce during the port to text for the book.
In the next MEAP, which is scheduled by the end of the month, the source code will be available to download. Thus, you will be able to open the solution and run the code


here the the source code fixed right now:

    let fuzzyMatch (words:string list) =
        let wordSet = new HashSet<string>(words)    
        let partialFuzzyMatch word =                
            query { for w in wordSet.AsParallel() do
                        select (JaroWinkler.getMatch w word) }
            |> Seq.sortBy(fun x -> -x.Distance)
            |> Seq.head

        fun word -> partialFuzzyMatch word          


In the book source code you will get all the function including `JaroWinkler.getMatch` one