/*********************************************************************************** * File: neg.c * Created: 19 NO 2000 * Author: Jeff Jenkins, R. DeArmond * Date modified: * * This file contains the struct and array declaration for the lexicon, and * the prototypes for all of the functions specific to negatives, to be used with the * grammars one through eight. The functions are used to manipulate the negatives in * an array of megatives, which represents the negative portion of a lexicon. * * The current implementation, using an array to store the lexical entries for each * type of word is adequate for now, but if the lexicon is to be allowed to grow to * any size, this will have to change. In that case, the lexicon will have to be * used in the file, and file access performed whenever the lexicon is to be used. * Currently, a maximum number of negatives (MAX_NEGS = 4) is imposed so that the * array can be declared. ***********************************************************************************/ /*********************************************************************************** * includes ***********************************************************************************/ #include #include #include "neg.h" #include "lib.h" #include "lexicon.h" #include "functions.h" int neg_cat; int neg; int neg_overt_comp; int neg_strong; char neg_cat_form[STRING_SIZE]; char neg_form[STRING_SIZE]; //char negative; struct neg_struct neg1, neg2; /*********************************************************************************** * local function prototypes ***********************************************************************************/ void print_neg_features(struct neg_struct* n) { printf("\tnegative:\t\t\t\t\t\t\t\t%s\n", n->neg_form); printf("\tnegative overt complement?:\t\t\t\t\t\t%s\n", n->neg_overt_comp); } /*********************************************************************************** * input: a negative struct for which the features are to be displayed. * description: uses printf to display the features to stdout. ***********************************************************************************/ void set_neg_defaults(int n, char *s); /*********************************************************************************** * input: s is a string holding the name of the negative. * n is the position in the array that it will be inserted. * description: copies s into the negative in the position in the array indicated * by n. ***********************************************************************************/ /*********************************************************************************** * extern function implementations ***********************************************************************************/ int find_neg_index(char *s) // iterate through the neg_list, comparing the string passed in via the parameter // to each negative, until the negative is found, or the end of the list is reached. { int i; for(i=0;i=0;i--) for(j=0;j0) { memmove(&temp_neg,&neg_list[j],sizeof(struct neg_struct)); memmove(&neg_list[j],&neg_list[j+1],sizeof(struct neg_struct)); memmove(&neg_list[j+1],&temp_neg,sizeof(struct neg_struct)); } } } void list_negs() { int i; printf("There are %d negatives.\n",negatives); for(i=0;ineg_cat_feat, "P"); }*/ void edit_neg() // Prompt for the negative to be edited. display its features. Prompt for the new negative // if it exists, and is not the one we are editing, stop. Else call get_n to get // the new features, then sort and get the new index for the negative. { char neg_entered[32]; // for searching for a negative int index, index2; printf("Enter the negative to be edited: "); scanf("%s", neg_entered); index = find_neg_index(neg_entered); if (index == -1) printf("That negative is not in the lexicon.\n"); else { print_neg_features(&neg_list[index]); printf("\n\nType in the correct negative: "); scanf(" %s",neg_entered); //check to see if this negative already exists, if it isn't the same as the original being edited index2 = find_neg_index(neg_entered); if((index2==-1)||(index2==index)) { strcpy(neg_list[index].neg_form,neg_entered); //so we can find the new index for the negative. get_neg(&neg_list[index]); sort_negs(); // get the new index index = find_neg_index(neg_entered); save_lexicon(0); printf("The new features of the negative are: \n"); print_neg_features(&neg_list[index]); } else printf("That negative already exists in the lexicon\n"); } } int get_neg(struct neg_struct *p) // blank out the old values (except the negative itself), then prompt for features using Dr DeArmond's rules. { // blank out the old values. // neg_defaults(p); printf("What is the categorial symbol of the negative? Answer with the appropriate symbol: ",p->neg_cat_form); scanf("%s",p->neg_cat_form); printf("\n[%s ] is the categorial symbol.\n\n",p->neg_cat_form); /* if(yes_answer("Does the negative take a NP complement? Type in 'y' or 'n' (only): ")) { p->neg_overt_comp=1; p->neg_cat=1; printf("'%d' is the value of the feature for overt complementation in the negative. \n",p->neg_overt_comp); } if(yes_answer("Does the negative take a PP complement? Type in 'y' or 'n' (only): ")) { p->neg_pp_comp=1; p->neg_trans=0; printf("'%d' is the value of the feature of transitiveness in the negative. \n",p->neg_trans); } if(yes_answer("Does the negative take an S (TP) complement? Type in 'y' or 'n' (only): ")) { p->neg_S_comp=1; p->neg_trans=0; printf("'%d' is the value of the feature of transitiveness in the negative. \n",p->neg_trans); } if(yes_answer("Does the negative take no complement? Type in 'y' or 'n' (only): ")) { p->no_comp=1; p->neg_trans=0; printf("'%d' is the value of the feature of transitiveness in the negative. \n",p->neg_trans); } */ printf("Takes an overt complement = '%d'\t\t\n",p->neg_overt_comp); return 0; } void neg_defaults(struct neg_struct* n) /*********************************************************************************** * input: a pointer to a neg_struct that is to have its features 'blanked out' * output: * description: copies an empty string into each feature. ***********************************************************************************/ { //strcpy(p->neg_cat_form,""); n->neg_cat = 0; n->neg; n->neg_strong; } /*********************************************************************************** * internal function definitions ***********************************************************************************/ void set_neg_defaults(int n, char *s) { strcpy(neg_list[n].neg_form, s); }