create table README
(
   entity_topic  varchar(50) not null default '',
   entity_type   varchar(50) not null default '',
   entity_name   varchar(50) not null default '',
   example       text        not null default '',
   description   text        not null default ''
);

insert into README values
('README', 'version',  'SCRUBBER 3.1-SNAPSHOT', null, null),
('README', 'version',  'cTAKES 1.2.2',          null, null);

insert into README values
('global','','','',''),
('global', 'variable',  '@DATASET',   'select TEST into @DATASET',         '(TRAIN | TEST) select dataset'),
('global', 'variable',  '@CSV_DIR',   'select /tmp/mysql/ into @CSV_DIR',   'call csvwrite(table) '),
('global', 'variable',  '@LOG_LEVEL', 'select 1 into @LOG_LEVEL',          'turn on printing log to console');

insert into README values
('shell','','','',''),
('shell',  'procedure',  'mem',      'call mem', 'get schema +memory usage'),
('shell',  'procedure',  'ps',       'call ps',  'show current sql process'),
('shell',  'procedure',  'csvread',  'call csvread(WordToken)',  'csv->table'),
('shell',  'procedure',  'csvwrite', 'call csvwrite(WordToken)', 'table->csv');

insert into README values
('logging','','','',''),
('logging', 'table',     'log',   'call log | tail | etime', 'scrubber application log'),
('logging', 'procedure', 'log',   'call log (tablename, message)', 'add new log event'),
('logging', 'procedure', 'tail',  'call tail', 'print recent log events'),
('logging', 'procedure', 'etime', 'call etime', 'print elapsed time from log');

select    'desc table | csvread | csvwrite'   into @csv_readwrite;
select 'desc table | show index' into @desc_table;

insert into README values
('ctakes', '',  '', null,null),
('ctakes', 'uima',  'Annotation',    @csv_readwrite, 'UIMA base class'),
('ctakes', '->',    'Sentence',      @csv_readwrite, 'sequence of annotation tokens'),
('ctakes', '->',    'Calculation',   @csv_readwrite, 'TermFrequency'),
('ctakes', '->',    'OntologyMatch', @csv_readwrite, 'UMLS, Regex, and Private dictionaries'),
('ctakes', 'type',  'BaseToken',     @csv_readwrite, 'CTAKES base class'),
('ctakes', '->',    'NumToken',      @csv_readwrite, 'token is a number'),
('ctakes', '->',    'WordToken',     @csv_readwrite, 'token is a word');



select 'PHI| NA' into @class;
select 'Class ( NumToken | WordToken )' into @sample;
select 'Lexical | Stat | Pattern | Ontology' into @feature;

insert into README values
('Classification','','','',''),
('Classification', 'table',  'Class',            @desc_table, @class),
('Classification', 'table',  'Sample',           @desc_table, @sample),
('Classification', 'table',  'Feature',          @desc_table, @feature),
('Classification', 'table',  'FeatureBin',       @desc_table, 'POS | UMLS | regex'),
('Classification', 'table',  'FeatureMatrix',    @desc_table, '(row,col) = (Sample,Feature)'),
('Classification', 'table',  'FeatureMatrixOnt', @desc_table, '(row,col) = (Sample,OntologyMatch)');

select 'POS* | Capital | cTAKES*' into @lexical;

insert into README values
('Features','','','',''),
('Features', 'type', 'Feature',          @feature, null),
('Features', '->',   'Lexical',          @lexical, null),
('Features', '->',   'Lexical',          'POS*', 'Part of Speech (BIN)?'),
('Features', '->',   'Lexical',          'Capital', 'Token Capitalization'),
('Features', '->',   'Lexical',          'cTAKES*', '(context dependent)');

select 'TF* | TokenLength | BagOfWords' into @stat;

insert into README values
('Features', '->',   'Stat',          @stat, null),
('Features', '->',   'Stat',          'TF*', 'Term Frequency (POS)?'),
('Features', '->',   'Stat',          'TokenLength', 'length(token)'),
('Features', '->',   'Stat',          'BagOfWords', '#OntologyMatches per ontology');

select 'Beckwith Regular Expressions' into @pattern;

insert into README values
('Features', '->',   'Pattern',          null,  null),
('Features', '->',   'Pattern',          @pattern,  'Beckwith et al. 2006'),
('Features', '->',   'Pattern',          'custom',  'custom regex.list');

select 'UMLS | custom' into @ont;
select 'Hl7|ICD|LOINC|MESH|RXNORM|SNOMED|COSTAR' into @umls;

insert into README values
('Features', '->',   'Ontology',           null, null),
('Features', '->',   'Ontology',          'UMLS',   @umls);


-- TODO REFACTOR
-- insert into README values
-- ('Human', 'table',  'HumanAnnotation', 'REFACTOR', 'REFACTOR');

update README set example=''      where example is null;
update README set description=''  where description is null;
update README set entity_name=''  where entity_name is null;
update README set entity_topic='' where entity_topic is null;
