private CykFillInBase ( Sentence s, double P, int>.Dictionary |
||
s | Sentence | |
P | double | |
RToJ | int>.Dictionary | |
return | bool |
private bool CykFillInBase(Sentence s, double[,,] P, Dictionary<Nonterminal, int> RToJ) {
for (int i = 0; i < s.Count; i++) {
var a_i = (Terminal)s[i];
var yields_a_i = _grammar.ProductionsProductingTerminal(a_i);
if (yields_a_i.Count == 0) {
// the grammar can't possibly produce this string if it doesn't know a terminal
return true;
}
foreach (var production in yields_a_i) {
var j = RToJ[production.Lhs];
P[0, i, j] += _grammar.GetProbability(production);
}
}
return false;
}