示例#1
0
 public void testIsTerminal()
 {
     Assert.IsTrue(ProbUnrestrictedGrammar.isTerminal("x"));
     Assert.IsTrue(ProbUnrestrictedGrammar.isTerminal("xxxxx"));
     Assert.IsFalse(ProbUnrestrictedGrammar.isTerminal("X"));
     Assert.IsFalse(ProbUnrestrictedGrammar.isTerminal("XXXXXX"));
 }
示例#2
0
 public void testIsVariable()
 {
     Assert.IsTrue(ProbUnrestrictedGrammar.isVariable("S"));
     Assert.IsTrue(ProbUnrestrictedGrammar.isVariable("SSSSS"));
     Assert.IsFalse(ProbUnrestrictedGrammar.isVariable("s"));
     Assert.IsFalse(ProbUnrestrictedGrammar.isVariable("tttt"));
 }
示例#3
0
        /**
         * Print out the probability table produced by the CYK Algorithm
         * @param probTable
         * @param words
         * @param g
         */
        public void printProbTable(float[,,] probTable, ICollection <string> words, ProbUnrestrictedGrammar g)
        {
            int N = words.Size();
            int M = g.vars.Size(); // num non-terminals in grammar

            for (int i = 0; i < M; ++i)
            {
                System.Console.WriteLine("Table For : " + g.vars.Get(i) + "(" + i + ")");
                for (int j = 0; j < N; j++)
                {
                    System.Console.Write(j + "| ");
                    for (int k = 0; k < N; k++)
                    {
                        System.Console.Write(probTable[i, j, k] + " | ");
                    }
                    System.Console.WriteLine();
                }
                System.Console.WriteLine();
            }
        }
示例#4
0
 /**
  * The probability table get's us halfway there, but this method can provide the
  * derivation chain that most probably derives the words provided to the parser.
  * @param probTable
  * @param g
  * @return
  */
 public ICollection <string> getMostProbableDerivation(float[,,] probTable, ProbUnrestrictedGrammar g)
 {
     // TODO
     return(null);
 }
示例#5
0
 public void setup()
 {
     g = new ProbUnrestrictedGrammar(); // reset grammar before each test
 }
 public void setup()
 {
     g   = new ProbUnrestrictedGrammar();
     cfG = ProbContextFreeExamples.buildWumpusGrammar();
 }