void ThetaRoleTextPrint(Text *text, int html, LexEntry *le, ThetaRole *theta_roles, Obj *con, Discourse *dc) { int lang; char buf[DWORDLEN]; lang = FeatureGet(le->features, FT_LANG); ThetaRoleTextPrint1(text, html, lang, TRPOS_NA, N("subj"), theta_roles, con, dc); ThetaRoleTextPrint1(text, html, lang, TRPOS_NA, N("aobj"), theta_roles, con, dc); ThetaRoleTextPrint1(text, html, lang, TRPOS_PRE_VERB, N("expl"), theta_roles, con, dc); LexEntryAddSep(le, le->srcphrase, DWORDLEN-1, buf); if (html) { HTML_TextPrintBoldBeginIfEnglish(text, lang); HTML_TextPrint(text, buf); TextPutc(SPACE, text); HTML_TextPrintBoldEndIfEnglish(text, lang); } else { TextPutword(buf, TERM, text); } ThetaRoleTextPrint1(text, html, lang, TRPOS_POST_VERB_PRE_OBJ, N("expl"), theta_roles, con, dc); ThetaRoleTextPrint1(text, html, lang, TRPOS_NA, N("obj"), theta_roles, con, dc); ThetaRoleTextPrint1(text, html, lang, TRPOS_POST_VERB_POST_OBJ, N("expl"), theta_roles, con, dc); ThetaRoleTextPrint1(text, html, lang, TRPOS_NA, N("iobj"), theta_roles, con, dc); }
void RptTextPrint1(Text *text, char *s, int fieldlen, int just) { int i, slen, total; if (StringIn(NEWLINE, s)) { if (0) { /* if (strlen(s) < fieldlen) { */ StringElimChar(s, NEWLINE); /* Destructive. Watch out. */ TextPuts(s, text); } else { TextPutsIndented(s, text, " "); return; } } slen = strlen(s); if (slen > fieldlen) { for (i = 0; i < fieldlen; i++) TextPutc(s[i], text); return; } if (just == RPT_JUST_RIGHT) { total = fieldlen - slen; TextPrintSpaces(text, total); } else if (just == RPT_JUST_CENTER) { total = (fieldlen - slen)/2; TextPrintSpaces(text, total); } else total = 0; TextPuts(s, text); total += slen; TextPrintSpaces(text, fieldlen-total); }
void RptTextPrintLine(Text *text, Rpt *r, RptLine *rl, int maxfieldlen, int sep) { int i, len; RptField *rf; for (rf = rl->fields, i = 0, len = r->numfields; rf && i < len; i++, rf = rf->next) { if (sep) { RptTextPrint1(text, "________________________________________________________________________________________", IntMin(r->fieldlens[i], maxfieldlen), rf->just); } else { RptTextPrint1(text, rf->s, IntMin(r->fieldlens[i], maxfieldlen), rf->just); } if (rf->next) TextPutc(SPACE, text); } TextPutc(NEWLINE, text); }
/* Used in printing word syntax. * Long form; contrast with TextPrintWordAndFeatures. * (Both long and short forms are used by Dict.) */ void ThetaRoleTextPrint1(Text *text, int html, int lang, int position, Obj *cas_restrict, ThetaRole *theta_roles, Obj *con, Discourse *dc) { int subcat, slotnum, dospace; Obj *cas, *restrict; Bool isoptional; char *p, buf[PHRASELEN], *s; LexEntry *le; for (slotnum = 1; theta_roles; theta_roles = theta_roles->next, slotnum++) { if (theta_roles->cas == N("expl")) { slotnum--; } if (position != theta_roles->position) continue; if (cas_restrict && cas_restrict != theta_roles->cas) continue; ThetaRoleGet(theta_roles, &le, &cas, &subcat, &isoptional); if (cas == ObjNA) { buf[0] = LBRACE; buf[1] = TERM; p = buf+1; } else if (cas == N("expl")) { buf[0] = TERM; p = buf; } else if (isoptional) { buf[0] = LPAREN; buf[1] = TERM; p = buf+1; } else { buf[0] = LBRACKET; buf[1] = TERM; p = buf+1; } if (html) { TextPuts(buf, text); } if (cas != ObjNA && cas != N("expl")) { if (html) { HTML_TextPrint(text, GenConceptAbbrevString(cas, 1, dc)); } else { StringCpy(p, GenConceptAbbrevString(cas, 1, dc), PHRASELEN-1); } dospace = 1; } else { dospace = 0; } if (con && (cas != N("expl"))) restrict = DbGetRestriction(con, slotnum); else restrict = NULL; if (restrict == N("concept") || restrict == N("object")) restrict = NULL; if (le) { if (dospace) { if (html) { TextPutc(SPACE, text); } else { StringAppendChar(buf, PHRASELEN, SPACE); } dospace = 0; } if (html) { LexEntryAddSep(le, le->srcphrase, PHRASELEN, buf); HTML_TextPrintBoldBeginIfEnglish(text, lang); HTML_TextPrint(text, buf); TextPutc(SPACE, text); HTML_TextPrintBoldEndIfEnglish(text, lang); } else { LexEntryAddSep(le, le->srcphrase, PHRASELEN, StringEndOf(buf)); } if (cas != N("expl")) { if (html) { TextPutc('+', text); } else { StringAppendChar(buf, PHRASELEN, '+'); } } } if (restrict && !ObjIsList(restrict)) { if (dospace) { if (html) { TextPutc(SPACE, text); } else { StringAppendChar(buf, PHRASELEN, SPACE); } dospace = 0; } if (html) { HTML_TextLinkToObj(text, restrict, 1, 0, 0); } else { GenConceptString(restrict, N("empty-article"), F_NOUN, F_NULL, DC(dc).lang, F_NULL, F_NULL, F_NULL, PHRASELEN, 1, 0, dc, p = StringEndOf(buf)); StringToUpperDestructive(p); } dospace = 1; } if (subcat != F_NULL) { if (html) { if ((s = GenFeatAbbrevString(subcat, 1, dc))) { TextPuts(s, text); } } else { if ((s = GenFeatAbbrevString(subcat, 1, dc))) { StringCat(buf, s, PHRASELEN); } } } if (html) { if (cas == ObjNA) TextPutc(RBRACE, text); else if (cas == N("expl")) Nop(); else if (isoptional) TextPutc(RPAREN, text); else TextPutc(RBRACKET, text); TextPutc(SPACE, text); } else { if (cas == ObjNA) StringAppendChar(buf, PHRASELEN, RBRACE); else if (cas == N("expl")) Nop(); else if (isoptional) StringAppendChar(buf, PHRASELEN, RPAREN); else StringAppendChar(buf, PHRASELEN, RBRACKET); TextPutword(buf, TERM, text); } } }