mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 19:22:50 -06:00
add bracketLinearizeAll for variants
This commit is contained in:
@@ -58,7 +58,7 @@ module PGF(
|
|||||||
|
|
||||||
-- * Operations
|
-- * Operations
|
||||||
-- ** Linearization
|
-- ** Linearization
|
||||||
linearize, linearizeAllLang, linearizeAll, bracketedLinearize, tabularLinearizes,
|
linearize, linearizeAllLang, linearizeAll, bracketedLinearize, bracketedLinearizeAll, tabularLinearizes,
|
||||||
groupResults, -- lins of trees by language, removing duplicates
|
groupResults, -- lins of trees by language, removing duplicates
|
||||||
showPrintName,
|
showPrintName,
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ module PGF.Linearize
|
|||||||
, linearizeAll
|
, linearizeAll
|
||||||
, linearizeAllLang
|
, linearizeAllLang
|
||||||
, bracketedLinearize
|
, bracketedLinearize
|
||||||
|
, bracketedLinearizeAll
|
||||||
, tabularLinearizes
|
, tabularLinearizes
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@@ -47,6 +48,12 @@ bracketedLinearize pgf lang = head . map (snd . untokn Nothing . firstLin cnc) .
|
|||||||
head [] = []
|
head [] = []
|
||||||
head (bs:bss) = bs
|
head (bs:bss) = bs
|
||||||
|
|
||||||
|
-- | Linearizes given expression as a bracketed string in the language
|
||||||
|
bracketedLinearizeAll :: PGF -> Language -> Tree -> [[BracketedString]]
|
||||||
|
bracketedLinearizeAll pgf lang = map (snd . untokn Nothing . firstLin cnc) . linTree pgf cnc
|
||||||
|
where
|
||||||
|
cnc = lookMap (error "no lang") lang (concretes pgf)
|
||||||
|
|
||||||
firstLin cnc arg@(ct@(cat,n_fid),fid,fun,es,(xs,lin)) =
|
firstLin cnc arg@(ct@(cat,n_fid),fid,fun,es,(xs,lin)) =
|
||||||
case IntMap.lookup fid (linrefs cnc) of
|
case IntMap.lookup fid (linrefs cnc) of
|
||||||
Just (funid:_) -> snd (mkLinTable cnc (const True) [] funid [arg]) ! 0
|
Just (funid:_) -> snd (mkLinTable cnc (const True) [] funid [arg]) ! 0
|
||||||
|
|||||||
Reference in New Issue
Block a user