Bool IsGarbage(Obj *obj) { Obj *head; if (ObjIsNa(obj) || ObjIsVar(obj)) return(1); #ifdef notdef if (ObjInDeep(ObjNA, obj)) { /* na should be considered garbage: * "Is Irish soda bread a drink?" * na should NOT be considered garbage: * "[active-goal X [buy X na car na]]" */ */ return(1); } #endif head = I(obj, 0); if (N("one") == head) return(1); /* note ISA(N("standard-copula"), head) is not garbage; cf UA_Question */ if (ISADeep(N("relative-pronoun"), obj)) { /* These are supposed to be dealt with by Sem_Parse. If they * are still present, then someone isn't constraining away * faulty parses. */ return(1); } return(0); }
/* Returns: NULL, when <cas> not found in <obj> and <cas> is optional * restriction pronoun, when <cas> not found in <obj> and <cas> * is required * value, when <cas> found in <obj> */ Obj *ThetaRoleGetCaseValue(Obj *obj, ThetaRole *theta_roles, Obj *cas, /* RESULTS */ int *i_r, int *subcat_r) { int i; Bool isoptional; i = ThetaRoleGetCaseIndex(theta_roles, cas, subcat_r, &isoptional); if (i_r) *i_r = i; if (i < 0 || ObjIsNa(I(obj, i))) { if (isoptional) return(NULL); else return(ThetaRoleRestrictionPronoun(I(obj, 0), i)); } return(I(obj, i)); }
void UA_Trade(Actor *ac, Ts *ts, Obj *a, Obj *in) { ObjList *products, *forsales, *p, *commentary; Intension *itn; if (ISA(N("active-goal"), I(in, 0)) && I(in, 1) == a && ISA(N("buy-from"), I(I(in, 2), 0)) && I(I(in, 2), 1) == a && (!ObjIsNa(I(I(in, 2), 3)))) { /* "I want to buy a desk phone." */ if ((products = UA_AskerSelect(ac->cx, I(I(in, 2), 3), &itn))) { commentary = NULL; for (p = products; p; p = p->next) { /* todo: Filter out old ads. */ forsales = RE(&TsNA, L(N("for-sale"), p->obj, ObjWild, ObjWild, ObjWild, ObjWild, ObjWild, E)); commentary = ObjListAppendDestructive(commentary, forsales); } /* if ((!(ac->cx->dc->mode & DC_MODE_CONV)) || ObjListLen(products) < 10 || ObjListLen(commentary) < 10) */ if ((!(ac->cx->dc->mode & DC_MODE_CONV)) || ObjListLen(products) < 18) { if (commentary) { CommentaryAdd(ac->cx, commentary, NULL); ContextSetRSN(ac->cx, RELEVANCE_TOTAL, SENSE_TOTAL, NOVELTY_TOTAL); } } else { /* Too much output. Try to narrow down with a question. An answer * to the question should result in this function being reinvoked * with something that UA_AskerSelect is able to use to narrow down * the selected products. */ if (UA_AskerNarrowDown(ac->cx, 1.0, N("UA_Trade"), itn, products, L(N("active-goal"), a, L(N("buy-from"), a, I(I(in, 2), 2), N("?answer"), I(I(in, 2), 4), E), E), 1)) { ContextSetRSN(ac->cx, RELEVANCE_TOTAL, SENSE_TOTAL, NOVELTY_TOTAL); } } } } }
/* Return values similar to ThetaRoleGetCaseValue. */ Obj *ThetaRoleGetCaseValueIth(Obj *obj, ThetaRole *theta_roles, Obj *cas, int n, /* RESULTS */ LexEntry **le, int *subcat_r, Bool *isoptional, int *done) { int i; ThetaRoleGetCase(theta_roles, cas, n, le, &i, subcat_r, isoptional); if (i < 0) { *done = 1; return(NULL); } *done = 0; if (ObjIsNa(I(obj, i))) { if (isoptional) { return(NULL); } else { return(ThetaRoleRestrictionPronoun(I(obj, 0), i)); } } return(I(obj, i)); }