id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
163,348
from __future__ import absolute_import, division, print_function, unicode_literals import collections import json import logging import os import regex as re import sys import unicodedata The provided code snippet includes necessary dependencies for implementing the `load_vocab` function. Write a Python function `def ...
Loads a vocabulary file into a dictionary.
163,349
from __future__ import absolute_import, division, print_function, unicode_literals import collections import json import logging import os import regex as re import sys import unicodedata The provided code snippet includes necessary dependencies for implementing the `whitespace_tokenize` function. Write a Python funct...
Runs basic whitespace cleaning and splitting on a piece of text.
163,350
from __future__ import absolute_import, division, print_function, unicode_literals import collections import json import logging import os import regex as re import sys import unicodedata The provided code snippet includes necessary dependencies for implementing the `_is_whitespace` function. Write a Python function `...
Checks whether `chars` is a whitespace character.
163,351
from __future__ import absolute_import, division, print_function, unicode_literals import collections import json import logging import os import regex as re import sys import unicodedata The provided code snippet includes necessary dependencies for implementing the `_is_control` function. Write a Python function `def...
Checks whether `chars` is a control character.
163,352
from __future__ import absolute_import, division, print_function, unicode_literals import collections import json import logging import os import regex as re import sys import unicodedata The provided code snippet includes necessary dependencies for implementing the `_is_punctuation` function. Write a Python function ...
Checks whether `chars` is a punctuation character.
163,353
from __future__ import absolute_import, division, print_function, unicode_literals import collections import json import logging import os import regex as re import sys import unicodedata def lru_cache(): return lambda func: func
null
163,354
from __future__ import absolute_import, division, print_function, unicode_literals import collections import json import logging import os import regex as re import sys import unicodedata The provided code snippet includes necessary dependencies for implementing the `bytes_to_unicode` function. Write a Python function...
Returns list of utf-8 byte and a corresponding list of unicode strings. The reversible bpe codes work on unicode strings. This means you need a large # of unicode characters in your vocab if you want to avoid UNKs. When you're at something like a 10B token dataset you end up needing around 5K for decent coverage. This ...
163,355
from __future__ import absolute_import, division, print_function, unicode_literals import collections import json import logging import os import regex as re import sys import unicodedata The provided code snippet includes necessary dependencies for implementing the `get_pairs` function. Write a Python function `def g...
Return set of symbol pairs in a word. Word is represented as tuple of symbols (symbols being variable-length strings).
163,356
from itertools import chain import json import numpy as np import pickle import time import subprocess as sp from tqdm import tqdm from galaxy.args import str2bool from galaxy.data.tokenizer import Tokenizer def max_lens(X): lens = [len(X)] while isinstance(X[0], list): lens.append(max(map(len, X))) ...
null
163,357
from itertools import chain import json import numpy as np import pickle import time import subprocess as sp from tqdm import tqdm from galaxy.args import str2bool from galaxy.data.tokenizer import Tokenizer def _get_file_len(corpus): n_line = int(sp.check_output(f"wc -l {corpus}".split(), ...
null
163,358
import os import random from collections import OrderedDict, defaultdict from itertools import chain import json import sqlite3 as sql import numpy as np import spacy from tqdm import tqdm from nltk.tokenize import word_tokenize as nltk_word_tokenize from nltk.stem import WordNetLemmatizer from galaxy.args import str2b...
null
163,360
import argparse import json class HParams(dict): """ Hyper-parameters class Store hyper-parameters in training / infer / ... scripts. """ def __getattr__(self, name): if name in self.keys(): return self[name] for v in self.values(): if isinstance(v, HParams): ...
Parse hyper-parameters from cmdline.
163,361
import json import logging import os import sys import time from collections import OrderedDict import torch import numpy as np from tqdm import tqdm from transformers.optimization import AdamW, get_linear_schedule_with_warmup from galaxy.args import str2bool from galaxy.data.data_loader import DataLoader from galaxy.m...
null
163,362
import logging import os import sys import time from collections import OrderedDict import torch import numpy as np from transformers.optimization import AdamW, get_linear_schedule_with_warmup from galaxy.args import str2bool from galaxy.data.data_loader import DataLoader from galaxy.metrics.metrics_tracker import Metr...
null
163,363
import math import torch import numpy as np from galaxy.args import str2bool def repeat(var, times): if isinstance(var, list): return [repeat(x, times) for x in var] elif isinstance(var, dict): return {k: repeat(v, times) for k, v in var.items()} elif isinstance(var, torch.Tensor): ...
null
163,364
import math import torch import numpy as np from galaxy.args import str2bool def gather(var, idx): if isinstance(var, list): return [gather(x, idx) for x in var] elif isinstance(var, dict): return {k: gather(v, idx) for k, v in var.items()} elif isinstance(var, torch.Tensor): out = ...
null
163,365
import logging import json import numpy as np from collections import OrderedDict from galaxy.utils import ontology def clean_replace(s, r, t, forward=True, backward=False): def clean_replace_single(s, r, t, forward, backward, sidx=0): # idx = s[sidx:].find(r) idx = s.find(r) if idx == -1: ...
null
163,366
import logging import json import numpy as np from collections import OrderedDict from galaxy.utils import ontology def py2np(list): return np.array(list)
null
163,367
import logging import json import numpy as np from collections import OrderedDict from galaxy.utils import ontology def write_dict(fn, dic): with open(fn, 'w') as f: json.dump(dic, f, indent=2)
null
163,368
def get_special_tokens(data_name): if data_name == 'multiwoz': db_tokens = ['<sos_db>', '<eos_db>', '[db_nores]', '[db_0]', '[db_1]', '[db_2]', '[db_3]', '[book_nores]', '[book_fail]', '[book_success]'] special_tokens = ['<go_r>', '<go_b>', '<go_a>', ...
null
163,369
import torch from torch.nn.modules.loss import _Loss import torch.nn.functional as F def compute_kl_loss(p, q, filter_scores=None): p_loss = F.kl_div(F.log_softmax(p, dim=-1), F.softmax(q, dim=-1), reduction='none') q_loss = F.kl_div(F.log_softmax(q, dim=-1), F.softmax(p, dim=-1), reduction='none') # You ...
null
163,370
import re from galaxy.utils import ontology def my_clean_text(text): text = re.sub(r'([a-zT]+)\.([a-z])', r'\1 . \2', text) # 'abc.xyz' -> 'abc . xyz' text = re.sub(r'(\w+)\.\.? ', r'\1 . ', text) # if 'abc. ' -> 'abc . ' return text
null
163,371
import json import math from collections import Counter import numpy as np from nltk.util import ngrams from sklearn.metrics import f1_score from galaxy.utils import ontology, utils from galaxy.utils.clean_dataset import clean_slot_values def setsub(a,b): def setsim(a,b): a,b = set(a),set(b) return setsub(a,b)...
null
163,372
import json import math from collections import Counter import numpy as np from nltk.util import ngrams from sklearn.metrics import f1_score from galaxy.utils import ontology, utils from galaxy.utils.clean_dataset import clean_slot_values def DAEvaluation(preds, labels): preds = np.array(preds) labels = np.arr...
null
163,373
from typing import Dict, Any from third_party.sparc.evaluation import * def evaluate(glist, plist, db_dir, etype, kmaps): def compute_interaction_metric(predictions, references) -> Dict[str, Any]: foreign_key_maps = dict() for reference in references: if reference["db_id"] not in foreign_key_maps: ...
null
163,374
from typing import Dict, Any from third_party.spider import evaluation as spider_evaluation def compute_exact_match_metric(predictions, references) -> Dict[str, Any]: foreign_key_maps = dict() for reference in references: if reference["db_id"] not in foreign_key_maps: foreign_key_maps[refer...
null
163,375
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,376
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,377
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,378
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,379
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,380
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,381
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,382
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,383
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,384
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,385
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,388
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,392
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,395
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,396
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,398
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,399
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,402
import os import math from typing import Dict from copy import deepcopy import numpy as np from datasets import DatasetDict from random import shuffle from torch.utils.data import Dataset, ConcatDataset from torch.utils.data.dataset import T_co from utils.configue import Configure def upsample(data, weight): n_dat...
null
163,405
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,406
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,408
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,416
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,418
import os import torch import random import math import re import numpy as np from copy import deepcopy from typing import List, Dict from datasets.dataset_dict import DatasetDict from torch.utils.data import Dataset from torch.utils.data.dataset import T_co from third_party.miscs.bridge_content_encoder import get_data...
null
163,434
import json import sqlite3 from nltk import word_tokenize def get_schema_from_json(fpath): with open(fpath) as f: data = json.load(f) schema = {} for entry in data: table = str(entry['table'].lower()) cols = [str(col['column_name'].lower()) for col in entry['col_data']] sch...
null
163,436
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def condition_has_or(conds): return 'or' in conds[1::2]
null
163,437
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql WHERE_OPS = ('not', 'between', '=', '>', '<', '>=', '<=', '!=', 'in', 'like', 'is', 'exists') def condition_has_like(conds): return WHERE_OPS.index('like'...
null
163,438
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def condition_has_sql(conds): for cond_unit in conds[::2]: val1, val2 = cond_unit[3], cond_unit[4] if val1 is not None and type(val1) is d...
null
163,439
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql UNIT_OPS = ('none', '-', '+', "*", '/') def val_has_op(val_unit): return val_unit[0] != UNIT_OPS.index('none')
null
163,440
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def accuracy(count, total): if count == total: return 1 return 0
null
163,441
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def recall(count, total): if count == total: return 1 return 0
null
163,442
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def F1(acc, rec): if (acc + rec) == 0: return 0 return (2. * acc * rec) / (acc + rec)
null
163,443
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def get_scores(count, pred_total, label_total): if pred_total != label_total: return 0,0,0 elif count == pred_total: return 1,1,1 ...
null
163,444
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def eval_sel(pred, label): pred_sel = pred['select'][1] label_sel = label['select'][1] label_wo_agg = [unit[1] for unit in label_sel] pred_tot...
null
163,445
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def eval_where(pred, label): pred_conds = [unit for unit in pred['where'][::2]] label_conds = [unit for unit in label['where'][::2]] label_wo_agg ...
null
163,446
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def eval_group(pred, label): pred_cols = [unit[1] for unit in pred['groupBy']] label_cols = [unit[1] for unit in label['groupBy']] pred_total = le...
null
163,447
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def eval_having(pred, label): pred_total = label_total = cnt = 0 if len(pred['groupBy']) > 0: pred_total = 1 if len(label['groupBy']) > 0:...
null
163,448
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def eval_order(pred, label): pred_total = label_total = cnt = 0 if len(pred['orderBy']) > 0: pred_total = 1 if len(label['orderBy']) > 0: ...
null
163,449
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def eval_and_or(pred, label): pred_ao = pred['where'][1::2] label_ao = label['where'][1::2] pred_ao = set(pred_ao) label_ao = set(label_ao) ...
null
163,450
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def eval_nested(pred, label): label_total = 0 pred_total = 0 cnt = 0 if pred is not None: pred_total += 1 if label is not None: ...
null
163,451
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def get_keywords(sql): res = set() if len(sql['where']) > 0: res.add('where') if len(sql['groupBy']) > 0: res.add('group') if l...
null
163,452
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql WHERE_OPS = ('not', 'between', '=', '>', '<', '>=', '<=', '!=', 'in', 'like', 'is', 'exists') def count_component1(sql): count = 0 if len(sql['where']...
null
163,453
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def get_nestedSQL(sql): def count_component2(sql): nested = get_nestedSQL(sql) return len(nested)
null
163,454
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def count_agg(units): return len([unit for unit in units if has_agg(unit)]) def count_others(sql): count = 0 # number of aggregation agg_count...
null
163,455
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def isValidSQL(sql, db): conn = sqlite3.connect(db) cursor = conn.cursor() try: cursor.execute(sql) except: return False r...
null
163,456
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql class Evaluator: """A simple evaluator""" def __init__(self): self.partial_scores = None def eval_hardness(self, sql): count_comp1_...
null
163,457
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def build_foreign_key_map(entry): cols_orig = entry["column_names_original"] tables_orig = entry["table_names_original"] # rebuild cols correspondi...
null
163,458
import json import sqlite3 from nltk import word_tokenize The provided code snippet includes necessary dependencies for implementing the `get_schema` function. Write a Python function `def get_schema(db)` to solve the following problem: Get database's schema, which is a dict with table name as key and list of column n...
Get database's schema, which is a dict with table name as key and list of column names as value :param db: database path :return: schema dict
163,461
import json import sqlite3 from nltk import word_tokenize def tokenize(string): string = str(string) string = string.replace( "'", '"' ) # ensures all string values wrapped by "" problem?? quote_idxs = [idx for idx, char in enumerate(string) if char == '"'] assert len(quote_idxs) % 2 == 0, ...
null
163,462
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def condition_has_or(conds): return "or" in conds[1::2]
null
163,463
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql WHERE_OPS = ( "not", "between", "=", ">", "<", ">=", "<=", "!=", "in", "like", "is", "exists", ) def condition...
null
163,465
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql UNIT_OPS = ("none", "-", "+", "*", "/") def val_has_op(val_unit): return val_unit[0] != UNIT_OPS.index("none")
null
163,468
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def F1(acc, rec): if (acc + rec) == 0: return 0 return (2.0 * acc * rec) / (acc + rec)
null
163,469
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def get_scores(count, pred_total, label_total): if pred_total != label_total: return 0, 0, 0 elif count == pred_total: return 1, 1, 1 ...
null
163,470
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def eval_sel(pred, label): pred_sel = pred["select"][1] label_sel = label["select"][1] label_wo_agg = [unit[1] for unit in label_sel] pred_tot...
null
163,471
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def eval_where(pred, label): pred_conds = [unit for unit in pred["where"][::2]] label_conds = [unit for unit in label["where"][::2]] label_wo_agg ...
null
163,472
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def eval_group(pred, label): pred_cols = [unit[1] for unit in pred["groupBy"]] label_cols = [unit[1] for unit in label["groupBy"]] pred_total = le...
null
163,473
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def eval_having(pred, label): pred_total = label_total = cnt = 0 if len(pred["groupBy"]) > 0: pred_total = 1 if len(label["groupBy"]) > 0:...
null
163,474
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def eval_order(pred, label): pred_total = label_total = cnt = 0 if len(pred["orderBy"]) > 0: pred_total = 1 if len(label["orderBy"]) > 0: ...
null
163,475
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def eval_and_or(pred, label): pred_ao = pred["where"][1::2] label_ao = label["where"][1::2] pred_ao = set(pred_ao) label_ao = set(label_ao) ...
null
163,476
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def eval_nested(pred, label): label_total = 0 pred_total = 0 cnt = 0 if pred is not None: pred_total += 1 if label is not None: ...
null
163,477
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def get_keywords(sql): res = set() if len(sql["where"]) > 0: res.add("where") if len(sql["groupBy"]) > 0: res.add("group") if l...
null
163,478
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql WHERE_OPS = ( "not", "between", "=", ">", "<", ">=", "<=", "!=", "in", "like", "is", "exists", ) def count_com...
null
163,480
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def count_agg(units): return len([unit for unit in units if has_agg(unit)]) def count_others(sql): count = 0 # number of aggregation agg_count...
null
163,481
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def update_scores_match(scores, exact_score, hardness, partial_scores, partial_types): scores[hardness]["exact"] += exact_score scores["all"]["exact"]...
null
163,483
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql class Evaluator: """A simple evaluator""" def __init__(self, db_dir, kmaps, etype): self.db_dir = db_dir self.kmaps = kmaps s...
null
163,484
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql The provided code snippet includes necessary dependencies for implementing the `eval_exec_match` function. Write a Python function `def eval_exec_match(db, p_...
return 1 if the values between prediction and gold are matching in the corresponding index. Currently not support multiple col_unit(pairs).
163,485
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql TABLE_TYPE = { "sql": "sql", "table_unit": "table_unit", } def build_valid_col_units(table_units, schema): col_ids = [ table_unit[1] ...
null
163,486
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def rebuild_condition_col(valid_col_units, condition, kmap): for idx in range(len(condition)): if idx % 2 == 0: condition[idx] = rebuil...
null
163,487
import os, sys import json import sqlite3 import traceback import argparse from .process_sql import tokenize, get_schema, get_tables_with_alias, Schema, get_sql def build_foreign_key_map(entry): # print("entry in build_foreign_key_map: ", entry) cols_orig = entry["column_names_original"] tables_orig = entry...
null
163,488
import json def _get_schemas_from_json(data: dict): db_names = [db["db_id"] for db in data] tables = {} schemas = {} for db in data: db_id = db["db_id"] schema = {} # {'table': [col.lower, ..., ]} * -> __all__ column_names_original = db["column_names_original"] table_nam...
null
163,489
import copy import math import random import warnings from typing import Optional, Tuple import torch import torch.utils.checkpoint from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.bart.configuration_bart import BartConfig from transformers.activations import ACT2FN from tran...
Shift input ids one token to the right.
163,490
import copy import math import random import warnings from typing import Optional, Tuple import torch import torch.utils.checkpoint from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.bart.configuration_bart import BartConfig from transformers.activations import ACT2FN from tran...
Make causal mask used for bi-directional self-attention.
163,491
import copy import math import random import warnings from typing import Optional, Tuple import torch import torch.utils.checkpoint from torch import nn from torch.nn import CrossEntropyLoss, MSELoss from transformers.models.bart.configuration_bart import BartConfig from transformers.activations import ACT2FN from tran...
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
163,492
import copy import math import os import warnings import torch from torch import nn from torch.nn import CrossEntropyLoss from torch.utils.checkpoint import checkpoint from transformers.activations import ACT2FN from transformers.file_utils import ( DUMMY_INPUTS, DUMMY_MASK, add_start_docstrings, add_st...
Load tf checkpoints in a pytorch model.