mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-24 03:52:50 -06:00
Unlexers: move capitalization of first word from GF.Text.Lexing to PGF.Lexing
The capitalization of the first word was done in GF.Text.Lexing.stringOp, but is now done in the functions unlexText and unlexMixed in PGF.Lexing. These functions are only used in stringOp and in PGFService (where the change is needed), so the subtle change in behaviour should not cause any bugs.
This commit is contained in:
@@ -16,9 +16,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 $ capitInit . appUnlexer (unlexText . unquote)
|
"unlextext" -> Just $ appUnlexer (unlexText . unquote)
|
||||||
"unlexcode" -> Just $ appUnlexer unlexCode
|
"unlexcode" -> Just $ appUnlexer unlexCode
|
||||||
"unlexmixed" -> Just $ capitInit . appUnlexer (unlexMixed . unquote)
|
"unlexmixed" -> Just $ appUnlexer (unlexMixed . unquote)
|
||||||
"unwords" -> Just $ appUnlexer unwords
|
"unwords" -> Just $ appUnlexer unwords
|
||||||
"to_html" -> Just wrapHTML
|
"to_html" -> Just wrapHTML
|
||||||
_ -> transliterate name
|
_ -> transliterate name
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ lexText' uncap1 = uncap . lext where
|
|||||||
_ -> s
|
_ -> s
|
||||||
|
|
||||||
unlexText :: [String] -> String
|
unlexText :: [String] -> String
|
||||||
unlexText = unlext where
|
unlexText = capitInit . 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]
|
||||||
@@ -67,7 +67,7 @@ lexMixed = concat . alternate False where
|
|||||||
lex env = if env then lexCode else lexText
|
lex env = if env then lexCode else lexText
|
||||||
|
|
||||||
unlexMixed :: [String] -> String
|
unlexMixed :: [String] -> String
|
||||||
unlexMixed = concat . alternate False where
|
unlexMixed = capitInit . concat . alternate False where
|
||||||
alternate env s = case s of
|
alternate env s = case s of
|
||||||
_:_ -> case break (=="$") s of
|
_:_ -> case break (=="$") s of
|
||||||
(t,[]) -> unlex env t : []
|
(t,[]) -> unlex env t : []
|
||||||
|
|||||||
Reference in New Issue
Block a user