def make_row(relation):
    """Make a tuple from a relation object
	
	This tuple factory assumes the schema to have specific fields.
	"""
    arg1_span = (relation.arg1.selection.span_ranges[0][0],
                 relation.arg1.selection.span_ranges[-1][1])
    arg2_span = (relation.arg2.selection.span_ranges[0][0],
                 relation.arg2.selection.span_ranges[-1][1])

    arg1_sentence_id, _ = locate_sentence(arg1_span, relation.wsj_section,
                                          'db_pdtb.sqlite')
    arg2_sentence_id, _ = locate_sentence(arg2_span, relation.wsj_section,
                                          'db_pdtb.sqlite')

    try:
        row = {
            'wsj_section': relation.wsj_section_number,
            'wsj_id': relation.wsj_section,
            'arg1_sentence_id': arg1_sentence_id,
            'arg2_sentence_id': arg2_sentence_id,
            'relation_json': str(relation),
            'sense': relation.relation_sense_tags(1)[0],
            'relation_type': relation.type
        }
    except Exception as e:
        print relation
        raise e
    return row
def make_row(relation):
	"""Make a tuple from a relation object
	
	This tuple factory assumes the schema to have specific fields.
	"""
	arg1_span = (relation.arg1.selection.span_ranges[0][0],
		relation.arg1.selection.span_ranges[-1][1])
	arg2_span = (relation.arg2.selection.span_ranges[0][0],
		relation.arg2.selection.span_ranges[-1][1])

	arg1_sentence_id, _ = locate_sentence(arg1_span, relation.wsj_section, 'db_pdtb.sqlite')
	arg2_sentence_id, _ = locate_sentence(arg2_span, relation.wsj_section, 'db_pdtb.sqlite')

	try:
		row = {
			'wsj_section': relation.wsj_section_number,
			'wsj_id': relation.wsj_section,
			'arg1_sentence_id': arg1_sentence_id,
			'arg2_sentence_id': arg2_sentence_id,
			'relation_json': str(relation),
			'sense': relation.relation_sense_tags(1)[0],
			'relation_type': relation.type
		}
	except Exception as e:
		print relation
		raise e
	return row
def test():
    assert_eq(locate_sentence((95, 110), '0001'), 1)
    populate_all_relations_from_sections([0])
def test():
	assert_eq(locate_sentence((95,110), '0001'), 1)
	populate_all_relations_from_sections([0])