2011-04-12

Text Analyzer



AIの課題を解く際に出来た副作用的な作品。とりあえず公開。もしかしたらiPhoneアプリでも使えるやもしれない。

GitHub - yasulab/Text-Analyzer


/Users/yohei/text-analyzer% python text-analyzer.py
Text Analyzer
-------------
Commands:
rand NUMBER   : Randomly pick a word given times.
read FILENAME : Read a given file.
stats         : Show stats of recently read text.
help          : Show this.
exit          : Exit.

Current Text:  alice.txt

[alice.txt]> stats
Number of words: 27421

TOP 10 - MOST FRQUENTLY USED WORDS
COUNT | WORD | PROB [%]
1636 | the | 5.97
870 | and | 3.17
729 | to | 2.66
627 | a | 2.29
595 | it | 2.17
553 | she | 2.02
544 | i | 1.98
515 | of | 1.88
462 | said | 1.68
411 | you | 1.50

[alice.txt]> stata
Unknown command: stata
[alice.txt]> rands 10
Unknown command: rands
[alice.txt]> rand 10
Number of words: 27421

TOP 10 - MOST FRQUENTLY USED WORDS
COUNT | WORD | PROB [%]
1 | with | 10.00
1 | while | 10.00
1 | trotting | 10.00
1 | to | 10.00
1 | the | 10.00
1 | she | 10.00
1 | replied | 10.00
1 | isn | 10.00
1 | heard | 10.00
1 | after | 10.00

[alice.txt]> rand 2
Number of words: 27421

TOP 10 - MOST FRQUENTLY USED WORDS
COUNT | WORD | PROB [%]
1 | looked | 50.00
1 | come | 50.00

[alice.txt]> rand 100
Number of words: 27421

TOP 10 - MOST FRQUENTLY USED WORDS
COUNT | WORD | PROB [%]
9 | the | 9.00
5 | to | 5.00
4 | and | 4.00
2 | you | 2.00
2 | thought | 2.00
2 | s | 2.00
2 | must | 2.00
2 | as | 2.00
2 | all | 2.00
2 | alice | 2.00

[alice.txt]> read vicar.txt
[vicar.txt]> stats
Number of words: 64244

TOP 10 - MOST FRQUENTLY USED WORDS
COUNT | WORD | PROB [%]
2890 | the | 4.50
2093 | to | 3.26
1796 | and | 2.80
1659 | of | 2.58
1581 | i | 2.46
1317 | a | 2.05
1219 | my | 1.90
948 | in | 1.48
930 | that | 1.45
873 | was | 1.36

[vicar.txt]> help
Commands:
rand NUMBER   : Randomly pick a word given times.
read FILENAME : Read a given file.
stats         : Show stats of recently read text.
help          : Show this.
exit          : Exit.

[vicar.txt]> rand 100
Number of words: 64244

TOP 10 - MOST FRQUENTLY USED WORDS
COUNT | WORD | PROB [%]
5 | and | 5.00
3 | for | 3.00
3 | be | 3.00
2 | went | 2.00
2 | we | 2.00
2 | to | 2.00
2 | time | 2.00
2 | the | 2.00
2 | my | 2.00
2 | is | 2.00

[vicar.txt]> stats
Number of words: 64244

TOP 10 - MOST FRQUENTLY USED WORDS
COUNT | WORD | PROB [%]
2890 | the | 4.50
2093 | to | 3.26
1796 | and | 2.80
1659 | of | 2.58
1581 | i | 2.46
1317 | a | 2.05
1219 | my | 1.90
948 | in | 1.48
930 | that | 1.45
873 | was | 1.36

[vicar.txt]> help
Commands:
rand NUMBER   : Randomly pick a word given times.
read FILENAME : Read a given file.
stats         : Show stats of recently read text.
help          : Show this.
exit          : Exit.

[vicar.txt]> exit

0 件のコメント: