program to find the count of each word in a para
i am trying to find count of each word in a para but i am not able to get it done...
so can any one tell me how to do that..
Example Input----
Hi stack over flow is a good forum.There will be many experts in stack overflow .
ouput--
Hi---1
stack-2
overflow-2
is---1
a---1
good---1
...
...
in this way i want to get output.
This is my code...but it is not complete...after that i got struck to proceed
#include<stdio.h>
#include<conio.h>
#include<string.h>
#define NULL 0
struct wordcount
{
char *s;
int count;
struct wordcount next;
}
struct checkletter
{
char alph;
struct wordcount next;
}
main()
{
char *c;
int hash[26],len,i,k=0,intm[100];
struct checkletter complete[26];
for(r=0;r<25;r++)
{
complete[r].alph=r+97;
complete[r].next=NULL;
}
printf("Enter the para :");
gets(s);
len=strlen(s);
for(i=0;i<len;i++)
{
k=0;
if(c[i]==' ')
{
for(j=i;j>m;j--)
{
intm[k]=c[i];
s1=intm;
k++;
}
m=k;
hastlet=s1[0];
开发者_开发百科 for(t=0;t<26;t++)
{
if(complete[t].alph==hastlet)
{
if(complete[t].next==NULL)
complete[t].next=
}
Here's a sketch:
- Parse the paragraph into a token of words
- Maintain a map from hash codes to counters, being careful that collisions are possible
- For each word in the paragraph, hash the word to an integer
- Again, being careful that collisions are possible, increment the corresponding count
- Run through the hash table spitting out the words and the counts
Beyond that, if you have a specific question about your own implementation of the above, let us know and we can try to help. We are not going to write your code for you, though.
精彩评论