The DBConsumer is an UIMA Annotation Engine that stores CAS annotatations and the XML CAS representation in the database.
The DBConsumer maps UIMA annotations to a relational database using a table per annotation class. Basically, a table exists for each UIMA annotation class. Primitive annotation attributes are mapped directly to table columns. Our strategy for mapping annotations to the database was to perform a 1-to-1 mapping: what you see in the database should correspond exactly to what you see in the UIMA CAS viewer.
Note that you must perform the additional YTEX installation tasks to use this component; this involves setting up a database (MySQL/Oracle/SQL Server).
Add the DBConsumer to the end of your pipeline, or add it to your CPE descriptor; the annotator configuration file is YTEX_HOME\desc\ctakes-ytex-uima\desc\analysis_engine\DBConsumer.xml
The DBConsumer UIMA Annotation Engine accepts the following configuration properties:
ref_uima_type table for a list of types stored in the database. The class name should give you an idea of what each annotation represents.anno_contain (below) for information on what this is.
For a graphical representation of document annotations, use the DBAnnotationViewer. This modified viewer retrieves the document CAS from the database (as opposed to the plain-vanilla AnnotationViewer which retrieves the CAS from the file system). To run, open a command prompt/shell, and run the following commands.
Windows:
cd CTAKES_HOME bin/setenv.bat java -cp lib/*;desc;resources org.apache.ctakes.ytex.tools.DBAnnotationViewerMain |
Linux:
cd CTAKES_HOME . bin/ctakes.profile java -cp lib/*;desc;resources org.apache.ctakes.ytex.tools.DBAnnotationViewerMain |
The document table represents a single note/document. The columns are
For each document processed, a document row is created.
An anno_base record represents an UIMA Annotation; there is a one-to-many relationship between document and anno_base. The columns are:
Annotation subclasses may have additional attributes; these attributes are stored in additional tables prefixed with anno_. E.g. additional attributes of the Sentence annotation are stored in the anno_sentence table. The primary key of these annotation subclass tables corresponds to the primary key of the anno_base table (i.e. it is also a foreign key).
This is mapped to the edu.mayo.bmi.uima.core.type.NumToken, edu.mayo.bmi.uima.core.type.WordToken, andytex.uima.types.WordToken annotations.
This is mapped to the cTAKES Medicationevent annotation.
In addition to Annotations, UIMA defines FeatureStructs; these are typically not 'free standing' annotations - they usually are 'inside' an Annotation. e.g. the Medicationevent and EntityMention annotations have arrays of OntologyConcepts. FeatureStructs are also mapped toanno_[subclass] tables, e.g. OntologyConcepts are mapped to the anno_ontology_concept table, and have a foreign key to the annotation 'within which' they reside (one-to-many relationship).
This is mapped to the cTAKES OntologyConceptArr of the Medicationevent or EntityMention annotation; these are the concepts (CUIs) of a Named Entity:
Metamap Candidate annotations are mapped to this table.
UIMA annotations can also have references to other UIMA annotations, e.g. the TreeBankNode annotation represents a node in a parse tree. This annotation has reference to a parent and children TreeBankNode annotations. Rows in the anno_link represent Annotation links
This table represents containment relationships between annotations, e.g. that a word/named entity is contained in a sentence. This has no direct equivalent in any UIMA object; these relationships can be inferred from the begin/end of UIMA annotations, but 'precomputing' these relationships has many practical applications; e.g. it simplfies writing queries of the sort 'give me all named entities in the Impression section'.
Mapping of Annotations is purely configurative. To map a new annotation do the following:
To illustrate this, say for example we would like to map your annotation named Foo that has a 'period' has the float attribute period. We would create a table for this annotation, e.g. for mysql:
create table anno_foo (
anno_base_id int not null primary key, /* foreign key to anno_base */
period double
) engine=myisam;
Note: the column names must match the UIMA annotation's attribute names (case insensitive).
And we need to tell YTEX to map Foos to this table:
insert into ref_uima_type (uima_type_id, uima_type_name, table_name)
values (201, 'org.acme.Foo', 'anno_foo');
This table tells YTEX what annotations to map, and the tables to map them to:
This is a spring bean configuration file that allows more mapping customization, e.g. mapping attributes to columns with different names.
Below an entity-relationship diagram
