From 9275d5e720b81ffe34b63f632d4c28a79190b3cd Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Fri, 4 Jun 2021 13:27:26 +0800 Subject: [PATCH] (Morphodict) Replace space/- in identifiers with _ --- src/morphodict/MkMorphodict.hs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/morphodict/MkMorphodict.hs b/src/morphodict/MkMorphodict.hs index 4af9f33d..f1255d73 100644 --- a/src/morphodict/MkMorphodict.hs +++ b/src/morphodict/MkMorphodict.hs @@ -163,14 +163,18 @@ mkMorphoDict env = _ | length (nub (map tail fls)) == length fls -> shrinkMore (map tail fls) _ -> fls - -mkFun = showCId . mkCId . concat . intersperse "_" +-- >>> mkFun ["hello", "world", "hello friends", "hello-all"] +-- "hello_world_hello_friends_hello_all" +mkFun :: [String] -> String -- if word contains space or hyphen, replace with underscore +mkFun = showCId . mkCId . concat . intersperse "_" . concatMap (words . removeHyphen) + where + removeHyphen [] = [] + removeHyphen ['-'] = ['-'] -- If hyphen is the last character, it's usually meaningful, leave it + removeHyphen ('-':cs) = ' ' : removeHyphen cs + removeHyphen (c:cs) = c : removeHyphen cs quote s = "\"" ++ s ++ "\"" - - - {- ---- let us ignore this findCompounds :: [RuleData] -> [RuleData] findCompounds = getCompounds . sortOn cat_orthrevforms