From 896233c4a9b85b2fe98ac22300bfef5d231f1be4 Mon Sep 17 00:00:00 2001 From: bringert Date: Mon, 26 Mar 2007 17:36:58 +0000 Subject: [PATCH] Remove all empty SLF nodes, don't care about edge explosion. Empty nodes are pprobably worse than lots of edges. --- src/GF/Speech/FiniteState.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/GF/Speech/FiniteState.hs b/src/GF/Speech/FiniteState.hs index 69b8de457..7c62ee0f8 100644 --- a/src/GF/Speech/FiniteState.hs +++ b/src/GF/Speech/FiniteState.hs @@ -184,8 +184,7 @@ moveLabelsToNodes = onGraph f removeTrivialEmptyNodes :: (Eq a, Ord n) => FA n (Maybe a) () -> FA n (Maybe a) () removeTrivialEmptyNodes = pruneUnusable . skipSimpleEmptyNodes --- | Move edges to empty nodes with exactly one outgoing edge --- or exactly one incoming edge to point to the next node(s). +-- | Move edges to empty nodes to point to the next node(s). -- This is not done if the pointed-to node is a final node. skipSimpleEmptyNodes :: (Eq a, Ord n) => FA n (Maybe a) () -> FA n (Maybe a) () skipSimpleEmptyNodes fa = onGraph og fa @@ -196,10 +195,12 @@ skipSimpleEmptyNodes fa = onGraph og fa info = nodeInfo g changeEdge e@(f,t,()) | isNothing (getNodeLabel info t) - && (inDegree info t == 1 || outDegree info t == 1) + -- && (i * o <= i + o) && not (isFinal fa t) = [ (f,t',()) | (_,t',()) <- getOutgoing info t] | otherwise = [e] +-- where i = inDegree info t +-- o = outDegree info t isInternal :: Eq n => FA n a b -> n -> Bool isInternal (FA _ start final) n = n /= start && n `notElem` final