protected internal virtual bool AddOneUnaryRule(UnaryRule rule, IDictionary <string, TransducerGraph> graphs) { string parentString = stateIndex.Get(rule.parent); string childString = stateIndex.Get(rule.child); if (IsSyntheticState(parentString)) { string topcat = GetTopCategoryOfSyntheticState(parentString); TransducerGraph graph = GetGraphFromMap(graphs, topcat); double output = SmartNegate(rule.Score()); graph.AddArc(graph.GetStartNode(), parentString, childString, output); return(true); } else { if (IsSyntheticState(childString)) { // need to add Arc from synthetic state to endState TransducerGraph graph = GetGraphFromMap(graphs, parentString); double output = SmartNegate(rule.Score()); graph.AddArc(childString, parentString, End, output); // parentString should the the same as endState graph.SetEndNode(parentString); return(true); } else { return(false); } } }
protected internal static TransducerGraph GetGraphFromMap(IDictionary <string, TransducerGraph> m, string o) { TransducerGraph graph = m[o]; if (graph == null) { graph = new TransducerGraph(); graph.SetEndNode(o); m[o] = graph; } return(graph); }