473,379 Members | 1,355 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,379 software developers and data experts.

Program that makes a list of words.

Maybe this is the wrong group, if so I would like to be pointed
to a better group.
Anyway here's the problem:

I would need a program that makes a list of words of a text-file.

For example take the text:

------------------------------------
To be, or not to be; thats: the ques-
tion.
-----------------------------------------

would return:

be 2
not 1
or 1
question 1
thats 1
the 1
To 1
to 1
.. 1
, 1
: 1
; 1
- 1
As can be seen from this example, I want the program to count both
words and
interpunctation, and I want it to make a difference between "to" and
"To",
I also want it to count:

ques
-tion

as

question 1
- 1
Any help would be appreciated!

Jun 27 '08 #1
12 1274
lu**********@yahoo.com writes:
>Any help would be appreciated!
The result you seek (homework?) is typically termed a concordance.

--
Chris.
Jun 27 '08 #2


Chris McDonald skrev:
lu**********@yahoo.com writes:
Any help would be appreciated!

The result you seek (homework?) is typically termed a concordance.

--
Chris.
Thank you for helping me.
Now I know what's the name is: concordance.
I guess that's some kind of dance?

It's not homework, I'm not a computerscientist.

I really would appreciate if someone can give me the URL
where I can find such a program.

Jun 27 '08 #3
lu**********@yahoo.com writes:
>Thank you for helping me.
Now I know what's the name is: concordance.
I guess that's some kind of dance?
>It's not homework, I'm not a computerscientist.
>I really would appreciate if someone can give me the URL
where I can find such a program.
Here's a start:

http://www.google.com/search?client=...UTF-8&oe=UTF-8

--
Chris.
Jun 27 '08 #4
Hi

On May 13, 9:52 am, Richard Heathfield <r...@see.sig.invalidwrote:
lundslakt...@yahoo.com said:
I asked my Father, and he suggested that I should use microsoft-word
to make the whole text one column,
and then insert that column in excel and use the sorting
function.

Blech! :-)
But that wont work for long text(more than 65536 words).

And it's so inelegant, too.
[snip]
>
qsort(WordArray, Treecount, sizeof *WordArray, CompareWords);
pot? kettle? :-)

Even the most rushed semi-efficient implementation would use an insert
sort on a linked list. I bet even excel doesn't use qsort. Perhaps a
good one would use a tree?

Jun 27 '08 #5
viza wrote:
Hi

On May 13, 9:52 am, Richard Heathfield <r...@see.sig.invalidwrote:
>lundslakt...@yahoo.com said:
>>I asked my Father, and he suggested that I should use microsoft-word
to make the whole text one column,
and then insert that column in excel and use the sorting
function.

Blech! :-)
>>But that wont work for long text(more than 65536 words).

And it's so inelegant, too.
[snip]
>>
qsort(WordArray, Treecount, sizeof *WordArray, CompareWords);

pot? kettle? :-)

Even the most rushed semi-efficient implementation would use an insert
sort on a linked list. I bet even excel doesn't use qsort. Perhaps a
good one would use a tree?
Who says that qsort does not do an insert sort? qsort != quick sort, at
least not neccarrily, regardless what the name implies

Bye, Jojo
Jun 27 '08 #6
Joachim Schmitz wrote:
viza wrote:
>Hi

On May 13, 9:52 am, Richard Heathfield <r...@see.sig.invalidwrote:
>>lundslakt...@yahoo.com said:
I asked my Father, and he suggested that I should use microsoft-word
to make the whole text one column,
and then insert that column in excel and use the sorting
function.
Blech! :-)

But that wont work for long text(more than 65536 words).
And it's so inelegant, too.
[snip]
>> WordArray
>> sizeof *WordArray
>pot? kettle? :-)

Even the most rushed semi-efficient implementation would use an insert
sort on a linked list. I bet even excel doesn't use qsort. Perhaps a
good one would use a tree?
Who says that qsort does not do an insert sort? qsort != quick sort, at
least not neccarrily, regardless what the name implies
What linked list?

--
pete
Jun 27 '08 #7
viza said:

<snip>
>>
qsort(WordArray, Treecount, sizeof *WordArray, CompareWords);

pot? kettle? :-)
I don't follow. I grabbed something off the Net and hacked it a bit to give
the OP a rough idea. I neither wrote the original code nor intended to
provide a perfect solution.
Even the most rushed semi-efficient implementation would use an insert
sort on a linked list.
I'd have used a BST, personally. But I didn't rush this implementation. I
stole it.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #8
lu**********@yahoo.com wrote:
Chris McDonald skrev:
>lu**********@yahoo.com writes:
>>Any help would be appreciated!

The result you seek (homework?) is typically termed a concordance.

