How to separate english words such as : I've = I have, etc.

  • Thread starter Thread starter Languageware
  • Start date Start date
L

Languageware

Guest
// I'm trying to move this code from *.c file compiling on Borland to VS.
//I get many errors.
// Could you, please, tell me which are the right include files and what changes must be made in the code ? I am trying to separate english words such as : I've = I have, we've = we have, etc. ?
// Is there a new, better way to do that, so that the program knows that I is a Personal Pronoun, have is auxiliary verb, etc. ?

// added incl.files
#include <ctype.h>
#include <stdio.h>
#include <conio.h>

struct C_TAB *contr_analys(char *word, int wl, WORD *wrd);
struct C_TAB *contr_analys(char *word, int wl, WORD *wrd)
{
struct C_TAB *mor;
int lf, i;
WORD *new;

for (mor = CTAB; mor->mflex; mor++) {
if ((lf = isflex(word, wl, mor->mflex)) > 0) {
wl -= lf;
wrd->stat = 1;

switch (mor->mgram[0]) {
case 'M':
wl = 3;
word[wl] = '\0';
break;

case 'X':

if (!strcmp(word, "there\'s") ||
!strcmp(word, "here\'s") ||
!strcmp(word, "what\'s") ||
!strcmp(word, "that\'s") ||
!strcmp(word, "who\'s"))
{
word[wl] = '\0';
break;
}
else { /* pronoun or possessive case */
word[wl] = '\0';
for (i = 0; PRTAB.mflex; i++)
if (strcmp(PRTAB.mflex, word) == 0) break;

if (PRTAB.mflex == NULL && mor->cond == 3) {
/* possessive case */
word[wl] = '\'';
wrd->stat = 0;
return NULL;
}
/* pronoun */
}
break;

case 'T':
word[wl] = '\0';
if (word[0] != 'i')
{ /* are */
for (i = 1; PRTAB.mflex; i++)
if (strcmp(PRTAB.mflex, word) == 0) break;

if (PRTAB.mflex == NULL) i = 1;
}
break;

default: /* not */
if (!strcmp(word, "can\'t"))
wl++;
else if (!strncmp(word, "arn", 3)) {
strcpy(wrd->inword + 1, "re");
strcpy(word + 1, "re");
wl = 3;
}
else if (!strncmp(word, "sha", 3)) {
strcpy(wrd->inword + 3, "ll");
strcpy(word + 3, "ll");
wl = 5;
}
else if (mor->cond == 2) /* cannot */
wl = 3;
wrd->wl = wl;
word[wl] = '\0';
break;

} /* end switch */

new = enque_word(NULL, mor->mgram[0], mor->ow);
if (new == NULL) {
wrd->stat = -1;
break;
}
strcpy(new->inword, mor->iw);
new->stat = 1;
if (new->syn == 'X') new->cflag = '\'';
/*new->esyn = new->syn;*/
new->wl = strlen(mor->iw);
new->next = wrd->next;
wrd->next = new;
wrd->inword[wl] = '\0';
wrd->wl = wl;
/*wnprintf("\nword=\"%s\", wl=%d @ word=\"%s\", wl=%d ",
wrd->inword, wrd->wl, new->inword, new->wl);*/

return mor;
}
}

return NULL;
}

Continue reading...
 
Back
Top