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 (16) [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