words are in two files that need to be compared...then generate another file that pluralize already...
words are in two files that need to be compared...then generate another file that pluralize already...
Please be specific. I don't understand the requirements. Give examples...
Hmm curious ko unsaon ni pag implement sa mga special words.
Akording sa mga brayt linguists:
[ simon.cpu ]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?
o kinsa to mga C programmers dha nga mga ngelngeg... pakitang gilas namo, para makatabang sad..
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.
Basicly it does this:Originally Posted by cold_fusion
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....
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
ok. here it is:
Code, keyword.txt, grammar.txt and output.txt can be downloaded at my blog here http://geekzone.freehostia.com/c-wor...tor-pluralizerCode:#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); }
Note that the code i posted parses the grammar.txt with the following format: singular/plural .Originally Posted by aloha123
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.
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
Similar Threads |
|