Haskell hunspell 绑定

Haskell binding for hunspell

是否有 Hunspell 拼写检查库的 Haskell 绑定?

如果没有,是否可以将要检查的单词发送到 Hunspell CLI 程序并检索结果?

这是对您第二个问题的回答:

If not, is it possible to send the words to check to the Hunspell CLI program and retrieve the results?

您可以使用 shelly 库调用 PATH 中的任何 cli 程序。 假设 foo 是您的程序,并且 param1param2param3 是所需的参数:foo param1 param2 param3 将是 OS shell.

中的调用

这是一个小 Haskell 示例:

{-# LANGUAGE OverloadedStrings #-}
import Shelly
import qualified Data.Text as T

main :: IO ()
main = shelly $ silently $ do
    out <- run "foo" ["param1", "param2", "param3"] 
    -- lns will containes a list of lines with the stdout output of foo
    let lns = T.lines out
    -- Here we print out the number of lines and the first 5 lines
    liftIO $ putStrLn $ show $ Prelude.length lns
    liftIO $ mapM_ (putStrLn .T.unpack) $ take 5 lns