Esempio n. 1
0
int diagram_category(lexicon_form *forms, int length, int root_number) {
  int i;
  int end;
  tag_t category = tag_category(forms[0].tag);

  for (end = 1; end < length && tag_category(forms[end].tag) == category; end++);

  if (root_number) {
    printf("%-38d", root_number);
  } else {
    printf("%38s", "");
  }

  switch (category) {
  case TAG_CATEGORY_VERB:
    print_wrapped("SINGULAR", "PLURAL");
    diagram_verb_category(forms, end);
    break;

  case TAG_CATEGORY_NOUN:
  case TAG_CATEGORY_ADJECTIVE:
  case TAG_CATEGORY_POSSESSIVE_ADJECTIVE:
  case TAG_CATEGORY_DEFINITE_ARTICLE:
  case TAG_CATEGORY_INDEFINITE_ARTICLE:
  case TAG_CATEGORY_1ST_PERSON_PRONOUN:
  case TAG_CATEGORY_2ND_PERSON_PRONOUN:
  case TAG_CATEGORY_3RD_PERSON_PRONOUN:
  case TAG_CATEGORY_REFLEXIVE_PRONOUN:
  case TAG_CATEGORY_RECIPROCAL_PRONOUN:
  case TAG_CATEGORY_DEMONSTRATIVE_PRONOUN:
  case TAG_CATEGORY_RELATIVE_PRONOUN:
  case TAG_CATEGORY_QUANTITATIVE_RELATIVE_PRONOUN:
  case TAG_CATEGORY_INTERROGATIVE_PRONOUN:
  case TAG_CATEGORY_QUANTITATIVE_INTERROGATIVE_PRONOUN:
    print_wrapped("SINGULAR", "PLURAL");
    diagram_adjectival_category(forms, end, 0);
    break;

  default:
    diagram_indeclinable_category(forms, end);
  }

  return end;
}
Esempio n. 2
0
File: main.c Progetto: xdpirate/dex
void PrintEntry(int pokeNum) {
	printf("[#%d]: %s\n", pokeNum, pokemonNames[pokeNum]);
	printf("%s Pokemon\n", pokemonKinds[pokeNum]);
	printf("Type: %s\n", pokemonTypes[pokeNum]);
	printf("Weight: %s\n", pokemonWeights[pokeNum]);
	printf("Height: %s\n", pokemonHeights[pokeNum]);
	printf("Steps to hatch: %d\n", stepsToHatchEgg[pokeNum]);
	printf("\n");
	print_wrapped(pokemonDexEntries[pokeNum], CONSOLE_CHAR_WIDTH, 0);
}
Esempio n. 3
0
/*
** Show a groups members, its rotate setting, and its comment.
*/
int group_show(const char *argv[])
	{
	const char *function = "group_show";
	const char *group = argv[0];		/* The name of the group to show is the argument. */

	int x;
	char *ptr;

	int rotate = TRUE;					/* Is rotate set for this group? */
	char *comment = (char*)NULL;		/* Group comment. */
	int member_count = 0;				/* Keep count of members. */
	char *members[MAX_GROUPSIZE];		/* The names of the members. */
	char *deffiltopts = (char*)NULL;	/* The default filter options string. */
	char *switchset = (char*)NULL;		/* The compressed switchset string. */
	char *passthru = (char*)NULL;
	char *acls = (char*)NULL;
	#define MAX_ADDONS 32
	char *addon[MAX_ADDONS];
	int addon_count = 0;

	if(! group)
		{
		fputs(_("You must supply the name of a group to show.\n"), errors);
		return EXIT_SYNTAX;
		}

	if(grpopen(group, FALSE, FALSE))	/* Open the configuration file. */
		{
		fprintf(errors, _("The group \"%s\" does not exist.\n"), group);
		return EXIT_BADDEST;
		}

	while(confread())			/* Read all the lines in the config file. */
		{
		if(lmatch(confline, "Rotate:"))
			{
			rotate = gu_torf(&confline[7]);
			continue;
			}
		if(gu_sscanf(confline, "Comment: %A", &ptr) == 1)
			{
			if(comment) gu_free(comment);
			comment = ptr;
			continue;
			}
		if(gu_sscanf(confline, "Printer: %S", &ptr) == 1)
			{
			if(member_count < MAX_GROUPSIZE)
				{
				members[member_count++] = ptr;
				}
			else
				{
				fprintf(errors, "%s(): too many members: %s\n", function, ptr);
				gu_free(ptr);
				}
			continue;
			}
		if(gu_sscanf(confline, "Switchset: %Z", &ptr) == 1)
			{
			if(switchset) gu_free(switchset);
			switchset = ptr;
			continue;
			}
		if(gu_sscanf(confline, "DefFiltOpts: %Z", &ptr) == 1)
			{
			if(deffiltopts) gu_free(deffiltopts);
			deffiltopts = ptr;
			continue;
			}
		if(gu_sscanf(confline, "PassThru: %Z", &ptr) == 1)
			{
			if(passthru) gu_free(passthru);
			passthru = ptr;
			continue;
			}
		if(gu_sscanf(confline, "ACLs: %Z", &ptr) == 1)
			{
			if(acls) gu_free(acls);
			acls = ptr;
			continue;
			}
		if(confline[0] >= 'a' && confline[0] <= 'z')	/* if in addon name space */
			{
			if(addon_count >= MAX_ADDONS)
				{
				fprintf(errors, "%s(): addon[] overflow\n", function);
				}
			else
				{
				addon[addon_count++] = gu_strdup(confline);
				}
			continue;
			}


		} /* end of line reading while() loop */

	confclose();		/* We are done with the configuration file. */

	if(!machine_readable)
		{
		printf(_("Group name: %s\n"), group);

		printf(_("Comment: %s\n"), comment ? comment : "");

		PUTS(_("Members:"));
		for(x=0;x<member_count;x++)		/* Show what printers are members. */
			{
			if(x==0)
				printf(" %s", members[x]);
			else
				printf(", %s", members[x]);
			}
		putchar('\n');					/* End group members line. */

		printf(_("Rotate: %s\n"), rotate ? _("True") : _("False"));

		{
		const char *s = _("Default Filter Options: ");
		PUTS(s);
		if(deffiltopts)
			print_wrapped(deffiltopts, strlen(s));
		putchar('\n');
		}

		PUTS(_("Switchset: "));
		if(switchset)
			print_switchset(switchset);
		putchar('\n');

		/* This rare parameter is shown only when it has a value. */
		if(passthru)
			printf(_("PassThru types: %s\n"), passthru);

		/* Only displayed if set. */
		if(acls)
			printf(_("ACLs: %s\n"), acls);

		/* Print the assembed addon settings. */
		if(addon_count > 0)
			{
			int x;
			PUTS(_("Addon:"));
			for(x = 0; x < addon_count; x++)
				{
				printf("\t%s\n", addon[x]);
				gu_free(addon[x]);
				}
			}

		}
	else
		{
		printf("name\t%s\n", group);
		printf("comment\t%s\n", comment ? comment : "");
		PUTS("members\t");
		for(x=0; x < member_count; x++)
			printf("%s%s", x > 0 ? " " : "", members[x]);
		PUTS("\n");
		printf("rotate\t%s\n", rotate ? "yes" : "no");
		printf("deffiltopts\t%s\n", deffiltopts ? deffiltopts : "");
		PUTS("switchset\t"); if(switchset) print_switchset(switchset); putchar('\n');
		printf("passthru\t%s\n", passthru ? passthru : "");
		printf("acls\t%s\n", acls ? acls : "");

		/* Addon lines */
		if(addon_count > 0)
			{
			int x;
			char *p;
			for(x = 0; x < addon_count; x++)
				{
				if((p = strchr(addon[x], ':')))
					{
					*p = '\0';
					p++;
					p += strspn(p, " \t");
					printf("addon %s\t%s\n", addon[x], p);
					}
				else
					{
					printf("addon\t%s\n", addon[x]);
					}
				gu_free(addon[x]);
				}
			}

		}

	if(comment)
		gu_free(comment);
	for(x=0;x<member_count;x++)
		gu_free(members[x]);
	if(deffiltopts)
		gu_free(deffiltopts);
	if(switchset)
		gu_free(switchset);
	if(passthru)
		gu_free(passthru);
	if(acls)
		gu_free(acls);

	return EXIT_OK;
	} /* end of group_show() */
