Skip to content

Commit 9275d5e

Browse files
committed
(Morphodict) Replace space/- in identifiers with _
1 parent d2d841e commit 9275d5e

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/morphodict/MkMorphodict.hs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,18 @@ mkMorphoDict env =
163163
_ | length (nub (map tail fls)) == length fls -> shrinkMore (map tail fls)
164164
_ -> fls
165165

166-
167-
mkFun = showCId . mkCId . concat . intersperse "_"
166+
-- >>> mkFun ["hello", "world", "hello friends", "hello-all"]
167+
-- "hello_world_hello_friends_hello_all"
168+
mkFun :: [String] -> String -- if word contains space or hyphen, replace with underscore
169+
mkFun = showCId . mkCId . concat . intersperse "_" . concatMap (words . removeHyphen)
170+
where
171+
removeHyphen [] = []
172+
removeHyphen ['-'] = ['-'] -- If hyphen is the last character, it's usually meaningful, leave it
173+
removeHyphen ('-':cs) = ' ' : removeHyphen cs
174+
removeHyphen (c:cs) = c : removeHyphen cs
168175

169176
quote s = "\"" ++ s ++ "\""
170177

171-
172-
173-
174178
{- ---- let us ignore this
175179
findCompounds :: [RuleData] -> [RuleData]
176180
findCompounds = getCompounds . sortOn cat_orthrevforms

0 commit comments

Comments
 (0)