mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-21 17:12:50 -06:00
Remove removeIdenticalRules, since it would get rid of alternative parse results.
This commit is contained in:
@@ -66,7 +66,6 @@ makeSimpleRegular :: Options -> StateGrammar -> CFRules
|
|||||||
makeSimpleRegular opts s = makeRegular $ preprocess $ cfgToCFRules s
|
makeSimpleRegular opts s = makeRegular $ preprocess $ cfgToCFRules s
|
||||||
where start = getStartCatCF opts s
|
where start = getStartCatCF opts s
|
||||||
preprocess = fix (topDownFilter start . bottomUpFilter)
|
preprocess = fix (topDownFilter start . bottomUpFilter)
|
||||||
. removeIdenticalRules
|
|
||||||
. removeCycles
|
. removeCycles
|
||||||
|
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -97,7 +97,6 @@ makeSimpleSRG opt s =
|
|||||||
(cats,cfgRules) = unzip $ preprocess $ cfgToCFRules s
|
(cats,cfgRules) = unzip $ preprocess $ cfgToCFRules s
|
||||||
preprocess = removeLeftRecursion origStart
|
preprocess = removeLeftRecursion origStart
|
||||||
. fix (topDownFilter origStart . bottomUpFilter)
|
. fix (topDownFilter origStart . bottomUpFilter)
|
||||||
. removeIdenticalRules
|
|
||||||
. removeCycles
|
. removeCycles
|
||||||
names = mkCatNames name cats
|
names = mkCatNames name cats
|
||||||
rs = map (cfgRulesToSRGRule names probs) cfgRules
|
rs = map (cfgRulesToSRGRule names probs) cfgRules
|
||||||
|
|||||||
@@ -112,14 +112,6 @@ topDownFilter start rules = filter ((`Set.member` keep) . fst) rules
|
|||||||
uses = reflexiveClosure_ (allCats rules) $ transitiveClosure $ mkRel rhsCats
|
uses = reflexiveClosure_ (allCats rules) $ transitiveClosure $ mkRel rhsCats
|
||||||
keep = allRelated uses start
|
keep = allRelated uses start
|
||||||
|
|
||||||
-- | Remove rules which have the same rhs.
|
|
||||||
-- FIXME: this messes up probabilities, names and profiles
|
|
||||||
removeIdenticalRules :: CFRules -> CFRules
|
|
||||||
removeIdenticalRules g = [(c,sortNubBy cmpRules rs) | (c,rs) <- g]
|
|
||||||
where
|
|
||||||
cmpRules (CFRule c1 ss1 _) (CFRule c2 ss2 _) =
|
|
||||||
mconcat [c1 `compare` c2, ss1 `compare` ss2]
|
|
||||||
|
|
||||||
-- * Removing left recursion
|
-- * Removing left recursion
|
||||||
|
|
||||||
-- The LC_LR algorithm from
|
-- The LC_LR algorithm from
|
||||||
|
|||||||
Reference in New Issue
Block a user