examples/text_to_sql/RAT-SQL/text2sql/utils/dusql_evaluation.py
def evaluate_one(self, db_id, gold_query, pred_query):
        """evaluate one predicted result, and cache evaluating info

        Args:
            db (TYPE): NULL
            gold_query (TYPE): NULL
            pred_query (TYPE): NULL

        Returns: TODO

        Raises: NULL
        """
        self.scores['all']['count'] += 1

        schema = self.schemas[db_id]
        kmap = self.foreign_key_maps[db_id]

        gold_query = gold_query.replace('==', '=')
        gold_sql = get_sql(schema, gold_query)
        # rebuild sql for value evaluation
        g_valid_col_units = build_valid_col_units(
            gold_sql['from']['table_units'], schema)
        gold_sql = rebuild_sql_col(g_valid_col_units, gold_sql, kmap,
                                   self.eval_value)

        is_parse_error = False
        try:
            pred_sql = get_sql(schema, pred_query)

            p_valid_col_units = build_valid_col_units(
                pred_sql['from']['table_units'], schema)
            pred_sql = rebuild_sql_col(p_valid_col_units, pred_sql, kmap,
                                       self.eval_value)
        except Exception as e:
            # If pred_sql is not valid, then we will use an empty sql to evaluate with the correct sql
            pred_sql = g_empty_sql
            self.eval_err_num += 1
            is_parse_error = True

        exact_score = self.eval_exact_match(pred_sql, gold_sql)
        if exact_score == 0:
            logging.debug("error instance %s:\npred: %s\ngold: %s" %
                          (db_id, pred_query, gold_query))
        self.scores['all']['exact'] += exact_score
        return {
            'gold': gold_query,
            'pred': pred_query,
            'correct': int(exact_score),
            'parse_error': int(is_parse_error)
        }
evaluate one predicted result, and cache evaluating info

        Args:
            db (TYPE): NULL
            gold_query (TYPE): NULL
            pred_query (TYPE): NULL

        Returns: TODO

        Raises: NULL
        
evaluate one predicted result, and cache evaluating info
evaluate one predicted result and cache evaluating info
def evaluate_one(self, db_id, gold_query, pred_query):
        self.scores['all']['count'] += 1
        schema = self.schemas[db_id]
        kmap = self.foreign_key_maps[db_id]
        gold_query = gold_query.replace('==', '=')
        gold_sql = get_sql(schema, gold_query)
        g_valid_col_units = build_valid_col_units(
            gold_sql['from']['table_units'], schema)
        gold_sql = rebuild_sql_col(g_valid_col_units, gold_sql, kmap,
                                   self.eval_value)
        is_parse_error = False
        try:
            pred_sql = get_sql(schema, pred_query)
            p_valid_col_units = build_valid_col_units(
                pred_sql['from']['table_units'], schema)
            pred_sql = rebuild_sql_col(p_valid_col_units, pred_sql, kmap,
                                       self.eval_value)
        except Exception as e:
            pred_sql = g_empty_sql
            self.eval_err_num += 1
            is_parse_error = True
        exact_score = self.eval_exact_match(pred_sql, gold_sql)
        if exact_score == 0:
            logging.debug("error instance %s:\npred: %s\ngold: %s" %
                          (db_id, pred_query, gold_query))
        self.scores['all']['exact'] += exact_score
        return {
            'gold': gold_query,
            'pred': pred_query,
            'correct': int(exact_score),
            'parse_error': int(is_parse_error)
        }
def evaluate_one ( self , db_id , gold_query , pred_query ) : self . scores [ 'all' ] [ 'count' ] += 1 schema = self . schemas [ db_id ] kmap = self . foreign_key_maps [ db_id ] gold_query = gold_query . replace ( '==' , '=' ) gold_sql = get_sql ( schema , gold_query ) g_valid_col_units = build_valid_col_units ( gold_sql [ 'from' ] [ 'table_units' ] , schema ) gold_sql = rebuild_sql_col ( g_valid_col_units , gold_sql , kmap , self . eval_value ) is_parse_error = False try : pred_sql = get_sql ( schema , pred_query ) p_valid_col_units = build_valid_col_units ( pred_sql [ 'from' ] [ 'table_units' ] , schema ) pred_sql = rebuild_sql_col ( p_valid_col_units , pred_sql , kmap , self . eval_value ) except Exception as e : pred_sql = g_empty_sql self . eval_err_num += 1 is_parse_error = True exact_score = self . eval_exact_match ( pred_sql , gold_sql ) if exact_score == 0 : logging . debug ( "error instance %s:\npred: %s\ngold: %s" % ( db_id , pred_query , gold_query ) ) self . scores [ 'all' ] [ 'exact' ] += exact_score return { 'gold' : gold_query , 'pred' : pred_query , 'correct' : int ( exact_score ) , 'parse_error' : int ( is_parse_error ) }
evaluate one predicted result, and cache evaluating info
evaluate one predicted result and cache evaluating info
"""evaluate one predicted result, and cache evaluating info

        Args:
            db (TYPE): NULL
            gold_query (TYPE): NULL
            pred_query (TYPE): NULL

        Returns: TODO

        Raises: NULL
        """ # rebuild sql for value evaluation # If pred_sql is not valid, then we will use an empty sql to evaluate with the correct sql
self
db_id
gold_query
None
pred_query
None
db
None