Thank you for helping me. Now I know what's the name is:
concordance. I guess that's some kind of dance?

It's not homework, I'm not a computerscientist.

I really would appreciate if someone can give me the URL
where I can find such a program.
Try wdfreq.c, a demo program with the hashlib package. It should
be easily modifiable to do what you wish. See:

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

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
** Posted from http://www.teranews.com **
Jun 27 '08 #9
viza <to******@gmail.comwrites:
On May 13, 9:52 am, Richard Heathfield <r...@see.sig.invalidwrote:
>lundslakt...@yahoo.com said:
I asked my Father, and he suggested that I should use microsoft-word
to make the whole text one column,
and then insert that column in excel and use the sorting
function.

Blech! :-)
But that wont work for long text(more than 65536 words).

And it's so inelegant, too.
[snip]
>>
qsort(WordArray, Treecount, sizeof *WordArray, CompareWords);

pot? kettle? :-)

Even the most rushed semi-efficient implementation would use an insert
sort on a linked list. I bet even excel doesn't use qsort. Perhaps a
good one would use a tree?
Why would you expect insertion sort (O(N**2)) to be better than qsort
(unspecified, but likely to be O(N log N))?

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 27 '08 #10
Hi

On May 13, 12:55 pm, "Joachim Schmitz" <nospam.j...@schmitz-
digital.dewrote:
viza wrote:
On May 13, 9:52 am, Richard Heathfield <r...@see.sig.invalidwrote:
lundslakt...@yahoo.com said:
And it's so inelegant, too.
[snip]
qsort(WordArray, Treecount, sizeof *WordArray, CompareWords);
pot? kettle? :-)
Even the most rushed semi-efficient implementation would use an insert
sort on a linked list. I bet even excel doesn't use qsort. Perhaps a
good one would use a tree?

Who says that qsort does not do an insert sort? qsort != quick sort, at
least not neccarrily, regardless what the name implies
It could perhaps, but qsort always requires all of the items to be in
place before it starts, so solving this problem with a qsort that was
implemented as an insert sort would double peak memory usage, and have
to copy the whole thing back as well. In this case IMHO it makes
sense to sort it as it is read, and the easiest way that I could think
to do this was an insert sort into a list.

Regards,
viza
Jun 27 '08 #11
Hi

On May 13, 1:22 pm, Richard Heathfield <r...@see.sig.invalidwrote:
viza said:
qsort(WordArray, Treecount, sizeof *WordArray, CompareWords);
pot? kettle? :-)

I don't follow. I grabbed something off the Net and hacked it a bit to give
the OP a rough idea. I neither wrote the original code nor intended to
provide a perfect solution.
I realized that, it was good of you to help the (OT) OP. I just
thought that the method this code used wasn't very elegant either.

Regards,
viza
Jun 27 '08 #12
viza wrote:
>
.... snip ...
>
Even the most rushed semi-efficient implementation would use an
insert sort on a linked list. I bet even excel doesn't use qsort.
Perhaps a good one would use a tree?
If you have a linked list, the most efficient sort is almost
certainly mergesort. It can operate in place, is O(NlogN), etc.
Virtually no extra memory is required.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
** Posted from http://www.teranews.com **
Jun 27 '08 #13

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

Similar topics

9
by: cppaddict | last post by:
Let's say you want to implement a Dictionary class, which contains a vector of DictionaryEntry. Assume each DictionaryEntry has two members, a word and a definition. Now assume your program...
2
by: duncanblacksmithmath | last post by:
I know a lot of you have seen this before but I have worked on the program and have gotten it to work thus far but I need help getting these two functions to work and implementing them. Here is...
23
by: comp.lang.tcl | last post by:
I have a TCL proc that needs to convert what might be a list into a string to read consider this: ]; # OUTPUTS Hello World which is fine for PHP ]; # OUTPUT {{-Hello}} World, which PHP...
66
by: genestarwing | last post by:
QUESTION: Write a program that opens and read a text file and records how many times each word occurs in the file. Use a binary search tree modified to store both a word and the number of times it...
8
by: hazmaz | last post by:
I am writing a program will have a function where it opens a text file, and fills a list box line by line from the text file. It works fine, except for when I tried to load a dictionary which is ~...
2
by: pchahar | last post by:
Write a program to process a text file. The program will determine how many unique words there are in the text file that begin with each letter of the alphabet. The text file name will be given as a...
27
by: Steven D'Aprano | last post by:
I thought that an iterator was any object that follows the iterator protocol, that is, it has a next() method and an __iter__() method. But I'm having problems writing a class that acts as an...
3
by: Wal | last post by:
I have written a program which lists all possible English words from a set of letters. Trouble is if you enter something over 8 letters long the function can go on for several minutes. I've...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.