/* Assumes dc is set according to type of speaker. (Generation would normally * be set the same way: generate in American English when talking to an * American...) * todo: Add FT_ADDRESS (useful only for French, to reduce probability of * singular "vous" interpretation when "tu" is expected) * todo: If a parse is accepted using a noncongruent lexical item, consider * updating the speaker model. */ Float LexEntryToObjScore(LexEntryToObj *leo, Discourse *dc) { Float score; if (leo == NULL) return(SCORE_MAX); switch (FeatureGet(leo->features, FT_FREQ)) { /* todoSCORE */ case F_FREQUENT: score = 1.0; break; case F_INFREQUENT: score = 0.2; break; default: score = 0.9; break; } score = ScoreCombine(score, StyleScore(FeatureGet(leo->features, FT_STYLE), DC(dc).style)); score = ScoreCombine(score, DialectScore(FeatureGet(leo->features, FT_DIALECT), DC(dc).dialect)); return(score); }
Float Syn_ParseFilterWY_W(PNode *w, PNode *y, int lang) { Float score; if (Syn_Parse_IsOnlyRelativeW(w, lang)) return(0.0); if (Syn_ParseRightmostIsPronoun(w)) return(0.0); if (Syn_Parse_IsAdvShiftableToVP(w, y, lang)) return(0.0); if (!XBarSatisfiesArgRestrictions(w, W_MAX_NPS, W_MAX_PPS-1, W_MAX_ARGS-1)) { return(0.0); } if (LexEntryConceptIsAncestor(N("prep-of"), PNodeLeftmostLexEntry(y))) { /* See Hindle and Rooth (1993, p. 109) * "default preference with of for noun attachment" todoSCORE */ score = 0.8; } else { score = SCORE_MAX; } if (!PNodeEndGroupingPunc(w)) { return(ScoreCombine(score, ScoreCount(PNodeNumberOfWords(w), 8, 20))); /* todoSCORE */ } return(score); }
/* Returns how many matching pns were found <r_cnt>, and how many of those * would be spliced out <r_spliced>. */ void TA_TaggerPrune2(PNode *pn, PNode *prev, int dosplice, size_t pos, int firstchar, Channel *ch, char *word, char *tag, /* RESULTS */ PNode **r_pn, PNode **r_prev, int *r_cnt, int *r_spliced) { int cnt, spliced; Float score; cnt = spliced = 0; for (; pn && pn->lowerb <= pos; pn = pn->next) { /* Dbg(DBGGEN, DBGHYPER, "%ld %ld\n", pn->lowerb, pos); */ if (pn->lowerb == pos && pn->type == PNTYPE_LEXITEM && pn->lexitem && pn->lexitem->word && (!PNodeIsPhrase(pn))) { if (firstchar != pn->lexitem->word[0]) { if (!dosplice) { Dbg(DBGGEN, DBGBAD, "TA_TaggerPrune1 firstchar mismatch <%c> <%s>", (char)firstchar, pn->lexitem->word); } prev = pn; } else if (0.0 == (score = PennTreebankTTCompatNBest(tag, pn->lexitem->features))) { /* Splice out. */ cnt++; spliced++; if (dosplice) { Dbg(DBGGEN, DBGDETAIL, "tag <%s> rules out <%s>.<%s>", tag, pn->lexitem->word, pn->lexitem->features); if (prev) { prev->next = pn->next; if (prev->next == NULL) ch->pnf->last = prev; /* todoFREE */ } else { ch->pnf->first = pn->next; if (ch->pnf->first == NULL) ch->pnf->last = NULL; } } } else { cnt++; if (dosplice && pn->score < 1.0) { pn->score = ScoreCombine(pn->score, score); Dbg(DBGGEN, DBGDETAIL, "nonbest tag <%s> modifies score of <%s>.<%s> to %d", tag, pn->lexitem->word, pn->lexitem->features, pn->score); } prev = pn; } } else { prev = pn; } } if (r_prev) *r_prev = prev; if (r_pn) *r_pn = pn; if (r_cnt) *r_cnt = cnt; if (r_spliced) *r_spliced = spliced; }