2019年1月12日土曜日

テレビアニメ「シンプソンズ」(Simpsons)の台本をRNNニューラルネットワークで作成 part 1

ソースはこちら:https://github.com/nyck33/RNN-for-NLP/blob/master/dlnd_tv_script_generation.ipynb

作業の順序:

1.既存する台本を読み込む。https://www.kaggle.com/wcukierski/the-simpsons-by-the-data

Dataset Stats
Roughly the number of unique words: 11492 (固有単語数)
Number of scenes: 262 (シーン数)
Average number of sentences in each scene: 15.248091603053435 (1文の平均単語数)
Number of lines: 4257 (行数)
Average number of words in each line: 11.50434578341555 (1行の平均単語数)

2.句読点のトークン化

 token_to_alpha={'.':'<PERIOD>', 
                    ',':'<COMMA>', 
                    '"':'<QUOTATION_MARK>',
                    ';':'<SEMICOLON>',
                   '!':'<EXCLAMATION_MARK>', 
                    '?':'<QUESTION_MARK>',
                    '(':'<LEFT_PAREN>', 
                    ')':'<RIGHT_PAREN>',
                   '--':'<DASH>', 
                    '\n':'<RETURN>'}

3.参照テーブルの作成。ニューラルネットワークに単語を入力するのは不可能なので、単語を数値に変換する。

ここから

{0: '<period>', 1: '<return>', 2: '<comma>', 3: '<left_paren>', 4: '<right_paren>', 5: 'the', 6: 'i', 7: 'you', 8: '<exclamation_mark>', 9: 'moe_szyslak:', 10: '<question_mark>', 11: 'a', 12: 'homer_simpson:', 13: 'to', 14: 'and', 15: 'of', 16: 'my', 17: 'it', 18: 'that', 19: 'in', 20: '<quotation_mark>', 21: 'me', 22: 'is', 23: 'this', 24: "i'm", 25: 'for',

ここまで

 6741: 'patented', 6742: 'coma', 6743: 'show-off', 6744: 'muscles', 6745: 'engraved', 6746: 'richard:', 6747: 'audience:', 6748: 'ref', 6749: 'issuing', 6750: 'warning', 6751: 'rasputin', 6752: 'referee', 6753: 'permitting', 6754: 'smitty:', 6755: 'squabbled', 6756: 'washed', 6757: 'refreshment', 6758: 'trustworthy', 6759: 'sharing', 6760: 'birthplace', 6761: 'roy', 6762: 'scum-sucking', 6763: 'pus-bucket', 6764: 'eyeballs', 6765: 'often', 6766: 'bull', 6767: 'connection', 6768: 'lighten', 6769: 'ironic', 6770: 'snotty', 6771: 'sister-in-law', 6772: 'picky', 6773: 'blur', 6774: 'decided', 6775: 'happiness', 6776: 'pancakes', 6777: 'disdainful', 6778: 'heals', 6779: 'wounds'

作成されてます。






0 件のコメント:

コメントを投稿

My Github repo

In case anyone is interested:   https://github.com/nyck33