public void testIsTerminal() { Assert.IsTrue(ProbUnrestrictedGrammar.isTerminal("x")); Assert.IsTrue(ProbUnrestrictedGrammar.isTerminal("xxxxx")); Assert.IsFalse(ProbUnrestrictedGrammar.isTerminal("X")); Assert.IsFalse(ProbUnrestrictedGrammar.isTerminal("XXXXXX")); }
public void testIsVariable() { Assert.IsTrue(ProbUnrestrictedGrammar.isVariable("S")); Assert.IsTrue(ProbUnrestrictedGrammar.isVariable("SSSSS")); Assert.IsFalse(ProbUnrestrictedGrammar.isVariable("s")); Assert.IsFalse(ProbUnrestrictedGrammar.isVariable("tttt")); }
/** * 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(); } }
/** * 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); }
public void setup() { g = new ProbUnrestrictedGrammar(); // reset grammar before each test }
public void setup() { g = new ProbUnrestrictedGrammar(); cfG = ProbContextFreeExamples.buildWumpusGrammar(); }