| 
    QNLP
    v1.0
    
   | 
 


Public Member Functions | |
| def | __init__ (self, db_name, db_path) | 
| def | create_table (self, table_name="qnlp") | 
| def | drop_table (self, table_name="qnlp") | 
| def | connect_db (self) | 
| def | close_db (self) | 
| def | db_insert (self, Dict values, data_type="noun", table_name="qnlp") | 
| def | db_load (self, data_type="noun", table_name="qnlp", direction="forward") | 
| def | db_print (self, table_name="qnlp") | 
Data Fields | |
| db_name | |
| db_path | |
| db_full_path | |
| db_conn | |
Class for providing DB access and output from the corpus tagging operations. The resulting file will then be loadable using the C++ QNLP code.
Definition at line 9 of file qnlp_db.py.
| def QNLP.io.qnlp_db.qnlp_db.__init__ | ( | self, | |
| db_name, | |||
| db_path | |||
| ) | 
Definition at line 14 of file qnlp_db.py.
| def QNLP.io.qnlp_db.qnlp_db.close_db | ( | self | ) | 
If there is an active connection, close it.
Definition at line 85 of file qnlp_db.py.
References QNLP.io.qnlp_db.qnlp_db.db_conn, and QNLP.io.qnlp_db.qnlp_db.db_full_path.
| def QNLP.io.qnlp_db.qnlp_db.connect_db | ( | self | ) | 
If there is an active DB connection, return it. If not, create one.
Definition at line 71 of file qnlp_db.py.
References QNLP.io.qnlp_db.qnlp_db.db_conn, and QNLP.io.qnlp_db.qnlp_db.db_full_path.
Referenced by QNLP.io.qnlp_db.qnlp_db.create_table(), QNLP.proc.DisCoCat.qdb_mixin.create_table_discocat(), QNLP.io.qnlp_db.qnlp_db.db_insert(), QNLP.proc.DisCoCat.qdb_mixin.db_insert_discocat(), QNLP.io.qnlp_db.qnlp_db.db_load(), QNLP.io.qnlp_db.qnlp_db.db_print(), and QNLP.io.qnlp_db.qnlp_db.drop_table().

| def QNLP.io.qnlp_db.qnlp_db.create_table | ( | self, | |
table_name = "qnlp"  | 
        |||
| ) | 
Create the database table for tagging the required data. The DB has columns for type (noun, verb, etc.), bin_id (binary string representing the type), weight (calculable from frequency of occurrence relative to other terms), and mapping_dir (1 indicates string to bin_id, or -1 bin_id to string mapping).
Definition at line 22 of file qnlp_db.py.
References QNLP.io.qnlp_db.qnlp_db.connect_db(), QNLP.io.qnlp_db.qnlp_db.create_table(), and QNLP.io.qnlp_db.qnlp_db.drop_table().
Referenced by QNLP.io.qnlp_db.qnlp_db.create_table(), and QNLP.io.qnlp_db.qnlp_db.db_insert().


| def QNLP.io.qnlp_db.qnlp_db.db_insert | ( | self, | |
| Dict | values, | ||
data_type = "noun",  | 
        |||
table_name = "qnlp"  | 
        |||
| ) | 
Insert the tag to binary encoding mapping into the DB. values -- Dict mapping string to binary value, and binary value to string. data_type -- String to indicate the type of data to be stored table_name -- Name of table to store in DB
The DB insert operation below assumes the value field of a key in DB is a tuple, containing (binary_id, weight of occurrence), where weight of occurrence cant be determined by the proximity of the word to other words; essentially a count in the simplest case. The mapping checks to see if the index is convertible to a numeric type. If so, this will imply the reverse mapping (ie qubit result to string val), and is indicated by -1. Otherwise, this will be a forward mapping, and given by 1.
Definition at line 94 of file qnlp_db.py.
References QNLP.io.qnlp_db.qnlp_db.connect_db(), and QNLP.io.qnlp_db.qnlp_db.create_table().

| def QNLP.io.qnlp_db.qnlp_db.db_load | ( | self, | |
data_type = "noun",  | 
        |||
table_name = "qnlp",  | 
        |||
direction = "forward"  | 
        |||
| ) | 
Load the tag to binary encoded mapping into from DB. data_type -- Data type to load from the DB (noun, verb, etc) table_name -- Database table to load data direction -- Direction of the returned mapping (forward: tag -> int, reverse: int -> tag)
Definition at line 128 of file qnlp_db.py.
References QNLP.io.qnlp_db.qnlp_db.connect_db().

| def QNLP.io.qnlp_db.qnlp_db.db_print | ( | self, | |
table_name = "qnlp"  | 
        |||
| ) | 
Prints all the available data stored in the DB
Definition at line 159 of file qnlp_db.py.
References QNLP.io.qnlp_db.qnlp_db.connect_db().

| def QNLP.io.qnlp_db.qnlp_db.drop_table | ( | self, | |
table_name = "qnlp"  | 
        |||
| ) | 
Drops the table if it exists.
Definition at line 57 of file qnlp_db.py.
References QNLP.io.qnlp_db.qnlp_db.connect_db().
Referenced by QNLP.io.qnlp_db.qnlp_db.create_table(), and QNLP.proc.DisCoCat.qdb_mixin.create_table_discocat().


| QNLP.io.qnlp_db.qnlp_db.db_conn | 
Definition at line 18 of file qnlp_db.py.
Referenced by QNLP.io.qnlp_db.qnlp_db.close_db(), and QNLP.io.qnlp_db.qnlp_db.connect_db().
| QNLP.io.qnlp_db.qnlp_db.db_full_path | 
Definition at line 17 of file qnlp_db.py.
Referenced by QNLP.io.qnlp_db.qnlp_db.close_db(), and QNLP.io.qnlp_db.qnlp_db.connect_db().
| QNLP.io.qnlp_db.qnlp_db.db_name | 
Definition at line 15 of file qnlp_db.py.
| QNLP.io.qnlp_db.qnlp_db.db_path | 
Definition at line 16 of file qnlp_db.py.