mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
correct capitalization in unlexmixed; unlextext and unlexmixed now remove string literal quotes
This commit is contained in:
@@ -18,9 +18,9 @@ stringOp name = case name of
|
|||||||
"words" -> Just $ appLexer words
|
"words" -> Just $ appLexer words
|
||||||
"bind" -> Just $ appUnlexer bindTok
|
"bind" -> Just $ appUnlexer bindTok
|
||||||
"unchars" -> Just $ appUnlexer concat
|
"unchars" -> Just $ appUnlexer concat
|
||||||
"unlextext" -> Just $ appUnlexer unlexText
|
"unlextext" -> Just $ capitInit . appUnlexer (unlexText . unquote)
|
||||||
"unlexcode" -> Just $ appUnlexer unlexCode
|
"unlexcode" -> Just $ appUnlexer unlexCode
|
||||||
"unlexmixed" -> Just $ appUnlexer unlexMixed
|
"unlexmixed" -> Just $ capitInit . appUnlexer (unlexMixed . unquote)
|
||||||
"unwords" -> Just $ appUnlexer unwords
|
"unwords" -> Just $ appUnlexer unwords
|
||||||
"to_html" -> Just wrapHTML
|
"to_html" -> Just wrapHTML
|
||||||
"to_utf8" -> Just encodeUTF8
|
"to_utf8" -> Just encodeUTF8
|
||||||
@@ -93,17 +93,25 @@ bindTok ws = case ws of
|
|||||||
[] -> ""
|
[] -> ""
|
||||||
|
|
||||||
unlexText :: [String] -> String
|
unlexText :: [String] -> String
|
||||||
unlexText = cap . unlext where
|
unlexText = unlext where
|
||||||
unlext s = case s of
|
unlext s = case s of
|
||||||
w:[] -> w
|
w:[] -> w
|
||||||
w:[c]:[] | isPunct c -> w ++ [c]
|
w:[c]:[] | isPunct c -> w ++ [c]
|
||||||
w:[c]:cs | isMajorPunct c -> w ++ [c] ++ " " ++ cap (unlext cs)
|
w:[c]:cs | isMajorPunct c -> w ++ [c] ++ " " ++ capitInit (unlext cs)
|
||||||
w:[c]:cs | isMinorPunct c -> w ++ [c] ++ " " ++ unlext cs
|
w:[c]:cs | isMinorPunct c -> w ++ [c] ++ " " ++ unlext cs
|
||||||
w:ws -> w ++ " " ++ unlext ws
|
w:ws -> w ++ " " ++ unlext ws
|
||||||
_ -> []
|
_ -> []
|
||||||
cap s = case s of
|
|
||||||
c:cs -> toUpper c : cs
|
-- capitalize first letter
|
||||||
_ -> s
|
capitInit s = case s of
|
||||||
|
c:cs -> toUpper c : cs
|
||||||
|
_ -> s
|
||||||
|
|
||||||
|
-- unquote each string of form "foo"
|
||||||
|
unquote = map unq where
|
||||||
|
unq s = case s of
|
||||||
|
'"':cs@(_:_) | last cs == '"' -> init cs
|
||||||
|
_ -> s
|
||||||
|
|
||||||
unlexCode :: [String] -> String
|
unlexCode :: [String] -> String
|
||||||
unlexCode s = case s of
|
unlexCode s = case s of
|
||||||
|
|||||||
Reference in New Issue
Block a user