module GF.Text.Clitics (getClitics,getCliticsText) where
import Data.List
getClitics :: (String -> Bool) -> [String] -> String -> [[String]]
getClitics isLex rclitics = map (reverse . map reverse) . clits . reverse where
clits rword = ifLex rword [rclit:more |
rclit <- rclitics, stem <- splits rclit rword, more <- clits stem]
splits c = maybe [] return . stripPrefix c
ifLex w ws = if isLex (reverse w) then [w] : ws else ws
getCliticsText :: (String -> Bool) -> [String] -> [String] -> [String]
getCliticsText isLex rclitics =
map unwords . sequence . map (map render . getClitics isLex rclitics)
where
render = unwords . intersperse "&+"