`
`PATENT
`Docket No.: 4428-4001
`
`main(int argc, char *argv[])
`
`int i=0;
`
`/*if (arge != 5)
`
`printf(""Usage Instructions: dialog config_file learn_file\n");
`printf("*** Exiting, goodbye.\n");
`exit(1);
`}*/
`if (arge != 2)
`
`printf("Usage Instructions: d <ini-file>\n");
`printf("*** Exiting, goodbye.\n");
`exit(1);
`}
`readini(argv[1]);
`formfile = fdoc;
`loadStopWords(sdoc);
`numPF = loadFormsList(xdoc);
`numForms = loadForms(fdoc);
`loadData(cfg, Icfg);
`Interactive(Icfg);
`
`} 9
`
`6 a ee ee eee ee eeee heRkA ee aaEE
`loaddata : This function will read the configuration files and load the
`information into the relevant global arrays.
`2 ee fe ae ae ee oe oe ee oe 2 oe fe oe he oe 2 ee oe oe oe ae ee ee 9 Ee Ae ee ee oe Re EAoe oe oO OR /
`loadData(char *filenm, char *file2)
`
`{ c
`
`har buf[256], word[20];
`inti, j, k, |;
`int numext;
`FILE *fp, *f2;
`
`[FR A aa oe ooee open configuration file 2 ee ee oe oe aeae eo
`fp = fileOpen(filenm, "r");
`
` /
`
`[RE open learn(extended thesaurus) file AO oe oeke oe2 aoe ee ae
`f2 = fileOpen(file2, "r);
`
`728851 vi
`
`77
`
`480
`480
`
`
`
`‘
`
`LOS99359 .ALLVoOe
`
`PATENT
`Docket No.: 4428-4001
`
`prompts = columnTerms = rowTerms = NULL;
`scoring = thesaurus = indexList = menuList = NULL;
`
`/* read data in the arrays */
`numMenu = loadMenuTree(fp, "[MENUTREE}");
`numIndex = readArray(fp, “[PROMPTS]", &prompts, 1, NULL,0,0);
`numColumn = readArray(fp, "[INDEX]", &columnTerms, 1, &indexList, numIndex,0);
`numOrgRow = readArray(fp, "[THESAURUS]", &rowTemns, 1, &thesaurus, numColumn,0);
`numRow = readArray(f2, "[EXT-THESAURUS]", &rowTerms, 1, &thesaurus, numColumn,
`numOrgRow);
`numScore = readArray(f2, "[SCORING]", NULL, 0, &scoring, numColumn + 1, 0);
`
`fclose(fp);
`fclose(f2);
`
`} [
`
`FRAAHA A HR EH AR HH A HK HH FR HA AA HE HR HE HR HOE EE HE HK
`readArray : Readsthefile and fills the rows and columnsofthe given arrays
`ER Re A 2A A ee AeooR eo 2Eo osEE oO 2 eo oR 8 eS oe Ok oS oe Se oe oe 2
`int readArray(FILE *fp, char *head, char ***ch_array, int ccount, int ***int_array,int icount, int
`sp)
`
`{ c
`
`har buf[256];
`int i, j, start = 0, we = 0;
`int k,c;
`char **tmparray; /*To store the pointers to the words/numbers from the string*/
`c= sp;
`
`if (icount != 0)
`tmparray = (char **)malloc((icount + 1) * sizeof(char *));
`
`fseek(fp, 0, 0); /* Go to Top */
`
`while (fgets(buf, 255, fp) != NULL) /* readlinestill end of file */
`
`{ a
`
`llTrim(buf);
`j = strlen(buf);
`if (buffy - 1] == Nn’) buffy - 1] = 0;
`if (start)
`
`{ i
`
`f (strlen(buf) == 0) /* if blank line, stop reading */
`break;
`if (icount == 0) /* i.e. no integer array */
`
`728851 vi
`
`78
`
`481
`481
`
`
`
`L0299359 .211902
`
`PATENT
`Docket No.: 4428-4001
`
`else
`
`addWord(ch_array, buf, ++c);
`//* read first word string */
`{
`/* rest are columnsofint array */
`we = readValues(buf, tmparray);
`crt;
`(*int_array) = (int **)realloc(*int_array, c * sizeof(int *));
`(*int_array)[c - 1] = (int *)malloc(icount* sizeof(int));
`if (ccount != 0)
`addWord(ch_array, tmparray[0], c);
`
`else
`
`(*int_array)[c - 1][0] = atoi(tmparray[0]);
`for (k = 1; k < icount; k++)
`if (k < we)
`(*int_array)[c - 1][k - ccount] = atoi(tmparray[k]);
`
`else
`
`(*int_array)[c - 1][k - ccount] = 0;
`
`}
`
`}
`
`else
`if (!strcemp(head, buf))
`start = 1;
`
`}
`return c;
`
`} [
`
`ER A ee eeA EEEEAA eeOO I EE
`loadMenuTree : loads the menutree from file to menuList array
`2 2 eee oe 2 ee ee ie AE ee AEeeA2 ie Aeee ee oe oe ef eo ee oe ae EO
`int loadMenuTree (FILE *fp, char *head)
`
`{c
`
`har buf[256];
`int i, j, start = 0, count = 0;
`fseek(fp, 0, 0);
`while (fgets(buf, 255, fp)
`{
`j=strlen(buf);
`if (buffj - 1] = "\n')
`buffj - 1] =0;
`
`!= NULL)
`
`if (start)
`
`{i
`
`f (strlen(buf) == 0)
`break;
`menuList = (int **)realloc(menuList, (count + 1) * sizeof(int *));
`
`728851 v1
`
`79
`
`482
`482
`
`
`
`a,
`
`10299359 .441902
`
`PATENT
`Docket No.: 4428-4001
`
`menuList[count] = (int *)malloc(3 * sizeof(int));
`sscanf(buf, "%d,%d,%d\n", &menuList[count][0],
`&menuList[count][1],&menuList{count][2]);
`count++;
`}
`
`if (!stremp(head, buf))
`start = 1;
`
`else
`
`}
`return count ;
`}
`
`readini(char * filenm)
`{
`
`FILE * fp;
`char buf[80], key[80], value[80], comment[80];
`int cnt;
`if ((fp=fopen(filenm,"r"))==NULL)
`{
`
`perror(filenm);
`exit(1);
`
`} w
`
`hile (fgets(buf,79,fp)!=NULL)
`
`sscanf(buf,"%s %s “%s" key,value, comment);
`if (!stremp(key, "sdoc"))
`sdoc=strdup(value);
`if (!stremp(key, "fdoc"))
`fdoc=strdup(value);
`if ('stremp(key, "xdoc"))
`xdoc=strdup(value);
`if (!stremp(key, "cfg"))
`cfg=strdup(value);
`if (!stremp(key, "Icfg"))
`Icfg=strdup(value);
`if (!strcmp(key, "minprompt"))
`minPromptCount=atoi(value);
`if (!stremp(key, "timeout"))
`timeout=atoi(value);
`
`}
`
`728851 v1
`
`80
`
`483
`483
`
`
`
`.
`
`AOS VSsso .ALAVoe
`
`PATENT
`Docket No.: 4428-4001
`
`interactive.c: This program contains funtionsrelated to user interaction
`[FERRARA RRA AR ERR EA EE EAE EEE EH ERE EEE EE AEE SE EEE EH EE
`Interactive : function to accept a sentence from the user and then
`generate the response.
`
`thesaurusFlag = is | if there is atleast 1 thesaurus/learned word in query
`updateFlag = is set to | if the program needsto learn (i.e. main menu was
`selected during the promptnavigation)
`interPrompts = Intersection of prompts
`unionPrompts = Union ofprompts
`interUnionPrompts = Intersection of Union
`numInter = numberof prompts in InterPrompts
`numInterUnion = num of promptsin Intersection of Union
`numUnion = num of prompts in Union
`numUnknown = num of unknown words
`2H 2 2 ee i es 2 ae oe ae oe 2 2 2 ee eo 2 2 oe he ee fe Oe Ee ee ee ee ee AOe ee ie oR oREo oO
`
`#include <stdio.h>
`#include <signal.h>
`#include <string.h>
`#include <unistd.h>
`#include "globalvar.h"
`#include "arraylib.h"
`#include "forms.h"
`
`#define max(a,b) (a > b)? a: b
`#define min(a,b) (a <b)? a: b
`#define swap(a,b) (a “= b, b “=a, a“=b)
`
`extern int numScore, **scoring;
`int updateFlag = 0, learnFlag, numQueryList = 0;
`FILE *If, *pf
`char ** uWList=NULL, *queryTerms[50];
`int uWNum;
`extern int minPromptCount, timeout;
`char query[256], **queryList = NULL;
`char *affrmWords[] = { "yes", "night", "correct"};
`char *negWords[] = { "no", "neither"};
`extern char * fdoc;
`int otheFlag = 0;
`int unknownWords[20], numQuery = 0, numUnknown;
`char **uWords;
`// Added this arrayto facilitate learning wvenif lateral shift
`int numUW;// Addedthis to facilitate learning wvenif lateral shift
`void sayOther();
`
`728851 vi
`
`81
`
`484
`484
`
`
`
`,
`
`-
`
`LAO2VS9S59 .ALASoOe2
`
`PATENT
`Docket No.: 4428-4001
`
`void Interactive(char *flnm)
`
`int InterPrompts[20], unionPrompts[20], tl Prompts[20];
`int interUnionPrompts[20], numInterUnion, t2Prompts[20], numT2;
`int i, j, k, 1;
`int start, numUnion, numInter, numT1;
`int n, selectedPrompt, thesaurusFlag = 0;
`char *interlog, *processlog,c;
`
`numUnknown = numUW = 0;
`for(i=0; i < 20; i++)
`unknownWords[i] = 0;
`uWords=NULL;
`
`if ((interlog = (char *)getenv("TIMEOUT")) != NULL)
`timeout = atoi(interlog);
`
`if ((interlog = (char *)getenv("MINPROMPT")) != NULL)
`minPromptCount = atoi(interlog);
`
`if ((interlog = (char *)getenv("INTERLOG")) == NULL)
`interlog = "test.htm1";
`
`if ((processlog = (char *)getenv("PROCESSLOG")) == NULL)
`processlog = "process.html";
`
`signal(SIGALRM, &sayOther);
`If = fileOpen(interlog,"w");
`
`pf = fileOpen(processlog,"w");
`fprintf(If, "<HTML>\n<TITLE>%s</TITLE>\n<BODY><FONTSIZE=5>\n", interlog);
`fprintf(pf, "<HTML>\n<TITLE>%s</TITLE>\n<BODY><FONTSIZE=5>\n", processlog);
`
`system("clear");
`printf("Thank you for calling the New Herald.\n");
`printf("How maywe help you?\n\n");
`fprintf(1f,"\nThank you for calling the New Herald.<BR>");
`fprintf(lf,"How may we help you. <P>");
`fgets(query, 255, stdin);
`/* accept the user input */
`
`while (1)
`{
`
`728851 v1
`
`82
`
`485
`485
`
`
`
`10299359 .A414902
`
`PATENT
`Docket No.: 4428-4001
`
`addWord(&queryList, query, ++numQueryList);
`numQuery = thesaurusFlag = 0;
`if (strlen(query) == 0)
`break;
`fprintf(If, "<I> %s</I> <P>", query);
`
`numQuery = createArray(query, queryTerms);
`
`[FR REee eeEe Ee Re Ae ee ee ee eo Oe ee ee Re ee A EO OO OK
`fprintf(pf, "Terms in Query: ");
`for (j = 0; | < numQuery;j++)
`fprintf(pf, " %s", queryTermsf[j]);
`fprintf(pf, "<BR>");
`[EE a ee ee ee ee ee ee ee eo fe oe ee fe oe fe oe eo oe eo eo oe oe oe a oe a oe oe oe 2 2 a a/
`
`/* initialize InterPrompts and unionPrompts array */
`for (i = 0; i < 20; i++)
`
`{ t
`
`2Prompts[i] = t1Prompts[i] = 0;
`InterPrompts[i] = unionPrompts{i] = interUnionPrompts[i] = 0;
`
`start = 1;
`numInterUnion = numT2 = numT1 = numInter = numUnion = 0;
`
`/* Scan thru all the words to generate union/intersection of prompts*/
`for (i = 0; i < numQuery; i++)
`
`/* if not in index words check thesaurus */
`if (!inArray(columnTerms, queryTerms{i], numColumn))
`
`{ l
`
`eamFlag = numT1 = numT2 = 0;
`scanThesaurus(queryTerms[i], t] Prompts, t2Prompts, &numT1,
`
`&numT2);
`
`/* if unknown/learned wordsaveit to array */
`if (learnFlag)
`
`unknownWords[numUnknown] = 1, numUnknown++;
`addWord(&uWords, queryTerms[i], ++numUW);
`if (numT1 = 0 && numT2 = 0)
`continue;
`
`else
`
`}
`
`thesaurusFlag = 1;
`
`728851 vi
`
`83
`
`486
`486
`
`
`
`AOSVSS59 ,.ALASoOL
`
`PATENT
`Docket No.: 4428-4001
`
`else
`
`}
`
`else
`
`thesaurusFlag = 1;
`
`numT 1 = fetchPrompts(queryTerms[i], tl Prompts);
`numT2= fetchPrompts(queryTerms[i], t2Prompts);
`[EE EE EE EE KE EE HE EEK EEE EE AK EEE EEK EE/
`fprintf(pf, "%s (index) :", queryTerms[1]);
`for (j = 0; } <numT1; j++)
`fprintf(pf, " %d", tl Prompts[j]);
`fprintf(pf, "<BR>");
`fflush(pf);
`[EA ee ee ee ee ee ee ee ee A ee ee ek Ae ee ee ee eo aa
`}
`
`if (start) /* if first word */
`
`{ n
`
`umInter = PromptUnion(InterPrompts, t2Prompts, numInter, numT2);
`numUnion = PromptUnion(unionPrompts, tl Prompts, numUnion,
`
`numT1);
`
`numInterUnion = PromptUnion(interUnionPrompts, tl Prompts,
`numInterUnion, numT 1);
`start = 0;
`}
`
`{ n
`
`else
`
`umInter = PromptIntersection(InterPrompts, t2Prompts, numInter,
`
`numT2);
`
`numT 1);
`
`numUnion = PromptUnion(unionPrompts, tl Prompts, numUnion,
`
`numInterUnion = PromptIntersection(interUnionPrompts, tl Prompts,
`numInterUnion, numT1);
`
`}
`
`[ATR FE HEAAA ee
`fprintf(pf, "Final Intersection Result: ");
`for (j = 0; j < numInter; j++)
`fprintf(pf," %d", InterPrompts[j]);
`fprintf(pf, "<BR>");
`fprintf(pf, "Final Intersection of Union Result: ");
`for (j = 0; } < numInterUnion; j++)
`
` /
`
`728851 v1
`
`84
`
`487
`487
`
`
`
`;
`
`:
`
`LO2S99S59 ,ALAVvOeS
`
`PATENT
`Docket No.: 4428-4001
`
`fprintf(pf, " %d", interUnionPrompts{j]);
`fprintf(pf, "<BR>");
`fprintf(pf, "Final Union Result: ");
`for (j = 0;j < numUnion; j++)
`fprintf(pf, " %d", unionPromptsf{j]);
`fprintf(pf, "<BR>");
`fflush(pf);
`[Ee fe ee ee ee ee ee oe oe a ee ae oi fe oe eR ee 2 i 2 2 ae/
`
`if (numInter < minPromptCount && thesaurusFlag)
`
`if (numInterUnion < minPromptCount)
`numInter = PromptUnion(InterPrompts, unionPrompts, numInter,
`
`numUnion);
`
`else
`
`numinter, numInterUnion);
`}
`
`numInter = PromptUnion(InterPrompts, interUnionPrompts,
`
`fprintf(pf, "Final Selection : ");
`fflush(pf);
`for (j = 0; j} < numInter; j++)
`fprintf(pf, " %d", InterPrompts[j]);
`fprintf(pf, "<BR>");
`fflush(pf);
`numiInter = orderPrompts(InterPrompts, numInter);
`numInter = removeChild(InterPrompts, numInter);
`// eliminate prompts > 3
`for (j = 3; } < numInter; j++)
`InterPrompts{j] = 0;
`numInter = min(numInter, 3);
`fprintf(pf, "Selection After Elimination of descendants: ");
`fflush(pf);
`for (j = 0; j < numInter; j++)
`fprintf(pf, " %d", InterPrompts{j]);
`fprintf(pf, "<BR>");
`fflush(pf);
`selectedPrompt = GetPrompt(InterPrompts, numInter);
`if (selectedPrompt == 100)
`continue;
`
`// if (updateFlag)
`learnThesaurus(selectedPrompt, unknownWords, numUnknown,flnm);
`
`728851 vi
`
`85
`
`488
`488
`
`
`
`LOS2SISsso .2z1i190e2
`
`PATENT
`Docket No.: 4428-4001
`
`updateFlag = 0;
`for(j = 0; (j <numMenu) && (menuList[j][1] != selectedPrompt); j++);
`if (menuList[j][2] >= 99)
`
`{ f
`
`or (i = 0; i < numPF;i++)
`
`{ i
`
`f (!stremp(Fprompts[i][1],prompts[selectedPrompt - 1]))
`
`{ f
`
`or(k = 0; k < numForms; k++)
`if (!stremp(Fprompts[i][0],formlist[k]->name))
`
`{ f
`
`illForm(formlist[k], queryList, numQueryList);
`processForm(formlist[k]);
`break;
`
`break;
`}
`
`}
`if (i = numPF)
`
`{ s
`
`ystem("clear");
`printf("\nYour query has been understood.\n");
`printf('"Please wait to be transferred to the relevant department.\n\n");
`fprintf(1f,"<P>Your query has been understood.<LI>");
`fprintf(1f,"Please wait to be transferred to the relevant department.<HR>");
`break;
`}
`
`{ p
`
`rintf("\n%s\n\n"prompts[menuList[j][2] - 1]);
`fprintf(if, "\n<P>%s<HR>",prompts[menuList[j][2] - 1]);
`
`else
`
`}/
`
`/ modified for the loop
`printf("Do you have another query?\n\n");
`fgets(query,80,stdin);
`if (IchkNegtn(query))
`
`{ f
`
`or(i = 0; i < numQueryList; i++)
`free(queryList[i]);
`for(i = 0; i< numForms;i++)
`free(formlist[i]);
`free(formlist);
`
`728851 v1
`
`86
`
`489
`489
`
`
`
`:
`
`102990359 .ALA190e
`
`PATENT
`Docket No.: 4428-4001
`
`free(queryList);
`queryList = NULL;
`numForms = loadForms(fdoc);
`numQueryList = 0;
`//printf("Please tell us your query.\n\n");
`//fgets(query,255,stdin);
`continue;
`}
`system("clear");
`printf("\nThank you for calling.\nGoodbye.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
`break;
`
`} f
`
`printf(lf, "</HTML>\n</BODY>\n");
`fprintf(pf, "</HTML>\n</BODY>\n");
`fclose(If);
`fclose(pf);
`
`} i
`
`nt scanThesaurus(char *word,int *tl Prompts, int *t2Prompts,int* n1, int * n2)
`
`{ i
`
`nt i,j, k= 0, 1;
`int m,tp[20], sflg = 1;
`
`for (i = 0; i < 20; i++)
`t1Prompts[i] = t2Prompts[i] = tp[i] = 0;
`
`for (1 = 0; 1 < numRow;|++)
`if (!stremp(word, rowTerms[]1]))
`break;
`/* if the word is not present in thesaurus */
`if (1 == numRow)
`
`{ f
`
`printf(pf, "%s (unknown) <BR>", word);
`learnFlag = 1;
`;
`return 0;
`}
`
`{i
`
`f (1 >= numOrgRow)
`
`else
`
`{ f
`
`printf(pf, "Yes (learned):<BR>", word);
`
`728851 v1
`
`87
`
`490
`490
`
`
`
`Loe939359 .4411902
`
`PATENT
`Docket No.: 4428-4001
`
`learnFlag = 1;
`
`} f
`
`else
`
`printf(pf, "%s (thesaurus):<BR>", word);
`
`for (j = 0; thesaurus[I][j] && j < numRow;j++)
`
`{m
`
`= fetchPrompts(columnTerms[thesaurus[I][j] - 1], tp);
`AR AR A A ee Aee ee eeee eeee eeeeEE
`fprintf(pf, "<LI>%s (index) :", columnTerms|[thesaurus[I][j] - 1]);
`for (k = 0; k <m; k++)
`fprintf(pf, " %d", tp[k]);
`fprintf(pf, "<BR>");
`[FR I HR HR RHHRAA AAEEEH /
`
`*nl = PromptUnion(t1 Prompts,tp, *nl, m);
`if (sflg)
`
`*n2 = PromptUnion(t2Prompts, tp, *n2, m);
`sflg = 0;
`}
`
`{ *
`
`}
`
`else
`
`n2 = PromptIntersection(t2Prompts, tp, *n2, m);
`
`}
`fprintf(pf, "Union Result: ");
`for (k = 0; k < *nl; k++)
`fprintf(pf, " %d", tl Prompts[k]);
`fprintf(pf, "<BR>");
`fprintf(pf, "Intersection Result: ");
`for (k = 0; k < *n2; k++)
`fprintf(pf, " %d", t2Prompts[k]);
`fprintf(pf, "<BR>");
`}
`
`retum k;
`
`ERB REOECCC CK
`PromptUnion: does a union ofarrays pointed by p1 and p2 and
`stores in pl. returns the total elementsin result
`ee ee ee ee eeA AEee ee ieeeoR oe oe oO
`
`728851 vi
`
`88
`
`491
`491
`
`
`
`‘
`
`10299359 .411902
`
`PATENT
`Docket No.: 4428-4001
`
`int PromptUnion(int *p1, int *p2, int nl, int n2)
`
`{ i
`
`nti, j;
`for (i = 0; i < n2; i++)
`
`for § = 0; j <nl; j++)
`if (p1Uj] = p2[i))
`break;
`if (j —nl)
`
`{ p
`
`1G) = p2[i);
`nl++;
`}
`
`}
`retum nl;
`
`} [
`
`RR A ee ee he eo ee 2 ee Ae ee he eo ee ee Ae eeeo oe ee ee ee ee eeek
`PromptIntersection : does a intersection of arrays pointed by pl and p2 and
`stores in pl. returns the total elements in result
`fe He ke ee eo ee Fe ee ee ee fe ee ee ee ee ee ee eo ee oe ee fe 2 fe oe oe oe ee ee oe fe oe eo eo eo eo ok ok A /
`int PromptIntersection(int *p1, int *p2, int n1, int n2)
`
`{ i
`
`nti, j;
`for (i = 0; i< nl; i++)
`
`{ f
`
`or § = 0; j < n2; j++)
`if (p1{i] = p2{i})
`break;
`if (j = n2) /* not there */
`
`{ f
`
`or (j =i; j <nl; j++)
`plij]=plU + 1);
`
`nl--;
`i--;
`}
`
`}
`return nl;
`
`[EE A A eA ee ee A he oe oe ie ee oe ee ok oe eo oe ok eo ok ok oe ok ee eo ae ko ok oe a a oo ak ok ok oe oe
`fetchPrompts : Will fetch all the prompts for 'word'into
`Arraylist pointed by tl Prompts;
`2 He ee oe ee te ee eee fe ee ee ee ee 2 ee 2 ee oe Re ee fe he ke eeA a eo A Ee a a/
`
`728851 v1
`
`89
`
`492
`492
`
`
`
`LOe99S59 .1411902
`
`PATENT
`Docket No.: 4428-4001
`
`int fetchPrompts(char *word, int *tl Prompts)
`
`inti, j, k, 1;
`for (i = 0; i < 20; i++)
`t1Prompts{i] = 0;
`if ((i = inArray(columnTerms, word, numColumn)) == 0)
`return 0;
`
`1--;
`for (j = 0; (t1Prompts[j] = indexList[i][j]) && (j < numIndex); j++);
`return j;
`
`} [
`
`RR AA A A ee ee AAee ee oe ee fe 2ee
`GetPrompt: Returns the final prompt selected by user
`2 ee ee ee ee ee ee ee AE AE he ee ee eA AE he AAE OR OREe oOoO
`int GetPrompt(int *Parray, int pent)
`
`{ i
`
`nt i, j, k, 1;
`int mmflag = 0, af = 0;
`char ans[80];
`
`while (1)
`
`{ s
`
`ystem("clear");
`printf("\n");
`fprintf(lf, "<P>");
`// Removed the commentsto reintroduce last prompt
`if (pent = 1 && isLeaf(Parray[0}) && numUnknown > 0)
`af =1;
`|] w-nnwnn nnn nnn nnn nn nnn nnn nnn nnn nn nnn
`if ((pent > 1) || (pent = 1 && af = 1))
`
`// sortPrompts(Parray, pent);
`orderPrompts(Parray, pent);
`for (i = 0; i < pent; i++)
`
`printf("%s\n\n", prompts[Parray[i] - 1]);
`fprintf(If, "<LI>%s", prompts[Parray[i] - 1]);
`}
`if (!mmflag)
`
`{ o
`
`theFlag = 0;
`alarm(timeout);
`
`728851 vi
`
`90
`
`493
`493
`
`
`
`AD299359 .34141902
`
`PATENT
`Docket No.: 4428-4001
`
`/* accept the user input */
`
`fgets(ans, 80, stdin);
`alarm(0);
`fprintf(lf, "<P><I>%s</I><P>", ans);
`fflush(1f);
`if (otheFlag = 1 && chkAfrm(ans))
`1= 0;
`
`else
`
`if (chkNegtn(ans) && otheFlag != 1)
`j=0;
`
`else
`
`addWord(&queryList, ans, ++numQueryList);
`j = chkAns(ans, Parray, pent);
`
`otheFlag = 0;
`
`} i
`
`f (j == -99)
`{
`
`updateFlag = 1;
`return 100;
`
`} i
`
`f j <0)
`{
`
`pent = removeZeros(Parray,pcnt);
`continue;
`
`mmflag = 0;
`}
`
`else
`
`j = pent;
`if G == 0)
`{
`pent = getNodes(j, Parray);
`mmflag = updateFlag = 1;
`}
`
`else
`
`{ i
`
`f (isLeaf(Parray[j - 1]))
`{
`
`return Parray[j - 1];
`
`728851 v1
`
`91
`
`494
`494
`
`
`
`10299359 ,.ALAVoOeS
`
`PATENT
`Docket No.: 4428-4001
`
`else
`
`}
`
`af=1;
`
`pent = getNodes(Parray[j - 1], Parray);
`
`} [
`
`A IA FEA AE AEee Ae A ee ee eeee eea ee 2 ae ae eo ae
`isLeaf: Returns | if 'node' is a leaf in the menutree, else 0
`HERA AEE ERE AKER ER EEK EA EEE EK EERE KA RERAEREEEN EEE EAE AEE SE EAH EKER EE KEK/
`int isLeaf(int node)
`
`int i;
`for (i = 0; i < numMenu; i++)
`if (menuList[i][1] == node)
`break;
`if (i = numMenu)
`return 0;
`return menuList[i][2];
`
`} i
`
`nt getNodes(int pnode, int *parray)
`
`inti, j;
`for (i = 0, | = 0; i<numMenu;i++)
`if (menuList[i][0] == pnode)
`
`parray[j] = menuList[i][1];
`JH;
`}
`
`parray[j] = 0;
`return J;
`}
`
`[RAR a a a A eeee A A A A A A A A A Aee i ee oe ee ee ee he ee ee a oe oo a aa
`learnThesaurus: re-writes the thesaurus with relearned pattern and newly
`learned word.
`eo A ee eeee ee ee He eAEe ee eeee A Ae 2 ee 2 eo ke kee eeoe
`learnThesaurus(int pmpt, int unknownWords[], int numUnknown,char *flnm)
`
`92
`
`495
`495
`
`{ i
`
`nt i, j, k, 1;
`FILE *fp;
`int *tmpList, tmpCount;
`
`728851 vi
`
`
`
`LO299359 .11190e2
`
`PATENT
`Docket No.: 4428-4001
`
`/* create andinitialize a tmp Array */
`tmpList = (int *)calloc(numColumn,sizeof(int));
`for (i = tmpCount= 0; i < numColumn;i++)
`tmpList[i] =0;
`—
`
`/* scan thru the query words and gathera list of unique keywordsin tmp array*/
`tmpCount = getKeyWords(queryTerms, numQuery, tmpList);
`/* Locate the row for select prompt.if not create new row */
`for (k = 0; k <numScore && scoring[k][0] != pmpt; k++);
`if (k >= numScore)
`{
`
`scoring = (int **)realloc(scoring, (k + 1) * sizeof(int *));
`scoring[k] = (int *) malloc((numColumn+ 1) * sizeof(int));
`for (j = 0; } <= numColumn;j++)
`scoring[k][j] = 0;
`numScoret+;
`
`} s
`
`coring[k][0] = pmpt;
`for (j = 0; j < tmpCount; j++)
`scoring[k][tmpList[j]]++;
`
`[AeeRe ee eeee ee ee oe ee ee eeoo ao a a A a /
`for (i = tmpCount = 0; i < numColumn;i++)
`tmpList[i] = 0;
`
`for (j = i = 0; j <numColumn;j++)
`
`{ f
`
`or (k = 0; k < numIndex && index List[j][k] != 0; k++)
`if (index List{j][k] == pmpt)
`break;
`if (k <numIndex && indexList[j][k] != 0)
`
`{t
`
`mpList[i] =j + 1;
`i++;
`}
`
`tmpCount= i;
`fp = fileOpen(flnm, "w");
`fprintf(pf, "<BR><B>Learned words</B><BR>");
`fprintf(fp, "[Y%s]\n", "EXT-THESAURUS");
`
`728851 v1
`
`93
`
`496
`496
`
`
`
`‘
`
`LOeSSSs59 .1411902e
`
`PATENT
`Docket No.: 4428-4001
`
`for (i = numOrgRow;i < numRow;i++)
`
`es "%s: "| rowTerms[i]);
`ifee && inArray(uWords, rowTerms[i], numUW))
`
`fprintf(pf, "%s (relearned)<BR>original: ", queryTerms[unknownWords[j]]);
`for (k = 0; k < numColumn; k++)
`
`{ i
`
`f (thesaurus[i][k] != 0)
`fprintf(pf, " %d", thesaurus[i][k]);
`if (thesaurus[i][k] == 0)
`break;
`
`} f
`
`printf(pf, "<BR>");
`k = PromptUnion(thesaurus[i], tmpList, k, tmpCount);
`fprintf(pf, "new :");
`for (j = 0; j < k; j++)
`fprintf(pf, " %d", thesaurus[i][}]);
`fprintf(pf, "<BR><BR>");
`
`}
`
`for (j = 0; } <numColumn; j++)
`
`if (thesaurus[i][j] == 0)
`break;
`fprintf(fp, "%d,", thesaurus[i][}j]);
`
`}
`fprintf(fp, "\n");
`}
`for (i = 0; updateFlag && 1 < numUW;i++)
`
`if (inArray(rowTenns, uWords[i], numRow))
`continue;
`
`fprintf(fp, "%s: ", uWords[i]);
`fprintf(pf, "%s(new-learned) :", uWords[i]);
`addWord(&rowTerms, uWords[i], ++numRow);
`thesaurus = (int **)realloc(thesaurus, numRow*sizeof(int *));
`thesaurus[numRow- 1] = (int *)malloc(numColumn*sizeof(int));
`for (j = 0; j <numColumn;j++) thesaurus[numRow-1][j] = 0;
`for (j = 0; } < tmpCount; j++)
`
`728851 vi
`
`94
`
`497
`497
`
`
`
`;
`
`¢
`
`10299359 .1411902
`
`PATENT
`Docket No.: 4428-4001
`
`thesaurus[numRow- 1)[j] = tmpList[j];
`fprintf(fp, "%d,", tmpList[j});
`fprintf(pf, " %d", tmpList[j]);
`}
`fprintf(fp, "\n");
`fprintf(pf, "<BR><BR>");
`}
`
`fprintf(fp, "\n");
`
`/* write the scoringin the file */
`fprintf(fp, "[%s]\n", "SCORING");
`for (i = 0; i < numScore; i++)
`
`{f
`
`printf(fp, "%d,", scoring[i][0]);
`for(j = 1; } <= numColumn;j++)
`fprintf(fp, "%d,", scoring[i][j]);
`fprintf(fp, "\n");
`}
`fprintf(fp, "\n");
`fclose(fp);
`
`} [
`
`EERE A eeeeee AAee
`removeChild: removes descendents of all the elements from thelist
`A a ee ee Ee 9 eeHeA A AAA A eA Aeeee Aef
`int removeChild(int *array, int tot)
`
`int i, j, k, ent = 0;
`int *tmparray, rm = 99;
`
`tmparray = (int *)calloc(numIndex, sizeof(int));
`
`/* Remove any promptsthat are responsesrather than choices */
`for (1 = 0; 1 < tot; i++)
`
`{ f
`
`}
`
`or(j = 0; | < numMenu;j++)
`if (menuList[j][1] == array[i] && menuList[j][2] == 100)
`array[i] = 0;
`
`/* Remove any promptsthat are root node and havea child whichis not a leaf rather than
`choices */
`
`728851 vl
`
`95
`
`498
`498
`
`
`
`10299359 .111902
`
`PATENT
`Docket No.: 4428-4001
`
`for (i = 0; 1 < tot; i++)
`
`if (array[i] == 0) /* already removed so go to next */
`continue;
`
`/* if (isLeaf(array[i]))
`continue; */
`
`m = array[i];
`while(1)
`
`{ f
`
`or(j = 0; } < numMenu; j++)
`if (menuList[j][1] == m)
`break;
`if (menuList[j][0] == 0)
`break;
`rm = menuList[j][0];
`
`if (1m != array[i])
`
`for (j = 0; j < tot; j++)
`
`if (array[j] =m)
`array[j] = 0;
`
`}
`
`}
`
`}
`
`for (i = 0; i < tot; i++)
`
`if (array[i] == 0) /* already removed so go to next */
`continue;
`for (j = 0; } < numIndex; j++) /* initialize tmparray */
`tmparray[j] = 0;
`cnt = getChildren(array[i], tmparray); /* get children & grand-children ofi */
`for (j = 0; j < tot; j++)
`/* scan thru thearray to check for child */
`if (j !=i) /* ignore self from checking */
`for (k = 0; k < cnt; k++)
`if (array[j] == tmparray[k])
`
`{ a
`
`rray[j] = 0; /* ifj is child of i, makeit 0 */
`break;
`
`728851 vl
`
`96
`
`499
`499
`
`
`
`,
`
`:
`
`LOESVOESS9 .ALI1902
`
`PATENT
`Docket No.: 4428-4001
`
`}
`
`/* Shift All non-zeroes upwards */
`for (i = 0; i < tot; i++)
`
`{ i
`
`f (array[i] == 0)
`
`{ f
`
`or (j =i + 1; j < tot; j++)
`if (array[j] != 0)
`break;
`
`if (j < tot)
`
`{ a
`
`rray[i] = array[}];
`array[j] = 0;
`}
`
`}
`
`}
`/* count no of elements */
`for (j = 0; j < tot; j++)
`
`if (array[j] == 0)
`break;
`
`}
`retum J;
`
`} [
`
`FER AA AEFE AAE FE EER A SEEE FE AAAA A AA
`getChildren: fetches all the descendents of pmptinto array
`26 ee Re hee fe ee fe oe ee ie he ee oe 2 Re fe ae fe ee 2 ee eee ae ee eee he ee ee ee fe ee ee eee ee fe ee oe
`int getChildren(int pmpt, int *array)
`
`/
`
`inti, j, k, ];
`int t, tl, t2;
`int *tmparrayl, *tmparray2;
`
`if (isLeaf(pmpt)) /* if node is leaf no children so return 0 */
`return 0;
`
`tmparray] = (int *)calloc(numIndex, sizeof(int)); /* child of child in every loop */
`tmparray2 = (int *)calloc(numIndex, sizeof(int)); /* union of all scanned children */
`t=tl =t2=0;
`for (i = 0; i< numMenu;i++)
`
`728851 vi
`
`97
`
`500
`500
`
`
`
`10299359 .1411902c
`
`PATENT
`Docket No.: 4428-4001
`
`if (menuList[i][0] == pmpt && menuList[i][2] != 100)
`
`array[t] = menuList[i][1];
`tl = getChildren(array[t], tmparray1);
`t2 = PromptUnion(tmparray2, tmparray1, 2,t1);
`te;
`}
`
`t = PromptUnion(array, tmparray?2, t, t2);
`return t;
`}
`
`int chkAns(char* ans,int * Parray,int pcnt)
`
`{ c
`
`har locquery[256];
`int i, j, tmplcnt = 0, tmp2cnt = 0;
`char *resWords[50], start = "Y';
`int numWords, tmpArrayl [20], tmpArray2[20];
`int uwFlag = 0, rowOrColWord = 0;
`
`strepy(locquery,ans);
`numWords = breakStr(ans, resWords);
`if ( stremp(resWords[0],"other") == 0 && strcmp(resWords[1],"options") = 0)
`
`return 0;
`
`numWords = processArray(resWords, numWords,1);
`for (i = 0; 1 < 20; i++)
`tmpArray1[i] = tmpArray2[i] = 0;
`fprintf(pf,"<li>Initialized Temp Array\n"); fflush(pf);
`
`for (i = 0; i <numWords; i++)
`
`if (tinArray(columnTerms, resWords[i], numColumn))
`
`if (!inArray(rowTerms,resWords[i],numColumn))
`
`{ i
`
`f (tinArray(uWList, resWords[i], uWNum))
`
`{a
`
`ddWord(&uWList, resWords[i], ++uWNum);
`fflush(1f);
`}
`
`728851 v1
`
`98
`
`501
`501
`
`
`
`LO2ISS59 .1ALAsoe
`
`PATENT
`Docket No.: 4428-4001
`
`else
`
`-
`{
`fprintf(pf,"<li>Unknown Word: %s\n",resWords[i]);
`fflush(pf);
`uwFlag = 1; /* unKnown word encountered twice */
`}
`
`}
`
`else
`
`rowOrColWord++;
`continue;
`}
`
`else
`
`rowOrColWord++;
`tmp|cnt = fetchPrompts(resWords[i], tmpArray]1);
`if (start == '"Y')
`
`{t
`
`mp2cnt = PromptUnion(tmpArray2, tmpArray1, tmp2cnt, tmp! cnt);
`start='"N';
`}
`
`else
`
`tmp2cnt = PromptIntersection(tmpArray2, tmpArrayl, tmp2cnt, tmpIcnt);
`
`tmp2cnt = PromptIntersection(tmpArray2, Parray, tmp2cnt, pent);
`}
`if (tmp2cnt != 1)
`
`if (tmp2cnt = 0 && pent == 1 && numWords = 1) //i.e. only one prompt &
`
`not selected
`
`{
`
`strepy(ans, locquery);
`if (chkAfrm(ans))
`return 1;
`
`if (tmp2cnt > 1) //i.e. multiple prompt selection then do score
`{
`
`strepy(ans, locquery);
`return checkscore(ans,Parray, pent);
`
`if (uwFlag)
`if (AskforOp())
`return -99;
`
`728851 v1
`
`99
`
`502
`502
`
`
`
`:
`
`A0299359 .411902
`
`PATENT
`Docket No.: 4428-4001
`
`else
`
`return -1;
`
`if (t(owOrColWord)
`
`else
`
`{ s
`
`trcpy(query,locquery);
`return -99;
`}
`
`}
`for (i = 0; Parray[i]; i++)
`if (Parray[i] == tmpArray2[0])
`returni+ 1;
`
`} i
`
`nt AskforOp()
`
`{ i
`
`nt i,j;
`char *resWords[50];
`int numWords;
`
`system("clear");
`printf(""Your request was not understood.\n");
`printf("Would you prefer to speak to an operatoror try again with a new request?\n");
`fprintf(If, "<P>Your request was not understood.<LI>");
`fprintf(If, "Would you prefer to speak to an operatoror try again with a new request?\n");
`fflush(1f);
`/* accept the user input */
`fgets(query, 255, stdin);
`addWord(&queryList, query, ++numQueryList);
`fprintf(lf, "<P><I> %s</I>", query);
`numWords = breakStr(query, resWords);
`if ( inArray(resWords,"operator",numWords))
`
`{p
`
`rintf("\n\nPlease wait for the operator...\n");
`fprintf(if,"<P>Please wait for the operator...");
`fflush(1f);
`exit(0);
`}
`if( inArray(resWords,"try",numWords) && inArray(resWords,"again",numWords))
`
`system("clear");
`printf(""Please tell us your new request\n");
`fprintf(If, "<P>Please tell us your new request\n");
`fflush(If);
`
`728851 vi
`
`100
`
`503
`503
`
`
`
`.
`
`L0299359 .1441902
`
`PATENT
`Docket No.: 4428-4001
`
`/* accept the user input */
`fgets(query, 255, stdin);
`addWord(&queryList, query, ++numQueryList);
`}
`return 1;
`
`} v
`
`oid sayOther()
`
`{p
`
`rintf("\nWould youlike to hear other options?\n\n");
`fprintf(lf, "<LI>Would you like to hear other options?<P>");
`otheFlag = 1;
`
`} i
`
`nt checkscore(char *ans, int *Parray, int pent)
`{
`
`char * resWords[50], *pmptWords[50];
`int i, j, *score, *scorel;
`int numWords, numpWords, maxscore;
`
`score = (int *)malloc(pent * sizeof(int));
`scorel = (int *)malloc(pent* sizeof(int));
`for (i = 0; i < pent; i++)
`score[i] = score] [i] = 0;
`
`numWords = breakStr(ans, resWords);
`for (i = 0; 1 < pent; i++)
`{
`
`numpWords = breakStr(prompts[Parray[i]-1], pmptWords);
`for (j = 0; } < numWords; j++)
`if (inArray(pmptWords,resWords[j], numpWords))
`score[i]++;
`
`} f
`
`or (i = maxscore = 0; i < pent; i++)
`maxscore = (maxscore< score[i])?score[i]:maxscore;
`for (i =j = 0; 1 < pent; i++)
`
`j += (score[i] == maxscore)? 1:0;
`
`if (j = 1) /* single promptselection */
`
`for (i = 0; i < pent; i++)
`if (score[i] == maxscore)
`returni+ 1;
`
`728851 v1
`
`101
`
`504
`504
`
`
`
`:
`
`LOe2ESSS59 .ALAIoe
`
`PATENT
`Docket No.: 4428-4001
`
`else
`
`for (i = 0; i < pent; i++)
`
`numpWords = breakStr(prompts[Parray[i] - 1], pmptWords);
`scorel[i] = getscorel(resWords, numWords, pmptWords, numpWords);
`
`} m
`
`axscore = 0;
`for (i = 0; 1 < pent; i++)
`maxscore = (score [i] > maxscore)?score1[i]:maxscore;
`for (i = j = 0; i < pent; i++)
`j += (scorel[i] == maxscore)?1:0;
`if (j == 1) /* single promptselection */
`
`for (i = 0; i < pent; i++)
`if (scorel [i] == maxscore)
`return i + 1;
`
`for (i = 0; i < pent; i++)
`if (score[i] != maxscore)
`Parray[i] = 0;
`return -1;
`
`} e
`
`lse
`
`}
`
`}
`
`int chkAfrm(char* str)
`{
`
`int i,j, numWords;
`char * res Words[50];
`
`numWords= breakStr(str, resWords);
`for (i = 0; i < numWords;i ++)
`if (inArray(affrmWords, resWords[i], 3))
`return 1;
`
`return 0;
`
`}
`
`int chkNegtn( char * str)
`{
`
`728851 vi
`
`102
`
`505
`505
`
`
`
`10299359 ,.11190e2
`
`PATENT
`Docket No.: 4428-4001
`
`int i,j, numWords;
`char * resWords[50];
`
`numWords = breakStr(str, resWords);
`for (i = 0; 1 < numWords; i ++)
`if (inArray(negWords, resWords[i], 2))
`return 1;
`
`return 0;
`
`}
`
`int getscorel (char **Word1, int num1, char **Word2, int num2)
`{
`
`int i, j, scr = 0;
`int Ismatch = 0;
`
`for(i = 0; i < num]; i++)
`{
`
`for(j = Ismatch; j} < num2; j++)
`if (!stremp(Word1 [i],Word2[j]))
`{
`
`scr++;
`break;
`
`}
`if j <num2)
`Ismatch = j + 1;
`
`} r
`
`eturn Scr;
`
`}
`
`int orderPrompts(int *InterPrompts,int numInter)
`
`inti, j, k, |;
`int *tmpArray[2]; /* 0- score ; 1 - level; 3 - menu order */
`int *tmpList, tmpCount;
`
`tmpArray[0] = (int *)malloc(numInter * sizeof(int));
`tmpArray[1] = (int *)malloc(numInter * sizeof(int));
`
`tmpList = (int *)malloc(numColumn * sizeof(int));
`for (i = 0;
`i <numColumn;i++)
`tmpList[i] = 0;
`// get the list of keywords from queryTerms
`
`728851 vi
`
`103
`
`506
`506
`
`
`
`i
`
`:
`
`LOSSOSso ,.A41190e2
`
`PATENT
`Docket No.: 4428-4001
`
`tmpCount = getKeyWords(queryTerms, numQuery, tmpList);
`
`for (i = 0; i < numInter; i++)
`{
`
`/* get the maxscore for the prompt */
`tmpArray[0][i] = 0;
`for (j = 0; (| < numScore) && (scoring[j][0] != InterPrompts[i]); j++);
`/* if any previous scoring present*/
`if (j <numScore) && (scoring[j][0] == InterPrompts[i]))
`
`// get the max score
`for (k = 0; k < tmpCount; k++)
`tmpArray[0)[i] = max(tmpArray[0][i] , scoring[j][tmpList[k]]);
`
`} t
`
`mpArray[1][i] = getLevel(InterPrompts[i]);
`
`} /
`
`/ sort the array in order of score, level and menu-order
`for (i = 0; i1<(numInter- 1); i++)
`{
`
`for (j =i + 1;j <numInter; j++)
`if (!gThan(tmpArray[0)[i], tmpArray[1)[i], InterPrompts[i],
`tmpArray[0][j], tmpArray[1][j], InterPrompts[j]))
`{
`
`swap(tmpArray([0)[i], tmpArray[0][j]);
`swap(tmpArray[1]f[i], tmpArray[1][j});
`swap(InterPrompts[i], InterPrompts[j]);
`
`} r
`
`eturn numInter;
`
`} i
`
`nt getKeyWords(char **queryTerms, int numQuery, int *tmpList)
`
`inti, j, k, 1;
`int count = 0;
`
`for (j = 0; } < numQuery; j++)
`
`/* Check if the word is keyword */
`if ((k = inArray(columnTerms, queryTerms{[j], numColumn)) != 0)
`{
`
`728851 v1
`
`104
`
`507
`507
`
`
`
`10299359 .A411902
`
`PATENT
`Docket No.: 4428-4001
`
`/* add in templist only if not present */
`for (i = 0; 1< count && tmpList[i] !=k ; i++);
`if (1 >= count)
`tmpList[count++] = k;
`continue;
`
`} /
`
`* check if the word is Thesaurus/Learned Word */
`if ((k = inArray(rowTerms,queryTerms[j], numRow)) != 0)
`
`/* pick-up all keywords for that word */
`for (i = 0; thesaurus[k - 1][i] != 0; i++)
`
`for (l= 0; 1< count && tmpList[l] != thesaurus[k - 1][i] ; ++);
`if (1 >= count)
`tmpList[count++] = thesaurus[k - 1][1];
`
`}
`
`}
`
`} r
`
`etum count;
`
`} i
`
`nt getLevel(int pmpt)
`
`inti, k, |;
`
`for (i= 0; i<numMenu && menuList{i}[1] != pmpt; i++);
`k = menuList[i][0];
`for (1 = 0; k > 0;1++)
`{
`
`for (i = 0; 1 <numMenu && menuList[i][1] !=k; i++);
`k = menuList[i][0];
`
`105
`
`508
`508
`
`} r
`
`eturn |;
`
`} i
`
`nt gThan(inta, int b, int c, int p, int q, int r)
`(
`
`if (a> p) return 1;
`if (a <p) return 0;
`if (b > q) return 0;
`
`// Desc order here
`// Desc order here
`// Asc order here
`
`728851 vi
`
`
`
`LOSSSssys .t1AsSoe
`
`PATENT
`Docket No.: 4428-4001
`
`if (6 <q) return 1; // Asc order here
`if(c >r) return 0;
`// Asc order here
`return 1; // Asc order here
`
`formlib.c: This program contains functions for forms processing
`#include <stdio.h>
`#include <string.h>
`#include “arraylib.h"
`
`struct input {
`char *Type;
`char *APrompt;
`char *RPrompt;
`char *Name;
`char *Value;
`char **Choice;
`int numChoice;
`}s
`
`struct form {
`char * name;
`struct input **fields;
`int numFields;
`};
`
`char * split(char * , char );
`
`int loadForm(FILE*f, struct form *frm, char *name)
`
`int j, start=0;
`char buf[512];
`char fname[20];
`
`sprintf(fname,"[%s]",name);
`fseek(f,SEEK_SET,0);
`while(fgets(buf,512,f) != NULL) {
`j = strlen(buf);
`if (buffj - 1] = ‘\n’) buffy - 1] = 0;
`if (start)
`{
`
`728851 vi
`
`106
`
`509
`509
`
`
`
`10299359 .111902
`
`PATENT
`Docket No.: 4428-4001
`
`if (strlen(buf) == 0) /* if blankline, stop reading */
`break;
`frm->numFields++;
`frm->fields = (struct input **)realloc(frm->fields, (frm->numFie