#region License Information /* HeuristicLab * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Diagnostics; using System.Linq; namespace HeuristicLab.Grammars { public class Test { public static void Main(string[] args) { var gStr = @"S -> a B | b A A-> a | a S | b A A B -> b | b S | a B B "; var g = HeuristicLab.Grammars.Grammar.FromString(gStr); var l = new Language(g); var s2 = new string[][] { new string[] {"a", "b"}, new string[] {"b", "a"} }; var s4 = new string[][] { new string[] {"a", "a", "b", "b"}, new string[] {"a", "b", "a", "b"}, new string[] {"a", "b", "b", "a"}, new string[] {"b", "b", "a", "a"}, new string[] {"b", "a", "b", "a"}, new string[] {"b", "a", "a", "b"} }; var watch = new Stopwatch(); watch.Start(); var lPrime = l.Take(100000); int s = 0; foreach (var c in lPrime) { s++; /* foreach (var symb in c) Console.Write(symb); Console.WriteLine(); */ } watch.Stop(); Console.WriteLine(s); Console.WriteLine("Generating 10000 sentences: {0}ms", watch.ElapsedMilliseconds); } } }