Velocity Reviews > How to calculate the percentage of each character in a text file?

How to calculate the percentage of each character in a text file?

Umesh
Guest
Posts: n/a

 02-01-2007
Plese help. Is there any software by which we can do that?

Clever Monkey
Guest
Posts: n/a

 02-01-2007
Umesh wrote:
> Plese help. Is there any software by which we can do that?
>

rely on the text in the Subject to always be obvious.

"How to calculate the percentage of each character in a text file?"

Sounds like homework to me. What have you done so far? You are
essentially asking for a distribution of letters (and, perhaps,
punctuation) in a file, possibly in order to print a histogram and/or
report on how often such characters appears in the file.

Start by counting how many of each character you get. Compare that with
the total number of characters you have.

Hint: choose a language and post to that group only. There is some
overlap between C and C++, but they are really different beasts.

Umesh
Guest
Posts: n/a

 02-01-2007
I want to find out % of a, b, c, d ..,z in a text file. Suppose that
the text file is a story. Is there any software for this purpose?

Walter Roberson
Guest
Posts: n/a

 02-01-2007
In article <(E-Mail Removed) .com>,
Umesh <(E-Mail Removed)> wrote:
>I want to find out % of a, b, c, d ..,z in a text file. Suppose that
>the text file is a story. Is there any software for this purpose?

Yes, there is software for that purpose, but No, I couldn't name
any immediately.

This sort of program is trivial to write in C (or C++).

case characters be treated as equivilent? Should they be
counted individually? Your specification only mentioned the
lower case letters, so should upper case letters be silently
ignored?

Should the program make some kind of attempt to determine whether
a letter is part of a word, and ignore the ones that are not?
For example, if there is a phrase that "She lives at 36-E 9th St.",
then should the 'E' be counted (36-E is not a word), should
the 't' and 'h' of '9th' be counted, should the 'S' and 't'
of 'St.' be counted?
--
"No one has the right to destroy another person's belief by
demanding empirical evidence." -- Ann Landers

Umesh
Guest
Posts: n/a

 02-01-2007
I need at least a solution first. Then I'll look for specifications.

Walter Roberson wrote:
> In article <(E-Mail Removed) .com>,
> Umesh <(E-Mail Removed)> wrote:
> >I want to find out % of a, b, c, d ..,z in a text file. Suppose that
> >the text file is a story. Is there any software for this purpose?

>
> Yes, there is software for that purpose, but No, I couldn't name
> any immediately.
>
> This sort of program is trivial to write in C (or C++).
>
> case characters be treated as equivilent? Should they be
> counted individually? Your specification only mentioned the
> lower case letters, so should upper case letters be silently
> ignored?
>
> Should the program make some kind of attempt to determine whether
> a letter is part of a word, and ignore the ones that are not?
> For example, if there is a phrase that "She lives at 36-E 9th St.",
> then should the 'E' be counted (36-E is not a word), should
> the 't' and 'h' of '9th' be counted, should the 'S' and 't'
> of 'St.' be counted?
> --
> "No one has the right to destroy another person's belief by
> demanding empirical evidence." -- Ann Landers

osmium
Guest
Posts: n/a

 02-01-2007

"Umesh" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
>I want to find out % of a, b, c, d ..,z in a text file. Suppose that
> the text file is a story. Is there any software for this purpose?

There probably is such a program but it most likely would be faster to write
such a program than to find, download, figure out how to use/ determine that
you *can't* use, such a program, and then use it, or start over.

Set up an array of 26 char and clear it. Then read the file,incrementing
the count in the appropriate array element when a character is received.

Dave Steffen
Guest
Posts: n/a

 02-01-2007
"Umesh" <(E-Mail Removed)> writes:

> I need at least a solution first. Then I'll look for specifications.

*Snort*

If you don't know the specifications of your solution, how will you
know if you have one?

I think you're in the wrong group. If you're looking for an existing
tool, you need to find a newsgroup for your platform.

----------------------------------------------------------------------
Dave Steffen, Ph.D. Disobey this command!
Software Engineer IV - Douglas Hofstadter
Numerica Corporation
dg@steffen a@t numerica d@ot us (remove @'s to email me)

Mark P
Guest
Posts: n/a

 02-01-2007
Umesh wrote:
> I need at least a solution first. Then I'll look for specifications.
>

That would be quite funny if it weren't written by someone who probably
intends to become a programmer. Please do humanity a favor and change
majors.

Umesh
Guest
Posts: n/a

 02-01-2007
For simplicity assume that all 26 inputs are in lower case. Now pl
write a program to input a text file and count number of a, b, c, ..,z
in the text file. Put is down in a output file. I'll do the rest.

Dave Steffen wrote:
> "Umesh" <(E-Mail Removed)> writes:
>
>
> > I need at least a solution first. Then I'll look for specifications.

>
> *Snort*
>
> If you don't know the specifications of your solution, how will you
> know if you have one?
>
> I think you're in the wrong group. If you're looking for an existing
> tool, you need to find a newsgroup for your platform.
>
> ----------------------------------------------------------------------
> Dave Steffen, Ph.D. Disobey this command!
> Software Engineer IV - Douglas Hofstadter
> Numerica Corporation
> dg@steffen a@t numerica d@ot us (remove @'s to email me)

Andre Kostur
Guest
Posts: n/a

 02-01-2007
"Umesh" <(E-Mail Removed)> wrote in
news:(E-Mail Removed) oups.com:

> For simplicity assume that all 26 inputs are in lower case. Now pl
> write a program to input a text file and count number of a, b, c, ..,z
> in the text file. Put is down in a output file. I'll do the rest.

How much are you paying?

See the C++ FAQ, section 5.3:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.3

Do it yourself. If you get stuck, ask a specific question.