473,395 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how to resolve this problem

here is the question:read in a input file such like input.txt,recognise
the english words.output
a list of the words by alphabet and the count of the each word into a
file such like output.txt
e.g.the input.txt is:

Hello world.
Hello every one.
Let us go.
and the output.txt is:
every,1
go,1
hello,2
let,1
one,1
us,1
world,1
I remember some book has the answer ,but i can't remember the name of
the book

regardly

Apr 3 '06 #1
11 1218
ye
cat file1 | tr -s ".,;= " "\n" | sort | uniq -c | sort -n +0 -r

Apr 3 '06 #2
is there source code for this problem,or anywhere i can find
ye wrote:
cat file1 | tr -s ".,;= " "\n" | sort | uniq -c | sort -n +0 -r


Apr 3 '06 #3
No u have try by manually(i.e by your skill)

Apr 3 '06 #4
u can start off with this code..
mind u it has a some bugs, but it can get u started..
the program will repeat the search for words that have been searched;
also it does not consider the '.' after at the end of a line.
u will have to finish it up.

#include<stdio.h>
FILE *rptr;

int main()
{
int wcount=0;
char str1[50],str2[50];
long cpos;

rptr=fopen("input.txt","r");
fscanf(rptr,"%s",str1);
while(!feof(rptr))
{
cpos=ftell(rptr);
wcount=1;
str2[0]='\0';
while(!feof(rptr))
{
fscanf(rptr,"%s",str2);
if(strcmp(str1,str2)==0) wcount++;
}
printf("\n%s:%d",str1,wcount);
fseek(rptr,cpos,SEEK_SET);
fscanf(rptr,"%s",str1);
}
return 0;
}

Apr 3 '06 #5
thank u very much ,i will do it myself.

Apr 3 '06 #6
niuzb wrote:

here is the question:read in a input file such like input.txt,
recognise the english words.output a list of the words by alphabet
and the count of the each word into a file such like output.txt
e.g.the input.txt is:

Hello world.
Hello every one.
Let us go.
and the output.txt is:
every,1
go,1
hello,2
let,1
one,1
us,1
world,1
I remember some book has the answer ,but i can't remember the name of
the book


wdfreq, which is one of the demos for hashlib, available at:

<http://cbfalconer.home.att.net/download/hashlib.zip>

produces:

[1] c:\c\hashlib>wdfreq
Usage: wdfreq < inputfile > outputfile
collects all words in inputfile and outputs a
sorted (by frequency) list of words and the
frequency of their occurences, ignores case.

Signal EOF to terminate (^D or ^Z usually)
hello world
hello every one
let us go
^Z
8 words, 7 entries, 10 probes, 2 misses
2 hello
1 every
1 go
1 let
1 one
1 us
1 world

Read the following URLs and sig before replying or otherwise
posting again. Remember, google is not usenet, only a poor
interface to it.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>

Apr 3 '06 #7
ye wrote:
cat file1 | tr -s ".,;= " "\n" | sort | uniq -c | sort -n +0 -r


Please read the information below.
Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Apr 3 '06 #8
niuzb wrote:
is there source code for this problem,or anywhere i can find
ye wrote:
cat file1 | tr -s ".,;= " "\n" | sort | uniq -c | sort -n +0 -r


Please read the information below.
Brian
--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Apr 3 '06 #9
code break wrote:
No u have try by manually(i.e by your skill)


Please read the information below.
Brian
--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Apr 3 '06 #10
rr********@gmail.com wrote:
u can start off with this code..


Please read the information below.
Brian
--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Apr 3 '06 #11

"CBFalconer" <cb********@yahoo.com> wrote in message
news:44***************@yahoo.com...
niuzb wrote:

here is the question:read in a input file such like input.txt,
recognise the english words.output a list of the words by alphabet
and the count of the each word into a file such like output.txt
e.g.the input.txt is:

Hello world.
Hello every one.
Let us go.
and the output.txt is:
every,1
go,1
hello,2
let,1
one,1
us,1
world,1
I remember some book has the answer ,but i can't remember the name of
the book


wdfreq, which is one of the demos for hashlib, available at:

<http://cbfalconer.home.att.net/download/hashlib.zip>

produces:

[1] c:\c\hashlib>wdfreq
Usage: wdfreq < inputfile > outputfile
collects all words in inputfile and outputs a
sorted (by frequency) list of words and the
frequency of their occurences, ignores case.

Signal EOF to terminate (^D or ^Z usually)
hello world
hello every one
let us go
^Z
8 words, 7 entries, 10 probes, 2 misses
2 hello
1 every
1 go
1 let
1 one
1 us
1 world

Read the following URLs and sig before replying or otherwise
posting again. Remember, google is not usenet, only a poor
interface to it.

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>


We could see this response coming from a mile away :-).
Apr 3 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Subrahmanyam Arya | last post by:
Dear oracle gurus, I am unable to get past the error ORA-12154: TNS: could not resolve service name on my host when using hsodbc to talk to a remote mysql database. i got from the meta link all...
1
by: yanwan | last post by:
I met this problem in executing a c++ project in visual studio. Does anyone have suggestions to resolve "error lnk 2001"? --------------------Configuration: reconstruction - Win32...
1
by: Alex Zhitlenok | last post by:
Hi, My question is how to resolve in C# ambiguous overloaded operators? Let say, I have two unrelated classes A and B, each one implements overloaded operator + with the first parameter of type...
0
by: Kevin Kenny | last post by:
Hi All, I have a problem with the following code: IPHostEntry hostInfo = Dns.Resolve("www.develop.com"); Dns.Resolve() throws : System.Net.Sockets.SocketException: No such host is known at...
0
by: Mike Eaton | last post by:
Hi all, I'm getting an error when I attempt to run the Dns.Resolve(hostName) method: No more results can be returned by WSALookupServiceNext I am able to ping the hostname I'm attempting...
1
by: pemigh | last post by:
I experienced the same problem that I found posted from summer 2005 (apparently too long ago to continue the thread). See below for full description. I found that reinstalling Access 2000 did...
1
by: vsp15584 | last post by:
Hii..i use the coding as below :- import java.applet.applet; import java.awt.*; import com.sun.j3d.utils.applet.mainframe; import com.sun.j3d.utils.universe.*; import...
5
by: carlpayne1984 | last post by:
Hi all, I'm fairly new to XML, however already I have studied myself stupid without being able to solve this problem. Basically, I have an XML file/Schema about a CD catalog that I've created that...
0
by: Usman Jamil | last post by:
Hi I'm writing a socket client application in C#. The problem is that the statement IPHostEntry hostEntry = Dns.Resolve(szIPAddress); takes too much time. Even if the IP address is of a...
4
by: =?Utf-8?B?SnVhbiBEZW50?= | last post by:
Hi, I am getting the following in a VC++ EXE (using VS2005) that links several C++ DLLs and uses MFC and ATL, when I try to start it under the debugger: ------- 'Exactus.UX.Studio.v1.exe':...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.