def populate_parses_from_files(file_names):
	rows = []
	for auto_parsed_file_name in file_names:
		print auto_parsed_file_name
		rows.extend(extract_rows(auto_parsed_file_name))
	con = sqlite3.connect('db_pdtb.sqlite', check_same_thread=False, 
			timeout=60.0 * 30, isolation_level="EXCLUSIVE")
	cur = con.cursor()
	print 'Writing %s rows' % len(rows)
	insert_rows(cur, 'parses', rows)
	con.commit()	
	print 'Finished writing %s rows' % len(rows)
def populate_relations_from_sections(section_numbers, predicate, table_name):
	"""Populate relation table

	This function makes it easy to selectively add tuples to table table_name
	that satisfies a predicate and comes from certain section numbers.
	The table has to be created before hand. 

	"""
	home = expanduser('~')
	corpus = CorpusReader('%s/nlp/wsj/python_pdtb/wsj_pdtb.jsons' % home)
	rows = []
	for relation in corpus.select(predicate):
		rows.append(make_row(relation))
	con = sqlite3.connect('db_pdtb.sqlite', check_same_thread = False, timeout=60.0 * 30, isolation_level='EXCLUSIVE')
	cur = con.cursor()
	insert_rows(cur, table_name, rows)
	con.commit()
def populate_relations_from_sections(section_numbers, predicate, table_name):
    """Populate relation table

	This function makes it easy to selectively add tuples to table table_name
	that satisfies a predicate and comes from certain section numbers.
	The table has to be created before hand. 

	"""
    home = expanduser('~')
    corpus = CorpusReader('%s/nlp/wsj/python_pdtb/wsj_pdtb.jsons' % home)
    rows = []
    for relation in corpus.select(predicate):
        rows.append(make_row(relation))
    con = sqlite3.connect('db_pdtb.sqlite',
                          check_same_thread=False,
                          timeout=60.0 * 30,
                          isolation_level='EXCLUSIVE')
    cur = con.cursor()
    insert_rows(cur, table_name, rows)
    con.commit()