mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
Merge branch 'majestic' of github.com:GrammaticalFramework/gf-core into majestic
This commit is contained in:
@@ -1149,23 +1149,30 @@ exit:
|
|||||||
PgfExpr PgfExprProbEstimator::eabs(PgfBindType bind_type, PgfText *name, PgfExpr body)
|
PgfExpr PgfExprProbEstimator::eabs(PgfBindType bind_type, PgfText *name, PgfExpr body)
|
||||||
{
|
{
|
||||||
m->match_expr(this, body);
|
m->match_expr(this, body);
|
||||||
|
cat_prob = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PgfExpr PgfExprProbEstimator::eapp(PgfExpr fun, PgfExpr arg)
|
PgfExpr PgfExprProbEstimator::eapp(PgfExpr fun, PgfExpr arg)
|
||||||
{
|
{
|
||||||
m->match_expr(this, fun);
|
prob_t tmp = cat_prob_total;
|
||||||
|
cat_prob_total = 0;
|
||||||
m->match_expr(this, arg);
|
m->match_expr(this, arg);
|
||||||
|
cat_prob_total = tmp + cat_prob;
|
||||||
|
m->match_expr(this, fun);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PgfExpr PgfExprProbEstimator::elit(PgfLiteral lit)
|
PgfExpr PgfExprProbEstimator::elit(PgfLiteral lit)
|
||||||
{
|
{
|
||||||
|
cat_prob = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PgfExpr PgfExprProbEstimator::emeta(PgfMetaId meta_id)
|
PgfExpr PgfExprProbEstimator::emeta(PgfMetaId meta_id)
|
||||||
{
|
{
|
||||||
|
prob += cat_prob_total;
|
||||||
|
cat_prob = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1173,16 +1180,25 @@ PgfExpr PgfExprProbEstimator::efun(PgfText *name)
|
|||||||
{
|
{
|
||||||
ref<PgfAbsFun> absfun =
|
ref<PgfAbsFun> absfun =
|
||||||
namespace_lookup(pgf->abstract.funs, name);
|
namespace_lookup(pgf->abstract.funs, name);
|
||||||
if (absfun == 0)
|
if (absfun == 0) {
|
||||||
prob = INFINITY;
|
prob = INFINITY;
|
||||||
else
|
cat_prob = INFINITY;
|
||||||
|
} else {
|
||||||
prob += absfun->prob;
|
prob += absfun->prob;
|
||||||
|
|
||||||
|
ref<PgfAbsCat> abscat =
|
||||||
|
namespace_lookup(pgf->abstract.cats, &absfun->type->name);
|
||||||
|
if (abscat == 0)
|
||||||
|
cat_prob = INFINITY;
|
||||||
|
else
|
||||||
|
cat_prob = abscat->prob;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PgfExpr PgfExprProbEstimator::evar(int index)
|
PgfExpr PgfExprProbEstimator::evar(int index)
|
||||||
{
|
{
|
||||||
|
cat_prob = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -198,12 +198,16 @@ class PGF_INTERNAL_DECL PgfExprProbEstimator : public PgfUnmarshaller {
|
|||||||
PgfPGF *pgf;
|
PgfPGF *pgf;
|
||||||
PgfMarshaller *m;
|
PgfMarshaller *m;
|
||||||
prob_t prob;
|
prob_t prob;
|
||||||
|
prob_t cat_prob;
|
||||||
|
prob_t cat_prob_total;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PgfExprProbEstimator(PgfPGF *pgf, PgfMarshaller *marshaller) {
|
PgfExprProbEstimator(PgfPGF *pgf, PgfMarshaller *marshaller) {
|
||||||
this->pgf = pgf;
|
this->pgf = pgf;
|
||||||
this->m = marshaller;
|
this->m = marshaller;
|
||||||
this->prob = 0;
|
this->prob = 0;
|
||||||
|
this->cat_prob = 0;
|
||||||
|
this->cat_prob_total = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual PgfExpr eabs(PgfBindType bind_type, PgfText *name, PgfExpr body);
|
virtual PgfExpr eabs(PgfBindType bind_type, PgfText *name, PgfExpr body);
|
||||||
|
|||||||
Reference in New Issue
Block a user