Page 1 of 2 12 LastLast
Results 1 to 10 of 16
  1. #1

    Default does anybody knows "word inflector" using c language?


    words are in two files that need to be compared...then generate another file that pluralize already...

  2. #2

    Default Re: does anybody knows "word inflector" using c language?

    Please be specific. I don't understand the requirements. Give examples...

  3. #3

    Default Re: does anybody knows "word inflector" using c language?

    Hmm curious ko unsaon ni pag implement sa mga special words.

    Akording sa mga brayt linguists:
    If the plural of tooth is teeth, why isn't the plural of booth beeth? One goose, 2 geese. So one moose, 2 meese? One index, 2 indices? Doesn't it seem crazy that you can make amends but not one amend? If you have a bunch of odds and ends and get rid of all but one of them, what do you call it? If teachers taught, why didn't preachers praught? If a vegetarian eats vegetables, what does a humanitarian eat?
    [ simon.cpu ]

  4. #4

    Default Re: does anybody knows "word inflector" using c language?

    o kinsa to mga C programmers dha nga mga ngelngeg... pakitang gilas namo, para makatabang sad..

  5. #5

    Default Re: does anybody knows "word inflector" using c language?

    Dili klaro kung specs. What I did not understand is what to compare on the two input files?
    To pluralize is just a dictionary lookup for non-standard plural words such as goose or tooth, etc.

    I hope the OP will be more specific.

  6. #6

    Default Re: does anybody knows "word inflector" using c language?

    Quote Originally Posted by cold_fusion
    Please be specific. I don't understand the requirements. Give examples...
    Basicly it does this:
    1. You have a big textfile of "keywords". Each line holds one keyword or a keyword phrase. A phrase can consist of 2-X words.
    2. Furthermore you have another file - a grammar file. This file contains the singularis/pluralis version of most english nouns.
    3. By comparing the words in the keyword file with those in the grammar file, you may extend the keyword file.
    4. In a phrase not all words are pluralized. Consider this pluralis example:

    car breakdown recovery service cardiff uk, can be:

    car breakdowns recovery service cardiff uk
    car breakdown recoveries service cardiff uk
    car breakdown recovery services cardiff uk

    meaning: words are extracted from two different files....

  7. #7

    Default Re: does anybody knows "word inflector" using c language?

    grammar file is given, we use this grammar file to compare in the keyword file.
    grammar file looks like this:singular,plural fomat
    example:
    internet,internets
    development,developments
    etc...

    if keyword file consist of line of text such as
    webdesign development on th internet

    output woud be: (pluralize one at a time)
    webdesign developments on the internet
    webdesign development on the internets

  8. #8

    Default Re: does anybody knows "word inflector" using c language?

    ok. here it is:

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <ctype.h>
    
    FILE *fk;
    FILE *fg;
    FILE *fo;
    
    unsigned char buffer[200];
    
    char* find_plural(char *s)
    {
    	int n;
    	char line[1024];
    	char word[1024];
    	char *ptr1, *ptr2;
    	
    	strcpy(word,s);
    	strcpy(buffer,s);
    	
    	n=strlen(word);
    	if (n==0) return buffer;
    	
    	word[n++] = '/';
    	word[n] = 0;
    	
    	fseek(fg, 0, SEEK_SET);
    	while(fgets(line,1024,fg) != NULL)
    	{
    		if (strncmp(word, line, n) == 0)
    		{
    			ptr1 = buffer;
    			ptr2 = line+n;
    			while (isalnum(*ptr2))
    			{
    				*ptr1++ = *ptr2++;
    			}
    			*ptr1 = 0;
    			return buffer;
    		}
    	}
    	
    	return buffer;
    }
    
    
    void pluralize(char *line)
    {
    	char *words[200];
    	char *ptr;
    	int new_word;
    	int word_count = 0;
    	int i;
    	
    	ptr = line;
    	new_word = 1;
    	
    	while(*ptr)
    	{
    		if (isalnum(*ptr))
    		{
    			if (new_word)
    			{
    				words[word_count++] = ptr;
    				new_word = 0;
    			}
    		}
    		else
    		{
    			*ptr=0;
    			new_word = 1;
    		}
    		++ptr;
    	}
    	*ptr = 0;
    
    	for (i=0;i<word_count;++i)
    	{
    		/* printf("%s-",words[i]); */
    		fprintf(fo, "%s ",find_plural(words[i]));
    	}
    	fprintf(fo, "\n");
    }
    
    
    
    int main(void)
    {
    	char line[1024];
    
    	fk = fopen("keyword.txt","r");
    	fg = fopen("grammar.txt","r");
    	fo = fopen("output.txt","w");
    	
    	while(fgets(line,1024,fk) != NULL)
    	{
    		pluralize(line);
    	}
    
    	fclose(fk);
    	fclose(fg);
    	fclose(fo);
    }
    Code, keyword.txt, grammar.txt and output.txt can be downloaded at my blog here http://geekzone.freehostia.com/c-wor...tor-pluralizer

  9. #9

    Default Re: does anybody knows "word inflector" using c language?

    Quote Originally Posted by aloha123
    grammar file looks like this:singular,plural fomat
    example:
    internet,internets
    development,developments
    etc...
    sign development on the internets
    Note that the code i posted parses the grammar.txt with the following format: singular/plural .
    I have not read this last post when I code this a few minutes ago.
    But you could change the code easily to fit your format as an exercise.

  10. #10

    Default Re: does anybody knows "word inflector" using c language?

    Hala mo... dapat bangkahan nimo si cold_fusion or kung di gani, dapat tagaan nimo siya ug kiss. Pang compiler project bya na... Hala mo.... :P

  11.    Advertisement

Page 1 of 2 12 LastLast

Similar Threads

 
  1. Does anybody know portofino's phone number?
    By iamclas in forum Destinations
    Replies: 2
    Last Post: 05-30-2009, 08:29 PM
  2. Replies: 6
    Last Post: 04-09-2008, 10:17 AM
  3. does anybody knows about this...
    By daddyfree in forum Software & Games (Old)
    Replies: 3
    Last Post: 12-16-2007, 07:14 PM
  4. does anybody know how to ring back your landline?
    By jim-designs in forum Gizmos & Gadgets (Old)
    Replies: 14
    Last Post: 12-10-2006, 07:46 PM
  5. does anybody know about a remote key logger?
    By maverick_7 in forum Software & Games (Old)
    Replies: 7
    Last Post: 03-09-2006, 12:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top