Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- neighbours :: PairsTally -> String -> WordTally
- neighbours [] _ = []
- neighbours [((string1, string2), n)] string
- | string == string1 = [(string, n)]
- | string == string2 = [(string, n)]
- | otherwise = []
- mostCommonNeighbour :: PairsTally -> String -> WordTally
- mostCommonNeighbour = mostCommonNeighbour1 . neighbours
- [("bear",2),("dog",1)]
- mostCommonNeighbour1 :: [(String, Int)] -> String -> MaybeString
- mostCommonNeighbour1 [] _ = "Nothing"
- mostCommonNeighbour1 (x:[]) word = fst x
- mostCommonNeighbour1 list@(x:xs) word = fst (fst (sortOn snd list))
- mostCommonNeighBour1 :: [(String, Int)] -> String -> (String, Int) -> Maybe String
- mostCommonNeighbour1 [] word _ = []
- mostCommonNeighbour1 _ "" _ = []
- mostCommonNeighbour1 (x:xs) word acc
- | word /= fst x && xs == [] = if snd acc == 0 then "Nothing" else fst acc
- | word /= fst x = mostCommonNeighbour1 xs
- | word == fst x = if snd x > snd acc then acc1 = x in mostCommonNeighbor xs word acc1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement