public RuleSet Synthesize(ExampleGroup exampleGroup, int k) { var examples = exampleGroup.examples; RuleSet ruleSet; _stopwatch.Restart(); // 1. Synthesize error pattern. var pattern = SynthesizeErrPattern(examples); if (pattern.HasValue) { Log.Debug("Synthesized error pattern: {0}", pattern); // 2. Synthesize transformers. var trans = SynthesizeTransformers(examples.Select(e => e.AsTExample(pattern.Value)), k); ruleSet = new RuleSet(pattern.Value, trans, exampleGroup.Name); } else { ruleSet = RuleSet.Empty; } _stopwatch.Stop(); Log.Info("Overall synthesis time: {0} ms", _stopwatch.ElapsedMilliseconds); return(ruleSet); }
private JObject LearnRuleSet(ExampleGroup examples) { var ruleSet = _synthesizer.Synthesize(examples, _topK); _rule_lib.add(ruleSet); JObject stat = new JObject(); stat.Add("example group path", examples.path); stat.Add("example group size", examples.Size); stat.Add("synthesis time (ms)", _synthesizer.SynthesisTime); stat.Add("synthesis succeeds?", !ruleSet.IsEmpty); stat.Add("rule set size", ruleSet.Size); stat.Add("rule set name", ruleSet.Name); return(stat); }