Esempio n. 4
0
void print_singular_plural(lexicon_form *forms, int end, tag_t mask, tag_t value) {
  char *singular = find_form(forms, end, mask, value | TAG_NUMBER_SINGULAR);
  char *plural = find_form(forms, end, mask, value | TAG_NUMBER_PLURAL);

  print_wrapped(singular, plural);
}
Esempio n. 5
0
File: main.c Progetto: xdpirate/dex
// GUESS THAT POKEYMAN!
void GuessThatPokemon(void) {
	int playing = 1;
	int points = 0;
	int tries = 0;
	while(playing == 1) {
		if(system("cls")) { system("clear"); }
		srand( (unsigned)time( NULL ) );
		int randomPokemonNum = (rand()%MAX_POKEMON)+1;
		char randomPokemonName[255];
		strcpy(randomPokemonName, pokemonNames[randomPokemonNum]);
		char randomPokemonDexEntry[255];
		strcpy(randomPokemonDexEntry, pokemonDexEntries[randomPokemonNum]);
		
		char answer[255];
		
		char ucPokemonName[256];
		strcpy(ucPokemonName, randomPokemonName);
		int derp;
		
		for(derp = 0; ucPokemonName[derp]; derp++) {
			ucPokemonName[derp] = toupper(ucPokemonName[derp]);
		}
		
		GTPInfo();
		print_wrapped(replace_str(pokemonDexEntries[randomPokemonNum], ucPokemonName, "[...]"), CONSOLE_CHAR_WIDTH, 0);
		
		printf("\n\nWhich Pokemon is described above?\nAnswer: ");
		scanf("%s", answer);
		
		tries++;
		
		int x = 0;
		int namelength = strlen(answer);
		while(x < namelength) {
			answer[x] = tolower(answer[x]);
			x++;
		}
		
		char lowercaseName[255];
		strcpy(lowercaseName, randomPokemonName);
		x = 0;
		namelength = strlen(lowercaseName);
		
		while(x < namelength) {
			lowercaseName[x] = tolower(lowercaseName[x]);
			x++;
		}
		
		if(system("cls")) { system("clear"); }
		
		GTPInfo();
		
		if(strcmp(lowercaseName, answer) == 0) {
			// correct
			points++;
			printf("CORRECT!\n\nThe correct Pokemon was:\n  [#%d] %s\n\nAfter %d tries, you have\nguessed correctly %d times,\n", randomPokemonNum, randomPokemonName, tries, points);
		} else {
			// incorrect
			printf("Incorrect!\n\nThe correct Pokemon was:\n  [#%d] %s\n\nAfter %d tries, you have\nguessed correctly %d times,\n", randomPokemonNum, randomPokemonName, tries, points);
		}
		
		int percentage;
		percentage = (points * 100) / tries;
		
		printf("that's a %d%% success rate!\n\nTry again? [Y/N]: ", percentage);
		
		char moar[10];
		
		scanf("%s", moar);
		
		if(moar[0] == 'y' || moar[0] == 'Y') {
			;
		} else {
			playing = 0;
		}
	}
}