def add_kb_mapping(kb_name, key, value=""): """ Adds a new mapping to given kb @param kb_name: the name of the kb where to insert the new value @param key: the key of the mapping @param value: the value of the mapping """ bibknowledge_dblayer.add_kb_mapping(kb_name, key, value)
def add_kb_values(kbname, kbfile): """ Given a KB name and path to a tab-delimited KB file, this function will insert all entries in the file into to the corresponding KB table in the database. """ num_added = 0 kb_fd = open(kbfile) for line in kb_fd: splitted_line = line.split('\t') pair = [] for part in splitted_line: if not part.strip(): # We can ignore this one continue pair.append(part.strip()) if len(pair) != 2: print "Error: %s" % (str(pair),) add_kb_mapping(kbname, pair[0], pair[1]) num_added += 1 kb_fd.close() return num_added
def add_kb_values(kbname, kbfile): """ Given a KB name and path to a tab-delimited KB file, this function will insert all entries in the file into to the corresponding KB table in the database. """ num_added = 0 kb_fd = open(kbfile) for line in kb_fd: splitted_line = line.split('\t') pair = [] for part in splitted_line: if not part.strip(): # We can ignore this one continue pair.append(part.strip()) if len(pair) != 2: print "Error: %s" % (str(pair), ) add_kb_mapping(kbname, pair[0], pair[1]) num_added += 1 kb_fd.close() return num_added