Нема описа

freqanalyzer.adoc 1.5KB

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