mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
Change category naming in CFG generation: the number now starts from 1 for each GF category, instead of being the FCFG category number.
This commit is contained in:
@@ -61,14 +61,16 @@ pgfToCFG pgf lang = mkCFG (lookStartCat pgf) extCats (startRules ++ concatMap fr
|
||||
rules :: [FRule]
|
||||
rules = Array.elems (PGF.allRules pinfo)
|
||||
|
||||
fcatGFCats :: Map FCat CId
|
||||
fcatGFCats = Map.fromList [(fc,c) | (c,fcs) <- Map.toList (startupCats pinfo), fc <- fcs]
|
||||
|
||||
fcatGFCat :: FCat -> CId
|
||||
fcatGFCat c = fromMaybe (mkCId "Unknown") (Map.lookup c fcatGFCats)
|
||||
fcatCats :: Map FCat Cat
|
||||
fcatCats = Map.fromList [(fc, prCId c ++ "_" ++ show i)
|
||||
| (c,fcs) <- Map.toList (startupCats pinfo),
|
||||
(fc,i) <- zip fcs [1..]]
|
||||
|
||||
fcatCat :: FCat -> Cat
|
||||
fcatCat c = Map.findWithDefault ("Unknown_" ++ show c) c fcatCats
|
||||
|
||||
fcatToCat :: FCat -> FIndex -> Cat
|
||||
fcatToCat c l = prCId (fcatGFCat c) ++ "_" ++ show c ++ row
|
||||
fcatToCat c l = fcatCat c ++ row
|
||||
where row = if catLinArity c == 1 then "" else "_" ++ show l
|
||||
|
||||
-- gets the number of fields in the lincat for the given category
|
||||
|
||||
Reference in New Issue
Block a user