Exemplo n.º 1
0
    def db_select(db, ids=[]):
        DBObject.db_select(db, ids)

        rows = db.select(
            'segments',
            'id start_time end_time user_adj_start user_adj_end'.split(),
            DBObject._build_where_cond_from_ids(ids),
        )

        seg_list = []
        for cur_row in rows:
            speaker_rows = db.select(
                'segs_to_speaker_codes rel join speaker_codes sc on rel.speaker_code_id=sc.id',
                ['sc.code'],
                'rel.seg_id=?',
                [cur_row[0]],
            )

            #create the segment's speaker objects
            speaker_list = []
            for cur_speaker in speaker_rows:
                codeinfo = DBConstants.SPEAKER_CODES.get_option(cur_speaker[0])
                speaker = Speaker(None, codeinfo)
                speaker_list.append(speaker)

            seg = Segment(None, float(cur_row[1]), float(cur_row[2]),
                          speaker_list, [], cur_row[0], cur_row[3], cur_row[4])
            seg_list.append(seg)

        return seg_list
Exemplo n.º 2
0
    def db_select(db, ids=[]):
        DBObject.db_select(db, ids)

        #build the SQL where clause using the ids passed in
        where_cond = DBObject._build_where_cond_from_ids(ids)

        #do the select to retrieve the a list of raw data
        rows = db.select(
            'checks2',
            'csv_file wav_folder activities environments blocks_per_activity datetime(completed,\'localtime\') datetime(created,\'localtime\') datetime(modified,\'localtime\') test2_index id'
            .split(), where_cond)

        #create Check2 objects from the selected data and return them
        check2_list = []
        for cur_row in rows:
            #each check2 has zero or more Test2s, which can be retrieved using this static method
            test2s = Test2.db_select_by_check2(db, cur_row[9])

            check2 = Check2(
                cur_row[0],
                cur_row[1],
                #un-pickle the lists of activities and environments (the loads() call will return an instance of a list)
                pickle.loads(cur_row[2]),
                pickle.loads(cur_row[3]),
                cur_row[4],
                cur_row[5],
                cur_row[6],
                cur_row[7],
                test2s,
                cur_row[8],
                cur_row[9])

            check2_list.append(check2)

        return check2_list
Exemplo n.º 3
0
    def db_select(db, ids=[]):
        DBObject.db_select(db, ids)

        #select the output data from the outputs table
        rows = db.select(
            'outputs',
            'id name desc calc_class_name calc_args chained'.split(),
            DBObject._build_where_cond_from_ids(ids),
        )

        #create an Output object for each row
        output_list = []
        for cur_row in rows:
            #instantiate the OutputCalc object
            calc_class = eval(cur_row[3])
            calc_args = eval(cur_row[4])
            output_calc = calc_class(*calc_args)

            #instantiate any filter objects associated with this outputs
            filters = SegFilter.db_select_by_ref(
                db,
                'outputs_to_seg_filters',
                'seg_filter_id',
                'output_id',
                cur_row[0],
            )

            #create the Output object using the info retreived above
            output = Output(cur_row[1], cur_row[2], filters, output_calc,
                            cur_row[5], cur_row[0])

            output_list.append(output)

        return output_list
Exemplo n.º 4
0
    def db_select(db, ids=[]):
        DBObject.db_select(db, ids)

        #select the configs
        rows = db.select(
            'output_configs',
            "id name desc datetime(created,'localtime')".split(),
            DBObject._build_where_cond_from_ids(ids),
        )

        #construct the OutputConfig objects
        config_list = []
        for cur_row in rows:
            #select the corresponding Outputs for this config using a relationship table
            outputs = Output.db_select_by_ref(
                db,
                'output_configs_to_outputs',
                'output_id',
                'config_id',
                cur_row[0],
            )

            config = OutputConfig(
                cur_row[1],
                cur_row[2],
                outputs,
                cur_row[3],
                cur_row[0],
            )
            config_list.append(config)

        return config_list
Exemplo n.º 5
0
    def db_select(db, ids=[]):
        DBObject.db_select(ids)

        #select the test data
        rows = db.select(
            'tests',
            'id check_id category_input syllables_w_context syllables_wo_context segment_id is_uncertain context_padding'
            .split(), DBObject._build_where_cond_from_ids(ids))

        return Test._build_from_db_rows(db, rows)
Exemplo n.º 6
0
    def db_select_by_check2(db, check2_id):
        DBObject.db_select(db, [check2_id])

        rows = db.select(
            'tests2',
            'check2_id wav_file child_code spreadsheet_timestamp child_vocs transcription ui_save_data id'
            .split(),
            ' check2_id=?', [check2_id],
            order_by='id')

        return Test2._build_from_db_rows(rows)
Exemplo n.º 7
0
    def db_select(db, ids=[]):
        DBObject.db_select(db, ids)

        where_cond = DBObject._build_where_cond_from_ids(ids)

        rows = db.select(
            'tests2',
            'check2_id wav_file child_code spreadsheet_timestamp child_vocs transcription ui_save_data id'
            .split(), where_cond)

        return Test2._build_from_db_rows(rows)
Exemplo n.º 8
0
 def db_select(db, ids=[]):
     rows = db.select('seg_filters',
                      'id class_name args',
                      DBObject._build_where_cond_from_ids(ids),
                      )
     
     return SegFilter._reconstruct_from_db(rows)
Exemplo n.º 9
0
    def db_select(db, ids=[]):
        DBObject.db_select(db, ids)

        where_cond = None
        if ids:
            where_cond = DBObject._build_where_cond_from_ids(ids)

        rows = db.select(
            'pitch_study_props',
            'clips_db_path clips_dir_path max_parts_per_batch num_options break_interval inter_clip_sound_del id'
            .split(),
            where_cond=where_cond)

        props = []
        for cur_row in rows:
            props.append(PitchStudyProps(*cur_row))
        return props
Exemplo n.º 10
0
    def db_select(db, ids=[]):
        DBObject.db_select(db, ids)

        #build the SQL where clause using the ids passed in
        where_cond = None
        if ids:
            where_cond = DBObject._build_where_cond_from_ids(ids)

        #perform the select and create Check objects for each row
        rows = db.select(
            'checks',
            'name input_filename wav_filename num_segs default_context_padding test_index datetime(completed,\'localtime\') datetime(created,\'localtime\') id pick_randomly datetime(last_run,\'localtime\')'
            .split(), where_cond)
        checks = []
        for cur_row in rows:
            check_id = cur_row[8]
            #select the corresponding filters via a relation table
            filters = SegFilter.db_select_by_ref(db, 'checks_to_seg_filters',
                                                 'seg_filter_id', 'check_id',
                                                 check_id)

            tests = Test.db_select_by_check(db, cur_row[8])

            checks.append(
                Check(
                    cur_row[0],
                    cur_row[1],
                    cur_row[2],
                    cur_row[3],
                    cur_row[4],
                    tests,
                    cur_row[5],
                    datetime.strptime(cur_row[6], DBConstants.DB_DATETIME_FMT)
                    if cur_row[6] != None else None,
                    datetime.strptime(cur_row[7], DBConstants.DB_DATETIME_FMT)
                    if cur_row[7] != None else None,
                    cur_row[8],
                    pick_randomly=bool(int(cur_row[9])),
                    last_run=datetime.strptime(cur_row[10],
                                               DBConstants.DB_DATETIME_FMT)
                    if cur_row[10] != None else None,
                    filters=filters))

        return checks