From cbfb9d5e7d76616b5490083a9f4071fd977c2ec0 Mon Sep 17 00:00:00 2001 From: aarne Date: Wed, 2 Jan 2008 16:54:22 +0000 Subject: experiment with Finnish morphology --- examples/uusisuomi/MyDiff.hs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 examples/uusisuomi/MyDiff.hs (limited to 'examples/uusisuomi/MyDiff.hs') diff --git a/examples/uusisuomi/MyDiff.hs b/examples/uusisuomi/MyDiff.hs new file mode 100644 index 000000000..f695978aa --- /dev/null +++ b/examples/uusisuomi/MyDiff.hs @@ -0,0 +1,25 @@ +module Main where + +import System + +-- compare lines word-by-word, returning difference pairs with their positions + +main = do + x:y:_ <- getArgs + old <- readFile x >>= return . lines + new <- readFile y >>= return . lines + mapM_ comp (zip old new) + +comp (ws1,ws2) = do + let diffs = [form ++ ":" ++ w1 ++ "-" ++ w2 | + (form,(w1,w2)) <- zip forms (zip (words ws1) (words ws2)), diff w2 w1] + putStr $ unwords diffs + if null diffs then return () else putStrLn "" + +forms = map show [1..] + +diff w ws = notElem w (chop ws) where + chop cs = case span (/='/') cs of + ([],_) -> [] + (w1,ww) -> w1:chop (drop 1 ww) + -- cgit v1.2.3