Lucene.Net.Tests.Util.Automaton.TestMinimize: Added notes about debugging efforts on the TestAgainstBrzozowski() test that is still failing.
Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/a9c3df54 Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/a9c3df54 Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/a9c3df54 Branch: refs/heads/api-work Commit: a9c3df54fe00713e6fdedd3b51fd72e1c36f5c36 Parents: d3151a3 Author: Shad Storhaug <[email protected]> Authored: Mon Mar 6 21:37:50 2017 +0700 Committer: Shad Storhaug <[email protected]> Committed: Mon Mar 6 21:38:56 2017 +0700 ---------------------------------------------------------------------- .../Util/Automaton/TestMinimize.cs | 215 ++++++++++++++++++- 1 file changed, 214 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a9c3df54/src/Lucene.Net.Tests/Util/Automaton/TestMinimize.cs ---------------------------------------------------------------------- diff --git a/src/Lucene.Net.Tests/Util/Automaton/TestMinimize.cs b/src/Lucene.Net.Tests/Util/Automaton/TestMinimize.cs index b2f6b52..b58eb06 100644 --- a/src/Lucene.Net.Tests/Util/Automaton/TestMinimize.cs +++ b/src/Lucene.Net.Tests/Util/Automaton/TestMinimize.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using NUnit.Framework; namespace Lucene.Net.Util.Automaton { @@ -61,6 +61,219 @@ namespace Lucene.Net.Util.Automaton } } + // LUCENENET TODO: + // + // DEBUG NOTE: + // + // Worked with the below test quite a bit to get it to match Lucene, + // but no luck so far. However, I was able to determine that + // + // AutomatonTestUtil.MinimizeSimple(a); + // Automaton b = (Automaton)a.Clone(); + // AutomatonTestUtil.MinimizeSimple(b); + // + // works and + // + // MinimizationOperations.Minimize(a); + // Automaton b = (Automaton)a.Clone(); + // MinimizationOperations.Minimize(b); + // + // works. So, it looks like the Clone() method is working. + // The only issue seems to be that the AutomatonTestUtil.MinimizeSimple() + // operation is somehow different than the MinimizationOperations.Minimize() + // operation. No more than one of them can be correct (but don't know which one, if either). + // + // I tried using the a.ToString() to compare what is happening against Java, + // but the results are coming back in a slightly different order. It is a strange implementation + // because SpecialOperations.Reverse() is called in AutomatonTestUtil.MinimizeSimple() + // but the results are stored in a HashSet<T>, which by definition is not ordered. + // So, it is not clear whether order is important or, if so, that it somehow depends + // on Java's HashSet implementation to work. It also isn't very clear what + // Automaton is supposed to do. + // + // I went over the AutomatonTestUtil line-by-line and although there were some things + // that needed correcting, the result is still the same. + + // HERE IS THE RESULT OF THE FOLLOWING TEST IN JAVA + + // One thing of note is that in .NET, the initial state + // is always coming back as 0 but in Java it is > 0 after + // the Minimize operation. + + //Before MinimizeSimple: initial state: 0 + //state 0 [accept]: + // S -> 1 + // * -> 2 + // \\U00005dbb -> 2 + // \\U000a9c44 -> 3 + //state 1 [reject]: + // \\U00000000-\\U0010ffff -> 4 + //state 2 [accept]: + //state 3 [reject]: + // \\U000001d9 -> 5 + //state 4 [reject]: + // ] -> 6 + // \\U0000e38e -> 7 + //state 5 [reject]: + // \\U00000000-\\U0010ffff -> 8 + //state 6 [reject]: + // \\U0000e38e -> 7 + //state 7 [reject]: + // \\U00021180 -> 9 + //state 8 [reject]: + // ] -> 10 + //state 9 [reject]: + // + -> 11 + //state 10 [accept]: + // \\U000761ca -> 2 + //state 11 [reject]: + // \\U0000f34c -> 12 + //state 12 [reject]: + // ] -> 13 + //state 13 [reject]: + // ] -> 14 + //state 14 [accept]: + // ] -> 14 + + //After MinimizeSimple: initial state: 12 + //state 0 [reject]: + // \\U00000000-\\U0010ffff -> 5 + //state 1 [reject]: + // \\U000001d9 -> 6 + //state 2 [accept]: + //state 3 [reject]: + // \\U0000e38e -> 4 + //state 4 [reject]: + // \\U00021180 -> 10 + //state 5 [reject]: + // ] -> 3 + // \\U0000e38e -> 4 + //state 6 [reject]: + // \\U00000000-\\U0010ffff -> 11 + //state 7 [reject]: + // ] -> 9 + //state 8 [reject]: + // ] -> 7 + //state 9 [accept]: + // ] -> 9 + //state 10 [reject]: + // + -> 13 + //state 11 [reject]: + // ] -> 14 + //state 12 [accept]: + // S -> 0 + // \\U000a9c44 -> 1 + // * -> 2 + // \\U00005dbb -> 2 + //state 13 [reject]: + // \\U0000f34c -> 8 + //state 14 [accept]: + // \\U000761ca -> 2 + + //After Clone: initial state: 0 + //state 0 [accept]: + // S -> 1 + // \\U000a9c44 -> 2 + // * -> 3 + // \\U00005dbb -> 3 + //state 1 [reject]: + // \\U00000000-\\U0010ffff -> 4 + //state 2 [reject]: + // \\U000001d9 -> 5 + //state 3 [accept]: + //state 4 [reject]: + // ] -> 6 + // \\U0000e38e -> 7 + //state 5 [reject]: + // \\U00000000-\\U0010ffff -> 8 + //state 6 [reject]: + // \\U0000e38e -> 7 + //state 7 [reject]: + // \\U00021180 -> 9 + //state 8 [reject]: + // ] -> 10 + //state 9 [reject]: + // + -> 11 + //state 10 [accept]: + // \\U000761ca -> 3 + //state 11 [reject]: + // \\U0000f34c -> 12 + //state 12 [reject]: + // ] -> 13 + //state 13 [reject]: + // ] -> 14 + //state 14 [accept]: + // ] -> 14 + + //After Minimize: initial state: 11 + //state 0 [reject]: + // \\U0000e38e -> 2 + //state 1 [reject]: + // ] -> 0 + // \\U0000e38e -> 2 + //state 2 [reject]: + // \\U00021180 -> 3 + //state 3 [reject]: + // + -> 4 + //state 4 [reject]: + // \\U0000f34c -> 8 + //state 5 [reject]: + // \\U000001d9 -> 7 + //state 6 [accept]: + // \\U000761ca -> 14 + //state 7 [reject]: + // \\U00000000-\\U0010ffff -> 9 + //state 8 [reject]: + // ] -> 13 + //state 9 [reject]: + // ] -> 6 + //state 10 [reject]: + // \\U00000000-\\U0010ffff -> 1 + //state 11 [accept]: + // \\U000a9c44 -> 5 + // S -> 10 + // * -> 14 + // \\U00005dbb -> 14 + //state 12 [accept]: + // ] -> 12 + //state 13 [reject]: + // ] -> 12 + //state 14 [accept]: + + + //[Test] + //public virtual void TestAgainstBrzozowskiFixed() + //{ + // //int num = AtLeast(200); + // //for (int i = 0; i < num; i++) + // //{ + + // //string regExp1 = AutomatonTestUtil.RandomRegexp(Random()); + // //string regExp2 = AutomatonTestUtil.RandomRegexp(Random()); + // //System.Console.WriteLine("regExp1: " + regExp1); + // //System.Console.WriteLine("regExp2: " + regExp2); + + // string regExp1 = "S.]?îð¡(+ï]+)]"; + // string regExp2 = "*|ò©±Ç.()]ñ¶?|å¶»?"; + + // Automaton a1 = new RegExp(regExp1, RegExpSyntax.NONE).ToAutomaton(); + // Automaton a2 = new RegExp(regExp2, RegExpSyntax.NONE).ToAutomaton(); + // Automaton a = BasicOperations.Union(a1, a2); + // System.Console.WriteLine("Before MinimizeSimple: " + a.ToString()); + + // AutomatonTestUtil.MinimizeSimple(a); + // System.Console.WriteLine("After MinimizeSimple: " + a.ToString()); + // Automaton b = (Automaton)a.Clone(); + // System.Console.WriteLine("After Clone: " + b.ToString()); + // MinimizationOperations.Minimize(b); + // System.Console.WriteLine("After Minimize: " + b.ToString()); + // Assert.IsTrue(BasicOperations.SameLanguage(a, b)); + // Assert.AreEqual(a.GetNumberOfStates(), b.GetNumberOfStates()); + // Assert.AreEqual(a.GetNumberOfTransitions(), b.GetNumberOfTransitions()); + // //} + //} + + /// <summary> /// n^2 space usage in Hopcroft minimization? </summary> [Test]
