QNLP
v1.0
|
Public Member Functions | |
def | create_table_discocat (self, table_name="qnlp") |
def | db_insert_discocat (self, values, dataset="basis", data_type="noun", table_name="qnlp") |
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 | |
Definition at line 13 of file DisCoCat.py.
|
inherited |
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.
|
inherited |
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().
|
inherited |
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.proc.DisCoCat.qdb_mixin.create_table_discocat | ( | self, | |
table_name = "qnlp" |
|||
) |
Create the database table for tagging the required data. The DB has columns for dataset ('basis' or 'corpus'), data_type ('verb', 'noun', etc.), token (the string value), mapping_idx (the index of the mapped binary value; for superpos states, this index labels the number of values in the superposition), map_bin_id (the binary value representing the quantum state in the register), map_coeff_r/i (real and imaginary coefficients of the map_bin_id state), mapping_dir (indicates the direction of the mapping; may not be used).
Definition at line 14 of file DisCoCat.py.
References QNLP.io.qnlp_db.qnlp_db.connect_db(), QNLP.proc.DisCoCat.qdb_mixin.create_table_discocat(), and QNLP.io.qnlp_db.qnlp_db.drop_table().
Referenced by QNLP.proc.DisCoCat.qdb_mixin.create_table_discocat(), and QNLP.proc.DisCoCat.qdb_mixin.db_insert_discocat().
|
inherited |
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.proc.DisCoCat.qdb_mixin.db_insert_discocat | ( | self, | |
values, | |||
dataset = "basis" , |
|||
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 49 of file DisCoCat.py.
References QNLP.io.qnlp_db.qnlp_db.connect_db(), and QNLP.proc.DisCoCat.qdb_mixin.create_table_discocat().
|
inherited |
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().
|
inherited |
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().
|
inherited |
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().
|
inherited |
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().
|
inherited |
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().
|
inherited |
Definition at line 15 of file qnlp_db.py.
|
inherited |
Definition at line 16 of file qnlp_db.py.