void ContextPrint(FILE *stream, Context *cx) { StreamSep(stream); fprintf(stream, "Context %ld sense %g ", cx->id, cx->sense); fputs(ContextModeString(cx->mode), stream); fputc(SPACE, stream); TsRangePrint(stream, &cx->story_time); fprintf(stream, " tensestep %d\n", cx->story_tensestep); if (cx->sproutcon) { fputs("last concept ", stream); ObjPrint(stream, cx->sproutcon); fputc(NEWLINE, stream); } if (cx->sproutcon) { fputs("last pn:\n", stream); PNodePrettyPrint(stream, NULL, cx->sproutpn); } AnswerPrintAll(stream, cx->answer, cx->dc); AnswerPrintAll(stream, cx->commentary, cx->dc); ContextPrintReasons(stream, cx); if (cx->questions) { QuestionPrintAll(stream, cx->questions); } if (cx->reinterp) { fputs("Reinterp ", stream); ObjPrint(stream, cx->reinterp); fputc(NEWLINE, stream); } ActorPrintAll(stream, cx->actors); }
void DbgOP(int flag, int level, Obj *obj) { if (DbgOn(flag, level)) { ObjPrint(Log, obj); fputc(NEWLINE, Log); } }
void ThetaRolePrint1(FILE *stream, ThetaRole *tr, int slotnum, Obj *con) { Obj *restrict; restrict = NULL; if (tr->isoptional) fputc(LPAREN, stream); else fputc(SPACE, stream); if (tr->cas == N("expl")) { fputs(" : ", stream); } else { if (con) { restrict = DbGetRestriction(con, slotnum); if (restrict == N("concept") || restrict == N("object")) restrict = NULL; } fprintf(stream, "%2d: ", slotnum); } fprintf(stream, "%7s ", M(tr->cas)); if (tr->le) { fprintf(stream, "%10s.%4s ", tr->le->srcphrase, tr->le->features); } else { fprintf(stream, "%10s %4s ", "", ""); } if (tr->subcat != F_NULL) fputc(tr->subcat, stream); else fputc(SPACE, stream); fprintf(stream, "%4s ", TRPOSToString(tr->position)); if (restrict) ObjPrint(stream, restrict); if (tr->isoptional) fputc(RPAREN, stream); else fputc(SPACE, stream); fputc(NEWLINE, stream); }
void ProveIt(char *goal_filename, char *rule_filename, char *fact_filename, char *output_filename) { Obj *goal; ObjList *rules; ObjList *facts; Proof *proofs; FILE *outstream; if (NULL == (outstream = StreamOpen(output_filename, "w+"))) { return; } goal = ObjFileRead(goal_filename); if (goal == NULL) { return; } rules = ObjListFileRead(rule_filename); facts = ObjListFileRead(fact_filename); fprintf(outstream, "input goal = "); ObjPrint(outstream, goal); fputc(NEWLINE, outstream); fprintf(outstream, "input rules =\n"); ObjListPrint(outstream, rules); fprintf(outstream, "input facts =\n"); ObjListPrint(outstream, facts); if (Prove1(&TsNA, NULL, goal, rules, facts, 1, 0, &proofs)) { fprintf(outstream, "found proofs:\n"); ProofPrintAll(outstream, proofs); } else { fprintf(outstream, "did not find proofs\n"); } StreamClose(outstream); }
Obj *ContextMapAssertion(Context *cx_parent, Context *cx_child, Obj *obj_parent) { ObjList *p; if (obj_parent == NULL) return(NULL); for (p = cx_parent->assertions; p; p = p->next) { if (p->obj == obj_parent) return(p->u.child_copy); } Dbg(DBGGEN, DBGBAD, "ContextMapAssertion failure"); ObjPrint(Log, obj_parent); fprintf(Log, "\nnot in:\n"); ObjListPrint(Log, cx_parent->assertions); Stop(); return(NULL); }