Skip to content
Ryo Sato edited this page Jan 11, 2018 · 1 revision

sentences

create table sentences (
    sentence_id serial primary key, /*id*/
    sentence varchar(255) not null, /*Discord上から取得した文章*/ // TODO:キャパ増やします。
    channel_id bigint not null, /*文章を取得したID*/
    create_date timestamp default CURRENT_TIMESTAMP,/*作成日時*/
    update_date timestamp default CURRENT_TIMESTAMP/*更新日時*/
);

words

MeCabで形態素解析を行った単語情報(重複して蓄積する)

create table words (
    word_id serial primary key,
    word varchar(255) not null, /*表層形*/
    part_of_speech varchar(255) default '*', /*品詞*/
    part_of_speech_detail1 varchar(255) default '*', /*品詞細分類1*/
    part_of_speech_detail2 varchar(255) default '*', /*品詞細分類2*/
    part_of_speech_detail3 varchar(255) default '*', /*品詞細分類3*/
    conjugate1 varchar(255) default '*', /*活用型*/
    conjugate2 varchar(255) default '*', /*活用形*/
    original varchar(255) default '*', /*原形*/
    pronunciation1 varchar(255) default '*', /*読み*/
    pronunciation2 varchar(255) default '*', /*発音*/
    create_date timestamp default CURRENT_TIMESTAMP,/*作成日時*/
    update_date timestamp default CURRENT_TIMESTAMP/*更新日時*/
);

sentence_word

単語情報と文章情報を繋ぐ中間テーブル

create table sentence_word (
    sentence_word_id serial primary key,
    sentence_id int not null,
    word_id int not null,
    channel_id bigint not null,
    create_date timestamp default CURRENT_TIMESTAMP,/*作成日時*/
    update_date timestamp default CURRENT_TIMESTAMP/*更新日時*/
);

markov_chain

マルコフ連鎖を3単語で行うためのテーブル

create table markov_chain (
    markov_chain_id serial primary key,
    sentence_id bigint not null,
    word1 varchar(255) not null,
    word2 varchar(255) not null,
    word3 varchar(255) not null,
    channel_id bigint not null,
    create_date timestamp default CURRENT_TIMESTAMP,/*作成日時*/
    update_date timestamp default CURRENT_TIMESTAMP/*更新日時*/
);

検索用にindexを生成

create index word2_index on markov_chain(word2, channel_id);

Discordチャネル

Discoのチャネル情報保持テーブル IDと和名を保持する

create table channels (
  channels_id serial primary key,
  channel_id bigint not null,/*チャネルID*/
  channel varchar(255) not null,/*チャネル名*/
  create_date timestamp default CURRENT_TIMESTAMP,/*作成日時*/
  update_date timestamp default CURRENT_TIMESTAMP/*更新日時*/
);

Clone this wiki locally