call Session;
call log('Step(2)', 'begin');

CALL log('FeatureBin',      'create');

call drop_table('FeatureBin');

create table FeatureBin
(
  match_source  varchar(50) not null,
  match_value   varchar(50) not null,
  match_bin     varchar(50) not null
)
engine = myisam;

insert into FeatureBin values
('pos','CC', 'com-dep-wd'),
('pos','CT', 'com-dep-wd'),
('pos','DT', 'com-dep-wd'),
('pos','EX', 'com-dep-wd'),
('pos','IN', 'com-dep-wd'),
('pos','MD', 'com-dep-wd'),
('pos','PDT', 'com-dep-wd'),
('pos','RP', 'com-dep-wd'),
('pos','TO', 'com-dep-wd'),
('pos','UH', 'com-dep-wd'),
('pos','WDT', 'com-dep-wd'),
('pos','FW', 'FW-Symb'),
('pos','SYM', 'FW-Symb'),
('pos','JJ', 'Adjectives'),
('pos','JJR', 'Adjectives'),
('pos','JJS', 'Adjectives'),
('pos','NN', 'Nouns'),
('pos','NNS', 'Nouns'),
('pos','NNP', 'Nouns'),
('pos','NNPS', 'Nouns'),
('pos','WRB', 'Adverbs'),
('pos','RB', 'Adverbs'),
('pos','RBR', 'Adverbs'),
('pos','RBS', 'Adverbs'),
('pos','VB', 'Verbs'),
('pos','VBD', 'Verbs'),
('pos','VBG', 'Verbs'),
('pos','VBN', 'Verbs'),
('pos','VBP', 'Verbs'),
('pos','VBZ', 'Verbs'),
('pos','PRP', 'Pronouns'),
('pos','PRP$', 'Pronouns'),
('pos','WP', 'Pronouns'),
('pos','WP$', 'Pronouns'),
('pos','CD', 'Numbers'),
('pos','LS', 'Numbers')
;

insert into FeatureBin values
('regex', 'HOSPITAL_1', 'hospital'),
('regex', 'HOSPITAL_2', 'hospital');


create temporary table temp_regex_list
(
match_value varchar(50) not null
);

insert into temp_regex_list values
('EMAIL_ADDRESS'),
('TELEPHONE2'),
('TELEPHONE3'),
('TELEPHONE0'),
('TELEPHONE1'),
('EXTENSION'),
('IP');

insert into FeatureBin select 'regex', match_value, 'phone' from temp_regex_list;
truncate temp_regex_list;

insert into temp_regex_list values
('WRITTEN_AGE_10_100_DIV10'),
('WRITTEN_AGE_110_TO_119'),
('WRITTEN_AGE_20_TO_99'),
('WRITTEN_AGE_1_TO_19'),
('AGE'),
('AGED_OVER'),
('AGE4'),
('AGE5'),
('AGE6'),
('AGE7'),
('AGE8');

insert into FeatureBin select 'regex', match_value, 'age' from temp_regex_list;
truncate temp_regex_list;

insert into temp_regex_list values
('DATE'),
('DATE1'),
('DATE2'),
('DATE3'),
('DATE4'),
('DATE5'),
('DATE5_U'),
('DATE6'),
('DATE7'),
('DATE8'),
('DATE9'),
('DATE11'),
('DATE12'),
('DATE13'),
('DATE14'),
('DATE15'),
('DATE16'),
('DATE17'),
('DATE18'),
('DATE19'),
('DATE20'),
('DATE21'),
('DATE22'),
('DATE_SEPARATORS'),
('YEAR_CENTURY'),
('MONTH'),
('MONTH2'),
('DISCHARGED'),
('DISCHARGED2'),
('DATE_23');

insert into FeatureBin select 'regex', match_value, 'date' from temp_regex_list;
truncate temp_regex_list;

insert into temp_regex_list values
('ADDRESS'),
('ADDRESS2'),
('ADDRESS4'),
('ADDRESS5'),
('ADDRESS6'),
('ADDRESS7'),
('ADDRESS8'),
('POBOX'),
('ROOM'),
('ZIP_CODE'),
('LOCATION_FLOOR_1'),
('LOCATION_FLOOR_2');

insert into FeatureBin select 'regex', match_value, 'address' from temp_regex_list;
truncate temp_regex_list;

insert into temp_regex_list values
('SURGEON'),
('SURGEON2'),
('SURGEON3'),
('SURGEON4'),
('SURGEON5'),
('SURGEON6'),
('SURGEON7'),
('SURGEON8'),
('ASST'),
('ASST2'),
('ASST3'),
('PA'),
('CC'),
('CC2'),
('FROM'),
('CONSULTATION'),
('TECH'),
('DOCTOR0_00'),
('DOCTOR0_0'),
('DOCTOR0_1'),
('DOCTOR0_2'),
('DOCTOR0'),
('DOCTOR1'),
('DOCTOR2'),
('DOCTOR3'),
('DOCTOR4'),
('DOCTOR_OLDER'),
('DOCTOR_GEN'),
('DOCTOR_SUBHEAD');

insert into FeatureBin select 'regex', match_value, 'doctor' from temp_regex_list;
truncate temp_regex_list;

insert into temp_regex_list values
('TITLES'),
('TITLE_THIRD'),
('PATIENT_NAME'),
('MR'),
('MS');


insert into FeatureBin select 'regex', match_value, 'patient' from temp_regex_list;
truncate temp_regex_list;

CALL log('FeatureBin', 'create is done');
call log('Step(2)',    'done');