| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- = Frequency Analyzer
-
- == Task
-
- Implement a program that analyzes arbitrary text files by counting the occurrence of letters.
- All special characters (e.g. `-`, `.`, `,`,`\s`,`\n`) and numbers should be ignored.
- The program should treat all letters as case-insensitive and output:
-
- * the letter,
- * the number of it occurance and
- * a percentage value in relation to all letters in the text
-
- ---
-
- For example, the following text should generate a similar output as shown below.
-
- `This is a simple test`
-
- [cols="",opts="autowidth"]
- |===
- |S |4 | 0.23529 | 23.529 %
- |T |3 | 0.17647 | 17.647 %
- |I |3 | 0.17647 | 17.647 %
- |E |2 | 0.11765 | 11.765 %
- |H |1 | 0.05882 | 5.882 %
- |A |1 | 0.05882 | 5.882 %
- |M |1 | 0.05882 | 5.882 %
- |P |1 | 0.05882 | 5.882 %
- |L |1 | 0.05882 | 5.882 %
- |===
-
- ---
-
- TIP: Design your program such that you can easily reuse the frequency-analysis component in other programs as well.
-
- WARNING: You can use any programming language you want. We will need the frequency analyzer for some other challenges as well. So choose wisely!
-
- ---
- Example output of a fequency analyzer program using the input link:./../test.txt[test.txt].
-
- [source, Shell]
- --
- $ python solution.py ../test.txt
- E 562 0.11408
- T 467 0.09480
- I 428 0.08688
- A 423 0.08587
- O 396 0.08038
- S 356 0.07226
- U 344 0.06983
- M 299 0.06069
- R 292 0.05927
- L 277 0.05623
- D 246 0.04993
- N 242 0.04912
- C 137 0.02781
- P 104 0.02111
- G 77 0.01563
- V 67 0.01360
- B 52 0.01055
- Q 38 0.00771
- Y 28 0.00568
- K 24 0.00487
- F 22 0.00446
- J 12 0.00243
- H 11 0.00223
- Z 10 0.00203
- X 8 0.00162
- W 4 0.00081
- --
|