query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Splits data into train, dev, and test sets and saves these into separate directories.
def split_train_test_dev(self): for dir_name in (self.config.train_dir, self.config.dev_dir, self.config.test_dir): create_dir(dir_name) self.split_helper(self.config.parsed_train_file_pos, 'pos') self.split_helper(self.config.parsed_train_file_neg, 'neg')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def MakeDataSetFiles(dirname):\n\n\n if not os.path.exists(dirname):\n os.mkdir(dirname)\n if not os.path.exists(os.path.join(dirname, 'train')):\n os.mkdir(os.path.join(dirname, 'train'))\n if not os.path.exists(os.path.join(dirname, 'test')):\n os.mkdir(os.path.join(dirname, 'test'))\n data_train = ...
[ "0.7316146", "0.71866006", "0.7114873", "0.7022753", "0.68888664", "0.6882073", "0.6838386", "0.6802326", "0.67861754", "0.6763696", "0.6753951", "0.6730403", "0.6691835", "0.6685175", "0.66725105", "0.6671246", "0.6665487", "0.66565126", "0.6647751", "0.660803", "0.66024566"...
0.80809546
0
Yields sequence, sequence length, count of unique tokens from input file. Reads file from beginning after reaching the end.
def train_sample_generator(self, fi): while True: line = fi.readline() if not line: fi.seek(0) continue sequence = np.array(line.split(" "), dtype=np.intp) yield sequence, sequence.shape[0], np.unique(sequence).shape[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_counts(counts_file):\n try:\n fi = open(counts_file, 'r')\n except IOError:\n sys.stderr.write('ERROR: Cannot open %s.\\n' % counts_file)\n sys.exit(1)\n\n for line in fi:\n fields = line.strip().split(' ')\n yield fields # yields a list of fields", "def solve...
[ "0.63293844", "0.6184904", "0.5920593", "0.5848726", "0.58256215", "0.58110034", "0.576691", "0.5766602", "0.57536906", "0.57464147", "0.5743451", "0.5698512", "0.56470245", "0.5639647", "0.5633243", "0.5612199", "0.56089216", "0.5563795", "0.55498075", "0.5525601", "0.551029...
0.5979231
2
Yields sequence, sequence length, and label from input file.
def dev_sample_generator(self, fi): for line in fi: line_list = line.split(" ") label = int(line_list[-1]) sequence = np.array(line_list[:-1], dtype=np.intp) yield sequence, sequence.shape[0], np.unique(sequence).shape[0], label
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fasta(path):\n label = None\n sequence = None\n with open(path, 'r') as data:\n for line in data:\n line = line.strip()\n if line.startswith('>'):\n if label and sequence:\n yield (label, sequence)\n label = line[1:]\n ...
[ "0.68528914", "0.6591686", "0.6564022", "0.64176744", "0.6332086", "0.62952423", "0.62774473", "0.620664", "0.6127451", "0.6097349", "0.60575753", "0.5990235", "0.5986205", "0.591602", "0.5905646", "0.58811617", "0.58803195", "0.5848473", "0.58155936", "0.580522", "0.5799044"...
0.643483
3
Yields sequence, sequence length from input file.
def predict_sample_generator(self, fi): for line in fi: sequence = np.array(line.split(" "), dtype=np.intp) yield sequence, sequence.shape[0], np.unique(sequence).shape[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fasta_read_generator(file_handler):\r\n seq = []\r\n name = ''\r\n for line in file_handler:\r\n if line[0] == '>':\r\n sequence = ''.join(seq)\r\n if name: # only yield when we already have all data for the first sequence\r\n yield name, sequence\r\n ...
[ "0.67658085", "0.6689718", "0.66688454", "0.6580756", "0.65676934", "0.65368074", "0.6521221", "0.65069735", "0.646596", "0.645717", "0.6447958", "0.6339892", "0.6260382", "0.61856395", "0.6143909", "0.61225396", "0.6086098", "0.6078724", "0.60098237", "0.5990917", "0.5990292...
0.62304157
13
Generates train batches by randomly selecting labels from both classes to avoid imbalance. Yields
def train_batch_generator(self): seq_lengths = np.zeros((self.batch_size), dtype=np.intp) unique_count = np.zeros((self.batch_size), dtype=np.intp) fis = (self.config.train_dir + "pos.txt", self.config.train_dir + "neg.txt") fi_pos, fi_neg = map(open, fis) sample_g...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sample_train_batch(self):\r\n batch = []\r\n labels =[]\r\n num_groups = self.batch_size // self.batch_k\r\n sampleed_classes = np.random.choice(self.train_class_ids,num_groups,replace=False)\r\n for class_id in sampleed_classes:\r\n img_fname = np.random.choice(se...
[ "0.71604943", "0.7110667", "0.68857807", "0.68060225", "0.6768268", "0.6751107", "0.67276067", "0.6708528", "0.658012", "0.65510166", "0.65371096", "0.6465802", "0.6404252", "0.63875073", "0.6372499", "0.63602597", "0.63326573", "0.6307031", "0.6297274", "0.6293418", "0.62921...
0.0
-1
Generates test batches from all.txt in train/ test/ or dev/ directories where samples are shuffled and labeled. Yields
def test_batch_generator(self, dir_name): input = np.zeros((self.batch_size, self.max_seq_len, self.embedding_size)) seq_lengths = np.zeros((self.batch_size), dtype=np.intp) unique_counts = np.zeros((self.batch_size), dtype=np.intp) labels = np.zeros((self.batch...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_test_batches(data_dir='/home/yunhan/batchified'):\n # train 3 valid 1\n # Use batch 1 - 53 as train (60%), 54 - 71 as validation (20%), 72 - 89 as test (20%)\n n = 18\n idx = np.random.permutation(n)\n idx = idx + 72\n for i in range(n):\n X = np.load(\"%s/X%d.npy\" % (data_dir, id...
[ "0.7377898", "0.7097675", "0.70060813", "0.66782206", "0.6657778", "0.65936774", "0.6588651", "0.65786034", "0.65503895", "0.6515142", "0.65122056", "0.6450401", "0.64411056", "0.64382833", "0.6385059", "0.6330969", "0.6320016", "0.6313816", "0.6294479", "0.62892824", "0.6274...
0.7086116
2
Generates test batches from all.txt in test/ or dev/ directories where samples are shuffled and labeled. Yields
def predict_batch_generator(self): input = np.zeros((self.batch_size, self.max_seq_len, self.embedding_size)) seq_lengths = np.zeros((self.batch_size), dtype=np.intp) unique_counts = np.zeros((self.batch_size), dtype=np.intp) i = 0 fi = open(self.config...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_test_batches(data_dir='/home/yunhan/batchified'):\n # train 3 valid 1\n # Use batch 1 - 53 as train (60%), 54 - 71 as validation (20%), 72 - 89 as test (20%)\n n = 18\n idx = np.random.permutation(n)\n idx = idx + 72\n for i in range(n):\n X = np.load(\"%s/X%d.npy\" % (data_dir, id...
[ "0.7177904", "0.71596247", "0.7101582", "0.7053556", "0.6844728", "0.67826915", "0.66571736", "0.6609596", "0.6556099", "0.65444964", "0.6511416", "0.64694655", "0.6429852", "0.6417383", "0.63924825", "0.6333554", "0.6333277", "0.6291732", "0.62873936", "0.62851316", "0.62671...
0.0
-1
Generates placeholder variables to represent the input tensors.
def add_placeholders(self): self.input_placeholder = tf.placeholder( tf.float32, (None, self.max_seq_len, self.embedding_size), "input" ) self.batch_seq_length_placeholder = tf.placeholder(tf.int32, (None, ), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_placeholders(self):\n # \"None\" means the batches may have a variable batch size and length.\n self.x = tf.placeholder(tf.int64, shape=[None, None])", "def _create_placeholders(self):\n\n\t\twith tf.name_scope(\"input_data\"):\n\t\t\tself.input_words=tf.placeholder(shape=(None,self.look_back),...
[ "0.752378", "0.75216216", "0.7436447", "0.73585546", "0.7357306", "0.71614146", "0.7106802", "0.70997226", "0.7085868", "0.7065236", "0.70339906", "0.70315886", "0.7022586", "0.69984174", "0.6973781", "0.69555634", "0.6947508", "0.6937862", "0.6934914", "0.6903116", "0.688508...
0.6893304
20
Creates the feed_dict for training the given step. If label_batch is None, then no labels are added to feed_dict
def create_feed_dict(self, inputs_batch, batch_seq_length, batch_unique_count, labels_batch=None, dropout=1, lr=None): feed_dict = dict() feed_dict[self.input_placeholder] = inputs_batch feed_dict[self.batch_seq_length_placeholder] = batch_seq_le...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_feed_dict(self, inputs_batch, labels_batch=None):\n ### YOUR CODE HERE\n feed_dict=dict()\n feed_dict[self.input_placeholder]=inputs_batch\n if labels_batch is not None:\n feed_dict[self.labels_placeholder]=labels_batch\n ### END YOUR CODE\n return fe...
[ "0.74259585", "0.714005", "0.70168495", "0.69314265", "0.68711233", "0.6858954", "0.6803167", "0.67105776", "0.65097845", "0.62538755", "0.6213174", "0.60656565", "0.60462654", "0.60310936", "0.60170025", "0.59969974", "0.5960441", "0.5938122", "0.5918129", "0.590943", "0.590...
0.6911674
4
Adds the core transformation for this model which transforms a batch of input data into a batch of predictions.
def add_prediction_op(self): pred = tf.get_variable( name='pred', shape=(self.batch_size, self.config.n_classes), initializer=tf.zeros_initializer() ) return pred
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _transform(self, dataset):\n raise NotImplementedError()", "def preprocess_transform(self, X: Tensor) -> Tensor:\n for tf in self.values():\n X = tf.preprocess_transform(X)\n return X", "def transform_batch(self, inputs_batch, target_ids_batch, targets_batch):\n # ext...
[ "0.64923996", "0.63494116", "0.6219738", "0.6142022", "0.61072344", "0.60516727", "0.60433406", "0.60370857", "0.6031921", "0.60278577", "0.60278577", "0.60278577", "0.60278577", "0.60278577", "0.60278577", "0.60278577", "0.59975016", "0.59867114", "0.59849584", "0.5957172", ...
0.0
-1
Adds ops for the cross entropy loss to the computational graph. The loss is averaged over all examples in the current minibatch.
def add_loss_op(self, pred): loss = tf.nn.sparse_softmax_cross_entropy_with_logits( labels=self.labels_placeholder, logits=pred, name="loss" ) loss = tf.reduce_mean(loss) return loss
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_loss_op(self, pred):\n ### YOUR CODE HERE\n loss = cross_entropy_loss(self.labels_placeholder,pred)\n ### END YOUR CODE\n return loss", "def loss_op(logits, labels):\n cross_entropy = tf.nn.sparse_softmax_cross_entropy_with_logits(logits, labels, name='xentropy_eval')\n...
[ "0.7201984", "0.6916799", "0.6771412", "0.67244655", "0.66884035", "0.66647446", "0.6586543", "0.6573803", "0.6466889", "0.6453262", "0.64367396", "0.6422562", "0.64079267", "0.6380531", "0.63719505", "0.6367178", "0.63509816", "0.63509816", "0.63411987", "0.6335173", "0.6322...
0.70479894
1
Creates an optimizer and applies the gradients to all trainable variables.
def add_training_op(self, loss, global_step): # Calculate and clip gradients params = tf.trainable_variables() gradients = tf.gradients(loss, params) clipped_gradients, _ = tf.clip_by_global_norm( gradients, self.config.max_gradient_norm ) # Opti...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _optimize(self):\n # Retrieve all trainable variables\n train_variables = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES)\n\n # Compute the gradient (return a pair of variable and their respective gradient)\n grads = self.optimizer.compute_gradients(loss=self.loss, var_list=trai...
[ "0.7602666", "0.747355", "0.73952514", "0.7230327", "0.7107085", "0.7087083", "0.7053867", "0.69550973", "0.68434846", "0.68424076", "0.68309206", "0.6783665", "0.6721693", "0.67049515", "0.66924775", "0.6641975", "0.6584569", "0.6563159", "0.65391326", "0.6534081", "0.652209...
0.6325796
36
Creates f1 evaluator of classifier
def add_eval_op(self, pred): f1_score, metric_update_op = tf.contrib.metrics.f1_score( self.labels_placeholder, tf.slice(tf.nn.softmax(self.pred), [0, 1], [-1, 1]), name='f1_score' ) return f1_score, metric_update_op
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate(classifier, normalizer, transformer, x, y):\n if normalizer is not None:\n x = normalizer.transform(x)\n\n if transformer is not None:\n x = transformer.transform(x)\n\n preds = classifier.predict(x)\n acc = np.sum(y == preds) / len(y)\n f1 = f1_score(y, preds, average='ma...
[ "0.67267", "0.64495933", "0.6437079", "0.6279391", "0.6247813", "0.6081725", "0.60645205", "0.6030185", "0.6019579", "0.59954196", "0.59708714", "0.5969949", "0.5936133", "0.5895928", "0.58899134", "0.5847119", "0.582209", "0.580883", "0.58036584", "0.5793276", "0.5783115", ...
0.57672435
21
Evaluates model on dev dataset and returns f1_score and predicted labels
def evaluate(self, sess, data_gen): pred_labels = np.array([], dtype=np.intp) labels = np.array([], dtype=np.intp) for inputs, seq_length, batch_labels in data_gen: feed_dict = self.create_feed_dict(inputs, seq_length, batch_labels, self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate(model, eval_data, num_labels): \n # Turn on the evaluation state to ignore dropouts\n model.eval()\n results = [predict(model, x) for x, y in eval_data]\n f1_score, accuracy = get_metrics(np.array([y for x, y in eval_data]), results, num_labels)\n return f1_score, accuracy", "def e...
[ "0.7339661", "0.72443473", "0.72425336", "0.72048825", "0.7053383", "0.6888309", "0.68621725", "0.68598145", "0.6721542", "0.6717622", "0.6713856", "0.6701493", "0.67008084", "0.6699391", "0.6676458", "0.66709936", "0.66066396", "0.6598177", "0.6550447", "0.65374744", "0.6524...
0.72352886
3
Predicts labels on unlabeled test set.
def predict(self, sess, data_gen): pred_labels = np.array([], dtype=np.intp) for inputs, seq_length in data_gen: feed_dict = self.create_feed_dict(inputs, seq_length, dropout=self.config.dropout) pred = sess.run(self.pred, feed_dict) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predict_labels(model, x_test):\n \n pred = model.predict(x_test)\n #pred_labels = model.predict_classes(x_test) # depricated\n pred_labels = np.argmax(model.predict(x_test), axis=-1)\n \n return pred, pred_labels", "def predict(self, test_set, test_labels):\n\n with tf.Session() a...
[ "0.7749779", "0.75957185", "0.75269455", "0.7390682", "0.7354112", "0.7269686", "0.71631753", "0.7143413", "0.70833015", "0.70598036", "0.6953809", "0.6916104", "0.6856251", "0.6856251", "0.68497777", "0.6846053", "0.68418294", "0.6825785", "0.68203235", "0.6814053", "0.67928...
0.0
-1
Saves best model during train.
def save_best(self, sess, score): if score > self.best_score: self.best_score = score path_prefix = self.saver.save(sess, self.config.save_path, self.global_step) self.best_model_path = path_prefix return path_prefix ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_model(self, is_best, state, epoch):\n path = os.path.join(self.logpath_models, 'model-%d.pth.tar' % epoch)\n torch.save(state, path)\n if is_best:\n shutil.copyfile(path, path + 'model_best.pth.tar')", "def save_model(self, epoch):\n\n # Reload weights form the che...
[ "0.77143276", "0.76434976", "0.76278317", "0.76071495", "0.7401447", "0.73491347", "0.7321327", "0.73050785", "0.725297", "0.7215255", "0.72109216", "0.72031134", "0.71639895", "0.7157207", "0.7136594", "0.71315217", "0.7115645", "0.7108602", "0.71053714", "0.71004444", "0.70...
0.6884816
49
Generates placeholder variables to represent the input tensors.
def add_placeholders(self): self.input_placeholder = tf.placeholder( tf.float32, (None, self.max_seq_len, self.embedding_size), "input" ) self.batch_seq_length_placeholder = tf.placeholder(tf.int32, (None, ), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_placeholders(self):\n # \"None\" means the batches may have a variable batch size and length.\n self.x = tf.placeholder(tf.int64, shape=[None, None])", "def _create_placeholders(self):\n\n\t\twith tf.name_scope(\"input_data\"):\n\t\t\tself.input_words=tf.placeholder(shape=(None,self.look_back),...
[ "0.7523517", "0.7521597", "0.74357694", "0.73583406", "0.73567647", "0.71616036", "0.7107284", "0.7100283", "0.70864344", "0.70652926", "0.7033381", "0.70321536", "0.7022589", "0.6998019", "0.697382", "0.69554234", "0.6947222", "0.6937978", "0.69340724", "0.68936676", "0.6885...
0.6903461
19
Creates an optimizer and applies the gradients to all trainable variables.
def add_training_op(self, loss, global_step): # Calculate and clip gradients params = tf.trainable_variables() gradients = tf.gradients(loss, params) clipped_gradients, _ = tf.clip_by_global_norm( gradients, self.config.max_gradient_norm ) # Opti...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _optimize(self):\n # Retrieve all trainable variables\n train_variables = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES)\n\n # Compute the gradient (return a pair of variable and their respective gradient)\n grads = self.optimizer.compute_gradients(loss=self.loss, var_list=trai...
[ "0.76019984", "0.74737346", "0.73964405", "0.7229506", "0.710572", "0.7086818", "0.70538044", "0.69551605", "0.68436944", "0.6842918", "0.6831712", "0.6783377", "0.67218363", "0.67048717", "0.66930056", "0.6641727", "0.65861505", "0.6564599", "0.6539085", "0.65337276", "0.652...
0.63445395
32
Adds the core transformation for this model which transforms a batch of input data into a batch of predictions.
def add_prediction_op(self): #x_dropout = tf.keras.layers.SpatialDropout1D(0.4).apply(self.input_placeholder) layer_1_size = 150 layer_2_size = 25 num_aux_feats = 4 rnn_cell_layer_1_fwd = tf.nn.rnn_cell.GRUCell( layer_1_size, activation='relu', ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _transform(self, dataset):\n raise NotImplementedError()", "def preprocess_transform(self, X: Tensor) -> Tensor:\n for tf in self.values():\n X = tf.preprocess_transform(X)\n return X", "def transform_batch(self, inputs_batch, target_ids_batch, targets_batch):\n # ext...
[ "0.64929265", "0.63505316", "0.621995", "0.61421704", "0.61059344", "0.6052137", "0.6044346", "0.60373497", "0.60322785", "0.6027754", "0.6027754", "0.6027754", "0.6027754", "0.6027754", "0.6027754", "0.6027754", "0.5998109", "0.5987142", "0.5984651", "0.59563875", "0.595031"...
0.0
-1
Returns database cursor to interact with PostgreSQL database.
def yield_db_cursor(connect_params=DB_PARAMS, cursor_type=DictCursor): with psycopg2.connect(**connect_params) as con: with con.cursor(cursor_factory=cursor_type) as cur: yield cur
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cursor():\n dbh = handle()\n return dbh.cursor()", "def managed_cursor(self, cursor_factory=None):\n\n self.conn_url = (f'postgresql://{self.user}:{self.password}@{self.host}:{self.port}/{self.db}')\n self.conn = psycopg2.connect(self.conn_url)\n self.conn.autocommit = True\n ...
[ "0.77635354", "0.75554824", "0.74691576", "0.73980325", "0.7387887", "0.73217696", "0.7303565", "0.72945076", "0.7289811", "0.72576785", "0.7194207", "0.7159727", "0.71519923", "0.71519923", "0.7132154", "0.70944715", "0.70845306", "0.7071748", "0.70472896", "0.6998076", "0.6...
0.71329457
14
convert MySQL timestamp to datetime
def convert_timestamp(ts): format = '%Y-%m-%d %H:%M:%S' return datetime.strptime(ts, format)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mysql_timestamp_converter(timestamp):\n if timestamp[4] == '-':\n return datetime_or_None(timestamp)\n timestamp += \"0\"*(14-len(timestamp)) # padding\n year, month, day, hour, minute, second = \\\n int(timestamp[:4]), int(timestamp[4:6]), int(timestamp[6:8]), \\\n int(timestamp[...
[ "0.77829003", "0.7010029", "0.6845619", "0.67591673", "0.6717474", "0.67072576", "0.6706572", "0.6541347", "0.640038", "0.63838106", "0.63502055", "0.6260463", "0.6218308", "0.6216306", "0.6183532", "0.6134314", "0.61161196", "0.61146975", "0.61005396", "0.6095403", "0.608007...
0.6650869
7
If active is true, only return active potholes. If active is false, return all potholes. If date is set, then return potholes with ledger information up to the specified date
def get_geojson_potholes(active=True, date=None): potholes = VwPothole.objects.all() if date is None \ else VwPothole.objects.raw(vw_pothole_by_date, {'datetime': '{} 23:59:59'.format(date)}) pothole_features = [Feature( geometry=Point((float(pothole.lon), float(pothole.lat)), precision=8), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def active (self, after = None, before = None):\n\n active = ActivityList()\n active.list = [actor for actor in self.list\n if (after == None or\n actor[\"period\"].end >= after) and\n (before == None or\n ...
[ "0.50194657", "0.49823934", "0.4923843", "0.48555967", "0.48555368", "0.47429028", "0.47279143", "0.46891028", "0.4629333", "0.46156973", "0.4614425", "0.45901078", "0.45899412", "0.45639297", "0.45589805", "0.45522225", "0.45316374", "0.4529043", "0.4516528", "0.45120677", "...
0.6141142
0
Can construct a package from a S3 Key
def test_list(self): key = Key(self.bucket) name, version, filename = 'mypkg', '1.2', 'pkg.tar.gz' key.key = name + '/' + filename key.set_metadata('name', name) key.set_metadata('version', version) key.set_contents_from_string('foobar') package = list(self.storag...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_key():\n conn = boto.connect_s3()\n bucket = conn.create_bucket(settings.MESSY_BUCKET)\n key = Key(bucket)\n key.key = settings.MESSY_KEY\n return key", "def make_s3(sitename):\n return s3.S3(sitename)", "def from_s3(cls, bucket_name, mos_file_key):\n xml = s3.get_file_con...
[ "0.6773442", "0.6403095", "0.6348497", "0.61896443", "0.6135538", "0.6134094", "0.6044005", "0.6023191", "0.5896879", "0.5869504", "0.58617014", "0.58217484", "0.57936394", "0.57654315", "0.5761166", "0.5751859", "0.5741993", "0.57388633", "0.573869", "0.57145077", "0.5685236...
0.54021513
67
Test that list works on old keys with no metadata
def test_list_no_metadata(self): key = Key(self.bucket) name, version = 'mypkg', '1.2' filename = '%s-%s.tar.gz' % (name, version) key.key = name + '/' + filename key.set_contents_from_string('foobar') package = list(self.storage.list(Package))[0] self.assertEqual...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_ls(self):\n fake_key = namedtuple('Key', ['name', 'last_modified', 'size'])\n num_items = 10\n items = []\n for i in range(num_items):\n items.append({'name': 'item_%d' % i, 'last_modified': 'fake_date', 'size': 100})\n\n backend = self.test_init_valid()\n\n ...
[ "0.7025229", "0.63540006", "0.63520336", "0.62515557", "0.6204083", "0.61587137", "0.61037785", "0.60956293", "0.60297567", "0.6005905", "0.600304", "0.59855175", "0.5985121", "0.59804595", "0.5962854", "0.59540826", "0.59345037", "0.58855706", "0.5871708", "0.5871708", "0.58...
0.66902786
1
Mock s3 and test package url generation
def test_get_url(self): package = make_package() response = self.storage.download_response(package) parts = urlparse(response.location) self.assertEqual(parts.scheme, 'https') self.assertEqual(parts.netloc, 'mybucket.s3.amazonaws.com') self.assertEqual(parts.path, '/' + ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mock_s3_fixture():\n with mock_s3():\n yield", "def mock_s3_client():\n with mock_s3():\n yield", "def mock_s3_bucket():\n with moto.mock_s3():\n bucket_name = \"mock-bucket\"\n my_config = Config(region_name=\"us-east-1\")\n s3_client = boto3.client(\"s3\", conf...
[ "0.7160128", "0.7098021", "0.70244277", "0.70041245", "0.68894506", "0.68372697", "0.6746593", "0.6678674", "0.6602817", "0.6598", "0.65938234", "0.6588515", "0.6581509", "0.65780693", "0.65651834", "0.6470033", "0.6459814", "0.64573693", "0.64334434", "0.64143026", "0.641260...
0.70476264
2
delete() should remove package from storage
def test_delete(self): package = make_package() self.storage.upload(package, StringIO()) self.storage.delete(package) keys = list(self.bucket.list()) self.assertEqual(len(keys), 0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(self):\n self.package = None", "def test_delete(self):\n package = make_package()\n path = self.storage.get_path(package)\n os.makedirs(os.path.dirname(path))\n with open(path, 'w') as ofile:\n ofile.write('foobar')\n self.storage.delete(package)\n ...
[ "0.79596126", "0.79171205", "0.74405926", "0.74049443", "0.73858505", "0.735797", "0.72527796", "0.7154662", "0.703437", "0.6974038", "0.6930558", "0.68803126", "0.6863968", "0.6856768", "0.6781866", "0.67654777", "0.67367566", "0.6721418", "0.6714018", "0.66926026", "0.66661...
0.75034857
2
Uploading package sets metadata and sends to S3
def test_upload(self): package = make_package() datastr = 'foobar' data = StringIO(datastr) self.storage.upload(package, data) key = list(self.bucket.list())[0] self.assertEqual(key.get_contents_as_string(), datastr) self.assertEqual(key.get_metadata('name'), pack...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upload_package(self, filename=None):\n logger.info(\"Uploading the package to S3\")\n s3f = S3FunctionUploader(self.function_config['Code']['S3Bucket'])\n self.s3_filename = path.join(\n self.function_config['Code']['S3KeyPath'],\n path.basename(filename or self.local...
[ "0.7508901", "0.71368754", "0.69945604", "0.6988492", "0.69506544", "0.66899306", "0.6670776", "0.65964633", "0.6553598", "0.65402174", "0.65022314", "0.64736867", "0.6442402", "0.63931197", "0.6360422", "0.63000345", "0.6274222", "0.62663007", "0.626292", "0.6248924", "0.623...
0.70516366
2
If prepend_hash = True, attach a hash to the file path
def test_upload_prepend_hash(self): self.storage.prepend_hash = True package = make_package() data = StringIO() self.storage.upload(package, data) key = list(self.bucket.list())[0] pattern = r'^[0-9a-f]{4}/%s/%s$' % (re.escape(package.name), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_hash(path):\n if re.search(r\"^/.+\", path):\n path = path[1:]\n\n # If a story, fix the path.\n is_story = False\n original_path = path\n if re.search(r\"^\\d{4}\\-\\d{2}\\-\\d{2}\", path):\n path = \"static/stories/%s.json\" % path\n is_story = True\n\n blocksize = ...
[ "0.6296029", "0.61588377", "0.6156242", "0.59895957", "0.5908115", "0.5859219", "0.5853377", "0.57811344", "0.5710734", "0.56959283", "0.5666711", "0.566154", "0.5638332", "0.5616522", "0.5597391", "0.55963844", "0.55830014", "0.5578103", "0.55753094", "0.5553651", "0.5540363...
0.6148258
3
If S3 bucket doesn't exist, create it
def test_create_bucket(self, boto_mock): conn = boto_mock.s3.connect_to_region() boto_mock.exception.S3ResponseError = boto.exception.S3ResponseError def raise_not_found(*_, **__): """ Raise a 'bucket not found' exception """ e = boto.exception.S3ResponseError(400, 'miss...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def s3_create_bucket(self):\n self.conn.create_bucket(DEFAULT_BUCKET_NAME)", "def _create_s3_bucket_if_not_exist(self, prefix):\n account = self.boto_session.client(\"sts\").get_caller_identity()[\"Account\"]\n region = self.boto_session.region_name\n s3_bucket_name = \"{}-{}-{}\".format(...
[ "0.8412326", "0.8206333", "0.81882066", "0.7882016", "0.77453667", "0.768874", "0.7617038", "0.7584526", "0.7462588", "0.74349284", "0.73654705", "0.73503596", "0.7315933", "0.72065103", "0.71941084", "0.71765643", "0.7155236", "0.7097696", "0.70871484", "0.7078128", "0.70769...
0.73255473
12
Raise a 'bucket not found' exception
def raise_not_found(*_, **__): e = boto.exception.S3ResponseError(400, 'missing') e.error_code = 'NoSuchBucket' raise e
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_empty(empty_bucket): # pylint: disable=redefined-outer-name\n with pytest.raises(KeyError):\n empty_bucket.get(\"key 1\")", "def test_get_bucket(self):\n pass", "def test_api_get_bucketlist_by_id_not_exist(self):\n res = self.client().get(f\"/bucketlist/99\")\n self...
[ "0.7205869", "0.71065015", "0.7096352", "0.7038852", "0.6997341", "0.6958753", "0.6955459", "0.6913117", "0.6909686", "0.6773827", "0.6682321", "0.6665191", "0.6648655", "0.6552224", "0.6528791", "0.64729685", "0.6464192", "0.6383199", "0.63815653", "0.63114816", "0.62645215"...
0.8030355
0
Mock s3 and test package url generation
def test_get_url(self): package = make_package(version="1.1+g12345") response = self.storage.download_response(package) parts = urlparse(response.location) self.assertEqual(parts.scheme, 'https') self.assertEqual(parts.netloc, 'abcdef.cloudfront.net') self.assertEqual(pa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mock_s3_fixture():\n with mock_s3():\n yield", "def mock_s3_client():\n with mock_s3():\n yield", "def test_get_url(self):\n package = make_package()\n response = self.storage.download_response(package)\n\n parts = urlparse(response.location)\n self.assertEqu...
[ "0.7160128", "0.7098021", "0.70476264", "0.70244277", "0.70041245", "0.68894506", "0.68372697", "0.6746593", "0.6678674", "0.6602817", "0.6598", "0.65938234", "0.6588515", "0.6581509", "0.65780693", "0.65651834", "0.6470033", "0.6459814", "0.64573693", "0.64334434", "0.641430...
0.616857
35
Uploading package saves file
def test_upload(self): package = make_package() datastr = 'foobar' data = StringIO(datastr) self.storage.upload(package, data) filename = self.storage.get_path(package) self.assertTrue(os.path.exists(filename)) with open(filename, 'r') as ifile: self.a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upload_package(self, __contents):\n raise NotImplementedError", "def upload_file(self, file_path, file_name, output_path):", "def upload(self, filename, file_path):\n return", "def store(self, filename):", "def upload_package(self, filename=None):\n logger.info(\"Uploading the pack...
[ "0.7098982", "0.70311284", "0.673023", "0.64792013", "0.6445228", "0.63774496", "0.6279477", "0.6275277", "0.62648404", "0.62244755", "0.6175778", "0.61720103", "0.6160675", "0.6138877", "0.61355174", "0.6126883", "0.60978365", "0.6096455", "0.6072449", "0.6071755", "0.607072...
0.6412353
5
Can iterate over uploaded packages
def test_list(self): package = make_package() path = self.storage.get_path(package) os.makedirs(os.path.dirname(path)) with open(path, 'w') as ofile: ofile.write('foobar') pkg = list(self.storage.list(Package))[0] self.assertEquals(pkg.name, package.name) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iter_upload(\n self,\n dandiset: RemoteDandiset,\n metadata: dict[str, Any],\n jobs: Optional[int] = None,\n replacing: Optional[RemoteAsset] = None,\n ) -> Iterator[dict]:\n ...", "def uploadPackages(self, directory):\n files_to_upload_dict = {}\n f...
[ "0.661685", "0.6494102", "0.60327435", "0.6024599", "0.5999073", "0.5940509", "0.5845385", "0.5839594", "0.5809949", "0.5790439", "0.5780649", "0.5731289", "0.57043016", "0.56614417", "0.5652788", "0.5590161", "0.55652773", "0.55527717", "0.55380183", "0.55373126", "0.5513332...
0.5469933
23
delete() should remove package from storage
def test_delete(self): package = make_package() path = self.storage.get_path(package) os.makedirs(os.path.dirname(path)) with open(path, 'w') as ofile: ofile.write('foobar') self.storage.delete(package) self.assertFalse(os.path.exists(path))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(self):\n self.package = None", "def test_delete(self):\n package = make_package()\n self.storage.upload(package, StringIO())\n self.storage.delete(package)\n keys = list(self.bucket.list())\n self.assertEqual(len(keys), 0)", "def test_delete_package(self):\n...
[ "0.79596126", "0.75034857", "0.74405926", "0.74049443", "0.73858505", "0.735797", "0.72527796", "0.7154662", "0.703437", "0.6974038", "0.6930558", "0.68803126", "0.6863968", "0.6856768", "0.6781866", "0.67654777", "0.67367566", "0.6721418", "0.6714018", "0.66926026", "0.66661...
0.79171205
1
configure() will create the package dir if it doesn't exist
def test_create_package_dir(self): tempdir = tempfile.mkdtemp() os.rmdir(tempdir) settings = { 'storage.dir': tempdir, } FileStorage.configure(settings) try: self.assertTrue(os.path.exists(tempdir)) finally: os.rmdir(tempdir)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_package_dir(self):\n\n recursive = True if self.format == 'src' else False\n return self.create_dir(self.packageDir, recursive=recursive)", "def mkconfig():\n basedir = os.path.join(os.path.expanduser('~'), '.strikepackage')\n\n # Try to populate dirs\n defaultdirs = [os.path.j...
[ "0.67424464", "0.6623338", "0.66134506", "0.6508852", "0.6499385", "0.63470924", "0.6320616", "0.6299468", "0.62711537", "0.62512326", "0.62406296", "0.6187436", "0.6186941", "0.61614126", "0.61340195", "0.6113963", "0.6108494", "0.60833925", "0.60372895", "0.6028414", "0.600...
0.6465807
5
Adds a directory to sys.path and processes its pth files.
def addsitedir(sitedir,known_paths=None): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_path():\n\timport sys\n\tsys.path.append(directory_root())", "def add_directory(self, directory, prepend=False):\r\n if prepend:\r\n self.directories.insert(0, os.path.normpath(directory))\r\n else:\r\n self.directories.append(os.path.normpath(directory))", "def m...
[ "0.6933244", "0.6737644", "0.67238295", "0.6666068", "0.652336", "0.652336", "0.6474273", "0.645103", "0.6360454", "0.635467", "0.6256308", "0.6189984", "0.61317366", "0.61105937", "0.60868436", "0.60415703", "0.6032115", "0.6032115", "0.5943574", "0.59285384", "0.5898018", ...
0.5466277
38
Returns a list containing all global sitepackages directories (and possibly sitepython).
def getsitepackages(): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_sitepackage_dirs():\n if 'getsitepackages' in dir(site):\n return site.getsitepackages()\n else:\n # workaround for https://github.com/pypa/virtualenv/issues/355\n return sys.path", "def get_site_packages():\n # Another hack...\n # Relies on the fact that os.py is in the ...
[ "0.8410711", "0.8401981", "0.7826747", "0.7820178", "0.7389793", "0.6985517", "0.68044204", "0.677929", "0.677861", "0.66732484", "0.6565434", "0.6558092", "0.6371193", "0.6354965", "0.63515717", "0.63431376", "0.63176894", "0.63109446", "0.6305077", "0.6305077", "0.6305077",...
0.77451956
4
Returns the "user base" directory path. The "user base" directory can be used to store data. If the global variable ``USER_BASE`` is not initialized yet, this function will also set it.
def getuserbase(): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_user_home(self):\n return os.environ['HOME']", "def get_user_home(self):\n return os.environ['HOME']", "def user_home_path(self):\n return path.join(env.user_home, self._user_home_path)", "def getUserDir() -> str:\n\n if os.name == \"nt\": # Windows system, try to return docu...
[ "0.72320074", "0.72320074", "0.7169158", "0.71514034", "0.7037741", "0.6934056", "0.691502", "0.6901557", "0.6891382", "0.6862563", "0.68151444", "0.6769605", "0.6735248", "0.66909224", "0.6690817", "0.65635455", "0.65374714", "0.6530841", "0.65104234", "0.6503841", "0.649601...
0.79859984
0
Returns the userspecific sitepackages directory path. If the global variable ``USER_SITE`` is not initialized yet, this function will also set it.
def getusersitepackages(): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def path(self):\n installed_packages_folder_path = site.getsitepackages()[0]\n return f'{installed_packages_folder_path}/{SITE_PACKAGES_FOLDER_NAME}'", "def user_site_packages() -> str:\n if os.name == 'nt':\n return os.path.join(user_plugin_dir(), 'Lib', 'site-packages')\n\n python_di...
[ "0.727083", "0.70846105", "0.6716054", "0.6541481", "0.6492487", "0.6406417", "0.6365474", "0.6347431", "0.6347431", "0.62456554", "0.62294674", "0.6225628", "0.6074075", "0.602471", "0.6020545", "0.5998052", "0.59796757", "0.59656936", "0.59631383", "0.5927635", "0.5906016",...
0.5686725
41
Read API key from /data/credential.txt
def read_key(): path = os.path.join(os.path.dirname(__file__), 'data') f = open(os.path.join(path, 'credential.txt'), 'r') key = f.read() f.close() return key
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_api_key ():\n PROJECT_PATH = os.path.abspath(os.path.dirname(__name__))\n key_file = open(PROJECT_PATH + \"/key_api.txt\", \"r\")\n return (key_file.read()).rstrip('\\n')", "def read_api_key():\n script_path = os.path.dirname(os.path.realpath(__file__)) \n config = open(script_path + '/...
[ "0.77033496", "0.76855683", "0.75721073", "0.75271016", "0.7320017", "0.72772956", "0.72321165", "0.7134715", "0.71150076", "0.7113407", "0.69248843", "0.68938637", "0.6853688", "0.67965347", "0.675196", "0.67040294", "0.6643031", "0.6438197", "0.6428389", "0.6417984", "0.634...
0.8547963
0
get champion name by its id
def get_champion_name(champion_id, api_key=read_key(), region='na'): response = urllib2.urlopen('https://global.api.pvp.net/api/lol/static-data/'+region+'/v1.2/champion/' + str(champion_id)+'?api_key=' + api_key) champion = json.load(response) return champion['name']
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_name(self, id):\n\t\treturn self.name_by_index[id]", "def champion_key_from_id(champion_id):\n return champions[\"data\"][str(champion_id)][\"key\"]", "def getPlayerCardName(self, playerid):\n with open('./data/players_database.csv', 'r', encoding=\"utf8\") as read_obj:\n csv_reade...
[ "0.70235884", "0.701553", "0.66856205", "0.6443642", "0.6425609", "0.6255943", "0.621068", "0.6080701", "0.6069413", "0.60660994", "0.60368574", "0.60175383", "0.5974954", "0.5973603", "0.59718186", "0.5946285", "0.59321064", "0.5921488", "0.5900459", "0.5856542", "0.5848437"...
0.81229717
0
Create new container, optionally preset with given items.
def __init__(self, items=None): if items is None: self.items = [] else: self.items = items
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createContainer(tag, data={}): #@NoSelf", "def _create_stack_item(container='gl-stack', children=None, viewers=None):\n children = [] if children is None else children\n viewers = [] if viewers is None else viewers\n\n return {\n 'id': str(uuid.uuid4()),\n 'contain...
[ "0.6197168", "0.5949519", "0.5759078", "0.5747322", "0.5676962", "0.56560975", "0.5639722", "0.56048506", "0.55990714", "0.5537253", "0.5523977", "0.5512537", "0.551178", "0.55078644", "0.54995126", "0.54995126", "0.54995126", "0.54995126", "0.54995126", "0.54977703", "0.5477...
0.51043123
42
Add a new item to the container data.
def append(self, item): self.items.append(item)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def push(self, Item):\n self.data_container.insert(0, Item)", "def add_item(self, item):\n self.items.append(item)", "def add(self, item):\n self.contents.append(item)", "def push(self, item):\n self._data.append(item)", "def push(self, item: Any) -> None:\n self._data.ap...
[ "0.8293996", "0.79781246", "0.79551023", "0.7854814", "0.7808611", "0.7806071", "0.77346116", "0.7652134", "0.7637927", "0.756785", "0.7530717", "0.7530717", "0.7530717", "0.7530717", "0.7530717", "0.75287896", "0.7527001", "0.7518286", "0.7480627", "0.74373317", "0.74295294"...
0.7446481
19
Allow support of the [] operator.
def __getitem__(self, idx): return self.items[idx]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __getitem__ (self, index):\n pass", "def __getitem__(self):\n pass", "def __getitem__(self, index):\n raise NotImplementedError", "def __getitem__(self, index):\n pass", "def __getitem__(self, index):\n pass", "def __getitem__(self, idx):\n pass", "def __getitem__(...
[ "0.7602952", "0.7474964", "0.74716824", "0.7461197", "0.7461197", "0.74117994", "0.74117994", "0.72971886", "0.72691345", "0.72691345", "0.72138184", "0.7195102", "0.7188712", "0.7188712", "0.7169328", "0.71553564", "0.7142823", "0.71186095", "0.7032734", "0.7000797", "0.6989...
0.66228575
75
Number of items in this container.
def __len__(self): return len(self.items)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def items_num(self):\n return len(self.items)", "def items_count(self):\n return len(self.items)", "def items_num(self):\n\t\treturn len(self.items)", "def items_num(self):\n\t\treturn len(self.items)", "def size(self) -> int:\n return self.num_items", "def get_num_items(self):\r\n ...
[ "0.8741414", "0.870422", "0.8616444", "0.8616444", "0.8564642", "0.8551799", "0.84417975", "0.8433523", "0.83744204", "0.8125933", "0.81075835", "0.8097785", "0.8085924", "0.8085924", "0.8085924", "0.8085924", "0.8085924", "0.80436784", "0.8008414", "0.8006885", "0.79698616",...
0.7501497
49
Create a new Token representation.
def __init__(self, kind, value=None, neg_kind=False, neg_value=False): self._kind = kind self._value = value self.neg_kind = neg_kind self.neg_value = neg_value
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_token(self, token_id, data):\n raise exception.NotImplemented() # pragma: no cover", "def token(self, id):\r\n return Token(self, id)", "async def create_token(self, *args, **kwargs) -> OAuth2Token:\n token = await super().create_token(*args, **kwargs)\n # NOTE: Save dat...
[ "0.6957312", "0.69491285", "0.68020576", "0.67987514", "0.67915785", "0.67016095", "0.6622861", "0.6608519", "0.64910173", "0.64553404", "0.6414626", "0.63857186", "0.6378225", "0.63423055", "0.6304656", "0.6271824", "0.62174344", "0.6169603", "0.6169603", "0.6169603", "0.616...
0.0
-1
Get the kind of this token.
def kind(self): return self._kind
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def kind(self):\r\n return TokenKind.from_value(conf.lib.clang_getTokenKind(self))", "def token_type(self) -> str:\n return self._token_type", "def token_type(self) -> str:\n return self._token_type", "def token_type(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self,...
[ "0.7913713", "0.7874426", "0.7874426", "0.77519107", "0.7514257", "0.7514257", "0.7482885", "0.7372285", "0.7361082", "0.7339658", "0.73053753", "0.73053753", "0.73053753", "0.73053753", "0.73053753", "0.73053753", "0.73053753", "0.73053753", "0.73053753", "0.73053753", "0.73...
0.7303887
36
Get the value of this token.
def value(self): return self._value
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getValue(self):\n \n return self._value", "def get(self):\n return self._value", "def get_value(self):\n return self._value", "def get_value(self):\n return self._value", "def get_value(self):\n return self._value", "def get_value(self):\n return s...
[ "0.7911703", "0.78716505", "0.7860829", "0.7860829", "0.7860829", "0.7810166", "0.7810166", "0.7808797", "0.7806703", "0.7791883", "0.7758687", "0.7758687", "0.7758687", "0.775261", "0.7745407", "0.7717471", "0.77137625", "0.7697193", "0.76841635", "0.76841635", "0.76841635",...
0.75800484
48
Compare two tokens (used for matching).
def __eq__(self, other): if not isinstance(other.kind, list): k0 = [other.kind] else: k0 = other.kind if not isinstance(other.value, list): v0 = [other.value] else: v0 = other.value if not isinstance(self.kind, list): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _compare_unordered(self, other):\n self_token_set = set(self.tokens)\n other_token_set = set(other.tokens)\n\n if len(self_token_set.intersection(other_token_set)) == 0:\n return MatchResult(\"NO\", 0.0)\n\n if self.address_type != other.address_type:\n return ...
[ "0.7164239", "0.70105475", "0.69408226", "0.6940618", "0.6847735", "0.67941594", "0.659077", "0.6555441", "0.6490086", "0.6489438", "0.64550525", "0.63669354", "0.63249445", "0.6286866", "0.62383115", "0.6128456", "0.60696906", "0.60504436", "0.6007138", "0.59917057", "0.5962...
0.0
-1
Represent a consumer as a string.
def __repr__(self): param = "" action = None if isinstance(self.items, list): for i in self.items: if len(param) > 0: param += ", " param += i.__repr__() if self.action is not None: action = self.action.__name...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self) -> str:\n return str(self.getvalue())", "def __str__(self) -> str:\n return str(self.getvalue())", "def __str__(self) -> str:\n return str(self.getvalue())", "def __str__(self):\n return str(self._inner)", "async def consumer(message):\n # TODO\n print(me...
[ "0.5992803", "0.5992803", "0.5992803", "0.5777372", "0.562348", "0.56132424", "0.5595922", "0.555455", "0.5551444", "0.55506545", "0.55497307", "0.5548537", "0.55457306", "0.55349976", "0.553099", "0.553099", "0.553099", "0.553099", "0.5517856", "0.55134", "0.551042", "0.55...
0.0
-1
Try to match expected tokens against input, and if they match , consume them from the input.
def match(self, inp): return 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def match(self, input_reader):\n retval = []\n # skip the whitespace here to prevent errors at the end of the string\n if input_reader.getIgnoreState():\n input_reader.skipWhite()\n retval.append(self.__rule.match(input_reader))\n try:\n while True:\n ...
[ "0.6492945", "0.64347273", "0.64072734", "0.6325343", "0.6323796", "0.6185672", "0.61034584", "0.5995298", "0.5961961", "0.5961961", "0.5961961", "0.5897409", "0.5832142", "0.58187217", "0.58052206", "0.58036894", "0.5779724", "0.5731637", "0.57204294", "0.57186896", "0.57164...
0.5457896
39
Try to match expected tokens against input, and if they match , consume them from the input. This consumer only consumes when all subconsumers consumed (AND).
def match(self, inp): and_complete = len(self.items) matches = 0 work = inp for t in self.items: if isinstance(t, Consumer) and len(work): r = t.match(work) if r: and_complete -= 1 matches += r ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def consume():\n depth = tokenizer.depth()\n for token in source:\n yield token\n if tokenizer.depth() < depth:\n return", "def consume():\n depth = tokenizer.depth()\n for token in source:\n yield token\n if tokenizer.depth()...
[ "0.64358234", "0.64358234", "0.64358234", "0.61860573", "0.60832894", "0.6072646", "0.59237236", "0.5916269", "0.58925706", "0.5841462", "0.5817155", "0.5734779", "0.57143986", "0.5662163", "0.56231654", "0.5539906", "0.54996157", "0.5483906", "0.5459921", "0.5455314", "0.543...
0.61943865
3
Try to match expected tokens against input, and if they match , consume them from the input. This consumer only consumes when one of the subconsumers consumed (OR).
def match(self, inp): matches = 0 work = inp for i in self.items: if isinstance(i, Consumer) and len(work): matches += i.match(work) if matches: return matches elif len(work): if work[0] == i: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def consume():\n depth = tokenizer.depth()\n for token in source:\n yield token\n if tokenizer.depth() < depth:\n return", "def consume():\n depth = tokenizer.depth()\n for token in source:\n yield token\n if tokenizer.depth()...
[ "0.6473479", "0.6473479", "0.6473479", "0.63934284", "0.6198775", "0.6061931", "0.5906932", "0.58926016", "0.5851433", "0.58479047", "0.5828107", "0.5804186", "0.5762405", "0.5644706", "0.56113833", "0.55958414", "0.5543219", "0.5503156", "0.5490929", "0.5426931", "0.5384671"...
0.60854316
5
This consumer executes the containing root consumer as long as that consumer consumed.
def match(self, inp): matches = 0 while True: m = self.items[0].match(inp) inp = inp[m:] if m > 0: matches += m else: break if matches and self.action is not None: self.action(inp[:matches]) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _consumer(self) -> None:\n while (data := self._q.get()) is not None:\n write_data(data, self.writer)\n self._q.task_done()\n else:\n logging.info(\"None received. Queue consumed.\")\n self._q.task_done()\n return", "def consume(self, handl...
[ "0.6843543", "0.6778191", "0.6764056", "0.6676201", "0.6596627", "0.6564594", "0.6454761", "0.6452899", "0.636782", "0.63429266", "0.6336376", "0.63289666", "0.6315336", "0.6311098", "0.6297736", "0.62942386", "0.62673885", "0.6200036", "0.61780053", "0.61507535", "0.6141587"...
0.0
-1
Create a rule with a given root consumer.
def __init__(self, root_cons): assert isinstance(root_cons, Consumer) self.root_cons = root_cons
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_acl_rule(self, context, sgr):\n self.security_group_driver.create_acl_rule(context, sgr)", "def create_resolver_rule(CreatorRequestId=None, Name=None, RuleType=None, DomainName=None, TargetIps=None, ResolverEndpointId=None, Tags=None):\n pass", "def create_snat_rule(self, **attrs):\n ...
[ "0.5656426", "0.55104995", "0.5498274", "0.54220843", "0.5255137", "0.51557946", "0.5137536", "0.5112721", "0.5094363", "0.5049951", "0.5020241", "0.50156814", "0.50156814", "0.501336", "0.50028026", "0.4972401", "0.49509874", "0.49509874", "0.49509874", "0.49509874", "0.4950...
0.53467864
4
Try to match this rule to the input tokens.
def match(self, inp): matched = self.root_cons.match(inp) return matched
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def match(self, input_reader):\n try:\n rule_match = self.__rule.match(input_reader)\n logging.debug(\"Matched %s\" % self)\n return self.returnToken(self.callAction(rule_match))\n except ParseException as e:\n if e.final:\n raise\n ...
[ "0.65860355", "0.6569237", "0.648908", "0.6396153", "0.6340394", "0.61685085", "0.61111885", "0.6084709", "0.60695326", "0.6060048", "0.6018276", "0.59840447", "0.5964592", "0.5909785", "0.59013426", "0.5880305", "0.5824402", "0.57897544", "0.57223314", "0.5671744", "0.559937...
0.0
-1
Represent a rule as a string.
def __repr__(self): return "%s(%s)" % (self.__class__.__name__, self.root_cons.__repr__())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return \"{ %s }\" % str(self.__rule)", "def __str__(self):\n return \"[ %s ]\" % str(self.__rule)", "def __str__(self):\n return \"{ %s }1\" % str(self.__rule)", "def rule_to_str(self, t):\r\n\r\n if(t[0] == TERMINAL):\r\n return self.terminal_to_st...
[ "0.82408535", "0.8018108", "0.79563034", "0.7597699", "0.7547775", "0.72459847", "0.7131237", "0.70973545", "0.703556", "0.70346487", "0.6995514", "0.68326235", "0.6769843", "0.67501", "0.67490554", "0.6587217", "0.6539035", "0.6535876", "0.6502795", "0.64148235", "0.6307539"...
0.0
-1
Create a parser from a given lexicon.
def __init__(self, lexicon, flags=0): import sre_parse import sre_compile from sre_constants import BRANCH, SUBPATTERN self.lexicon = lexicon # combine phrases into a compound pattern p = [] s = sre_parse.Pattern() s.flags = flags for phrase, ac...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_parser():\n pass", "def make_minilang_parser():\n gramm = Grammar.from_string(GRAMMAR)\n return parser_from_grammar(gramm, 'program')", "def make_parser(data):\n # type: (str) -> RelayParser\n input_stream = InputStream(data)\n lexer = RelayLexer(input_stream)\n token_stream = C...
[ "0.6069957", "0.6066554", "0.60480183", "0.5750524", "0.5577068", "0.55530554", "0.55429524", "0.5505798", "0.5487193", "0.5439394", "0.5416125", "0.541545", "0.5408069", "0.5406951", "0.5396058", "0.537577", "0.5354577", "0.52744836", "0.5261595", "0.5259573", "0.52374434", ...
0.621701
0
Scan the input string, return a list of tokens.
def scan(self, string): result = [] append = result.append match = self.scanner.scanner(string).match i = 0 while 1: m = match() if not m: break j = m.end() if i == j: break action = sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tokenize(self, input_string: str) -> List[str]:", "def tokenise_str(input_str):\n t = Tokeniser(input_str)\n tokens = []\n while True:\n token = t.next()\n if token is None:\n break\n tokens.append(token)\n return tokens", "def _get_tokens(s: str) ->List[str]:\n ...
[ "0.77675945", "0.7501283", "0.73545146", "0.7273766", "0.7175815", "0.7150616", "0.71369165", "0.70631945", "0.70483094", "0.6998969", "0.69848484", "0.69318676", "0.69164383", "0.69087684", "0.68783075", "0.68697166", "0.6829753", "0.68255985", "0.68176705", "0.67455864", "0...
0.6573386
34
Create a tokenizer from a list of patterns.
def __init__(self, patterns=None): Container.__init__(self, patterns)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_tokenizer(self):\n def tokenizer(doc):\n token_pattern = re.compile(self.token_pattern)\n return token_pattern.findall(doc)\n \n return tokenizer", "def tokenize(self, texts: List[str]) -> List[Token]:\n raise NotImplementedError", "def tokenizer(...
[ "0.658101", "0.63527864", "0.61232406", "0.6110007", "0.58901197", "0.586808", "0.5829946", "0.5823161", "0.57966834", "0.56878775", "0.5638406", "0.5624384", "0.56119484", "0.558832", "0.55631876", "0.5546463", "0.5538981", "0.5531948", "0.551695", "0.5488704", "0.5483571", ...
0.0
-1
Tokenize the input string.
def tokenize(self, inp): scanner = Scanner(self.items) return scanner.scan(inp)[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tokenize(self, input_string: str) -> List[str]:", "def tokenize(str):\n return str.split()", "def _tokenize(self, string_):\n return \" \".join(word_tokenize(string_))", "def _tokenize(self, string):\n self._tokens = []\n\n # Split and strip the input string by newlines\n f...
[ "0.78138953", "0.7647113", "0.7621142", "0.7614912", "0.7563403", "0.7274134", "0.7199052", "0.7167596", "0.71064675", "0.7049297", "0.70231694", "0.6993997", "0.68852586", "0.6804387", "0.67763877", "0.6765216", "0.67639923", "0.6758892", "0.674922", "0.67352617", "0.6723727...
0.0
-1
String representation of this Tokenizer.
def __repr__(self): return "%s()" % self.__class__.__name__
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return 'Tokenizer({type}, {value})'.format(\n type=self.type,\n value=repr(self.value)\n )", "def __repr__ (self) -> String:\n\n st = (\"_Token(%r, '%s', %s, %r)\"\n % (self.start, self.text, self.kind, self.value))\n return st", "def toString(sel...
[ "0.80519426", "0.7545306", "0.75383246", "0.73899835", "0.7332152", "0.7317708", "0.7317708", "0.7317708", "0.7317708", "0.7237351", "0.7175742", "0.71049696", "0.7057985", "0.68212074", "0.6681456", "0.6658947", "0.6633161", "0.6614109", "0.645334", "0.63983494", "0.63702554...
0.0
-1
Parse the input by first tokenizing it, and than applying the grammar.
def parse(self, inp): tokens = self.tokenizer.tokenize(inp) tokens_left = len(tokens) # print(tokens) while tokens_left: for rule in self.grammar: tokens = tokens[rule.match(tokens):] if len(tokens) < tokens_left: tokens_left =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_input(self, input):\r\n return self._parse(antlr3.ANTLRInputStream(input))", "def parse(self, input):\n pass", "def _parse(self):\n try:\n # parse token stream into abstract syntax tree (AST)\n self._ast = self._rule_container()\n\n except ParseError:\n ...
[ "0.7399071", "0.7176999", "0.68727535", "0.6820916", "0.6671495", "0.6598285", "0.6544924", "0.64858556", "0.6451945", "0.6421137", "0.6334191", "0.62509596", "0.6192237", "0.61716855", "0.60511875", "0.6048852", "0.603809", "0.5991771", "0.596822", "0.5967969", "0.59347737",...
0.7061553
2
String representation of this Parser.
def __repr__(self): if self.tokenizer is not None: tok = self.tokenizer.__repr__() else: tok = None if self.grammar is not None: gr = self.grammar.__repr__() else: gr = None return "%s(%s, %s)" % (self.__class__.__name__, tok, gr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return self.str_parse_tree(0)", "def __str__(self) :\n if not self.parsed :\n return \"\"\n mybuffer = []\n mybuffer.append(\"IPP version : %s.%s\" % self.version)\n mybuffer.append(\"IPP operation Id : 0x%04x\" % self.operation_id)\n mybu...
[ "0.7421955", "0.7210431", "0.7145681", "0.71311057", "0.7080356", "0.7047601", "0.7026195", "0.70037293", "0.6999853", "0.6991449", "0.6958756", "0.6935437", "0.6929929", "0.6928658", "0.6918804", "0.6912121", "0.6911741", "0.6909374", "0.68920237", "0.6884707", "0.6884707", ...
0.69677925
10
Test dummpy molecule for 90 degree rotations on global zaxis
def test_diatomic_dummy_molecule_rotation_around_global_axis(): mol = Molecule() mol.atoms = ['C'] * 2 mol.coordinates = np.array([[1, 0, 0], [0, 1, 0]]) mol.rotate(([0, 0, 0], [0, 0, 1]), np.pi / 2, center=False) assert np.allclose(mol.coordinates, [[0, 1, 0], [-1, 0, 0]]) mol.rotate(([0, 0, 0]...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_diatomic_dummy_molecule_rotation_around_molecule_axis():\n mol = Molecule()\n mol.atoms = ['C'] * 2\n mol.coordinates = np.array([[1, 0, 0], [0, 1, 0]])\n mol.rotate(([0, 0, 0], [0, 0, 1]), np.pi / 2, center=True)\n assert np.allclose(mol.coordinates, [[1, 1, 0], [0, 0, 0]])\n mol.rotate...
[ "0.68779147", "0.6699214", "0.6467635", "0.6058268", "0.59421706", "0.5833135", "0.5812672", "0.5786473", "0.5781003", "0.57146466", "0.5709731", "0.5701399", "0.5697652", "0.5675569", "0.56018823", "0.5592052", "0.5585152", "0.55424553", "0.55419815", "0.55203927", "0.549647...
0.72263396
0
Test dummpy molecule for 90 degree rotations on zaxis of the molecule
def test_diatomic_dummy_molecule_rotation_around_molecule_axis(): mol = Molecule() mol.atoms = ['C'] * 2 mol.coordinates = np.array([[1, 0, 0], [0, 1, 0]]) mol.rotate(([0, 0, 0], [0, 0, 1]), np.pi / 2, center=True) assert np.allclose(mol.coordinates, [[1, 1, 0], [0, 0, 0]]) mol.rotate(([0, 0, 0]...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_z_rot(self):\n\n # Create a Matrix representing 90 deg z rot.\n mat = Matrix44.from_rot_z(90)\n # Use from_matrix44()\n quat = Quat.from_matrix44(mat)\n\n # Ensure the quat matches a 90 degree x rotation.\n expected = Quat.from_axis_angle_deg(Vec3(0, 0, 1), 90)\n ...
[ "0.70797455", "0.68893856", "0.6713505", "0.6137352", "0.60241646", "0.6014459", "0.59592366", "0.5933176", "0.5881573", "0.58782434", "0.58767945", "0.5848994", "0.584663", "0.583147", "0.58155316", "0.5810699", "0.58072495", "0.57150024", "0.568535", "0.56782866", "0.567333...
0.70375586
1
Call recursive glob iff is in the pattern.
def recursive_glob(path): if "*" not in path: # Glob isn't needed. return [path] elif "**" not in path: # Recursive glob isn't needed. return path_utils.glob(path) else: return path_utils.glob(path, recursive=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recursive_glob(stem, file_pattern):\n\n if sys.version_info >= (3, 5):\n return glob(stem + \"/**/\" + file_pattern, recursive=True)\n else:\n # gh-316: this will avoid invalid unicode comparisons in Python 2.x\n if stem == str(\"*\"):\n stem = \".\"\n matches = []\...
[ "0.751194", "0.6974341", "0.68034536", "0.6758196", "0.67542297", "0.65902424", "0.6563652", "0.6520523", "0.64885634", "0.6402769", "0.6326716", "0.6301645", "0.6283898", "0.6252692", "0.6246691", "0.62367874", "0.6196066", "0.61890477", "0.6177601", "0.6141388", "0.6139274"...
0.7050668
1
Create a nested directory, but don't fail if any of it already exists.
def makedirs(path): try: os.makedirs(path) except OSError as e: if e.errno != errno.EEXIST: raise
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_dir_if_necessary(path):\n try:\n os.makedirs(path)\n except OSError as exception:\n if exception.errno != errno.EEXIST:\n raise", "def create_dir():\n if check_dir_exist():\n return False\n else:\n os.makedirs(path_structure)\n return True", ...
[ "0.74229234", "0.72851455", "0.7262007", "0.7246796", "0.7240233", "0.7218255", "0.718408", "0.7164283", "0.7142678", "0.7140523", "0.7129466", "0.7109018", "0.70924854", "0.70889115", "0.7085182", "0.70810604", "0.70569605", "0.704916", "0.7046928", "0.70466846", "0.7039653"...
0.0
-1
Context manager. Change the directory, and restore it afterwards.
def cd(path): if not path: yield return curdir = path_utils.getcwd() os.chdir(path) try: yield finally: os.chdir(curdir)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __enter__(self):\n self.savedPath = os.getcwd()\n os.chdir(self.newPath)", "def restore_cwd():\n cwd = os.getcwd()\n try:\n yield\n finally:\n os.chdir(cwd)", "def _restore_orig_directory(self):\n if not self._is_temp_dir:\n return\n self._base_...
[ "0.78329426", "0.72657293", "0.71698695", "0.7141132", "0.7084793", "0.7076439", "0.7041844", "0.68930256", "0.68384814", "0.68027496", "0.6796666", "0.67186296", "0.6703635", "0.6698865", "0.66618675", "0.6634945", "0.6622206", "0.66195375", "0.6611089", "0.65799147", "0.657...
0.60399324
58
Checks if a pyi file is path/to/dir/__init__.pyi.
def is_pyi_directory_init(filename): if filename is None: return False return path_utils.splitext(path_utils.basename(filename))[0] == "__init__"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def IsPackage(path):\n init_base_path = os.path.join(path, '__init__.py')\n return (os.path.isfile(init_base_path) or\n os.path.isfile(init_base_path + 'c') or\n os.path.isfile(init_base_path + 'o'))", "def is_pkg(cls, path):\n return exists(join(path, '__init__.py'))", "def ...
[ "0.7422277", "0.7233876", "0.7077706", "0.70653397", "0.6987086", "0.6987086", "0.6595339", "0.6401514", "0.6298225", "0.62583286", "0.6258052", "0.6250494", "0.61958045", "0.60404485", "0.6009115", "0.60048294", "0.58957773", "0.5888118", "0.58545226", "0.58261836", "0.58251...
0.79479814
0
Checks if the filename is a pickle file.
def is_pickle(filename): return path_utils.splitext(filename)[1].startswith(PICKLE_EXT)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pickleExists(name):\n fileNames = [f for f in os.listdir(PICKLE_DIR) if name in f]\n return not len(fileNames) == 0", "def verify_filename(filename):\n\n if is_fileobj(filename):\n raise ValueError(\"%r not a filename\" % filename)", "def is_mp3_file(filename):\n ext = str(os.path.splite...
[ "0.643423", "0.6430957", "0.6344804", "0.6319534", "0.62992567", "0.6294618", "0.6250568", "0.62361664", "0.6185609", "0.61671084", "0.61487937", "0.61480135", "0.61176413", "0.6105346", "0.6073736", "0.6073736", "0.6023189", "0.60059375", "0.6004802", "0.5994341", "0.5991949...
0.8553102
0
Fully expand a path, optionally with an explicit cwd.
def expand_path(path, cwd=None): expand = lambda path: path_utils.realpath(path_utils.expanduser(path)) with cd(cwd): return expand(path)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expandpath(path):\n return os.path.abspath(os.path.expanduser(path))", "def expand_path(path):\n return expanduser(expandvars(path))", "def ExpandPath(path):\n return os.path.realpath(os.path.expanduser(path))", "def expand_path(path):\n\n return os.path.abspath(os.path.expanduser(os.path.expan...
[ "0.74701923", "0.73939276", "0.73707473", "0.7219343", "0.7219343", "0.71664995", "0.7078088", "0.6832545", "0.6721617", "0.6641923", "0.6560282", "0.655823", "0.65138286", "0.65120006", "0.6336295", "0.62854826", "0.62736595", "0.62604237", "0.61930496", "0.6163498", "0.6128...
0.85340816
0
Fully expand a list of paths, optionally with an explicit cwd.
def expand_paths(paths, cwd=None): return [expand_path(x, cwd) for x in paths]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expand_globpaths(globpaths, cwd=None):\n with cd(cwd):\n paths = sum((recursive_glob(p) for p in globpaths), [])\n return expand_paths(paths, cwd)", "def expand_paths(__file__, paths_with_globs):\n if isinstance(paths_with_globs, str):\n return expand_path(__file__, paths_with_globs)\n else...
[ "0.7456049", "0.70066786", "0.6774307", "0.66487193", "0.65742046", "0.624558", "0.61956173", "0.59257555", "0.56479543", "0.5538372", "0.55290365", "0.54953575", "0.54544365", "0.5436541", "0.5423522", "0.5376047", "0.5348702", "0.5323587", "0.53146243", "0.5308345", "0.5304...
0.8460689
0
Expand a list of glob expressions into a list of full paths.
def expand_globpaths(globpaths, cwd=None): with cd(cwd): paths = sum((recursive_glob(p) for p in globpaths), []) return expand_paths(paths, cwd)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def expand(self, path_list):\n path_list2 = []\n for path in path_list:\n if glob.has_magic(path):\n iterator = glob.iglob(path)\n path_list2.extend(iterator)\n else:\n path_list2.append(path)\n return path_list2", "def expan...
[ "0.8407495", "0.80332714", "0.7528493", "0.7383241", "0.73741955", "0.6872758", "0.6813668", "0.6686918", "0.6616619", "0.65312225", "0.64324456", "0.6402898", "0.6316146", "0.63040036", "0.6291287", "0.62841296", "0.62715226", "0.6246781", "0.6219632", "0.6194844", "0.618852...
0.7691867
2
Expand a spaceseparated string of filenames passed in as sources. This is a helper function for handling command line arguments that specify a list of source files and directories. Any directories in filenames will be scanned recursively for .py files. Any files that do not end with ".py" will be dropped.
def expand_source_files(filenames, cwd=None): out = [] for f in expand_globpaths(filenames.split(), cwd): if path_utils.isdir(f): # If we have a directory, collect all the .py files within it.... out += recursive_glob(path_utils.join(f, "**", "*.py")) elif f.endswith(".py"): out.append(f) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preprocess(\n self,\n source: str,\n name: t.Optional[str] = None,\n filename: t.Optional[str] = None,\n ) -> str:\n return reduce(\n lambda s, e: e.preprocess(s, name, filename),\n self.iter_extensions(),\n str(source),\n )", "def...
[ "0.57943326", "0.56623256", "0.56462324", "0.56194705", "0.56137234", "0.55241853", "0.54940057", "0.5488685", "0.54875094", "0.5447087", "0.5410495", "0.5335001", "0.5287344", "0.5250983", "0.5189532", "0.5180171", "0.5116171", "0.5083184", "0.5078157", "0.506521", "0.505824...
0.689316
0
Shows possible moves interpreted as chess coords
def chess_coord_moves(self, select): hold = [] for i in self.board[select].possible_moves: hold.append(self.chess_coords[self.coords.index(i)]) self.print_message(("my possible moves are:",hold))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_possible_moves(self):\n for move in self.env.possible_moves(self.env.turn):\n self.render_marker(move, Colors.BLUE)", "def chess_map(self):\n print('<>\\t', end='')\n for i in range(1, self.mapX + 1): # 打印列坐标\n print(i, end='\\t')\n print()\n f...
[ "0.75572604", "0.73018354", "0.6853283", "0.6808992", "0.6737718", "0.66602975", "0.6623016", "0.66016227", "0.6577454", "0.65595424", "0.6546937", "0.65451103", "0.64989746", "0.6481591", "0.6444175", "0.64146894", "0.6391575", "0.63840497", "0.6382809", "0.6382281", "0.6379...
0.7084934
2
Prints messages. Makes it easier to turn off when running AI
def print_message(self, message): print(message)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hide_messages():\n\n print(\"Keep uncertainty data?\")\n print(\"NewDatabase(..., keep_uncertainty_data=True)\")\n print(\"\")\n print(\"Hide these messages?\")\n print(\"NewDatabase(..., quiet=True)\")", "def print_messages(self):\n if self.messages:\n self.messages.append(\"\")\n ...
[ "0.6853183", "0.67243636", "0.66580886", "0.6560094", "0.65378034", "0.63819957", "0.63348514", "0.62748116", "0.62620103", "0.62291723", "0.62229854", "0.62218237", "0.62142426", "0.62052816", "0.6195678", "0.619227", "0.6191761", "0.6156673", "0.6156401", "0.61522394", "0.6...
0.5950852
35
Fixes the problem where the mover method infinetly recurses due to the computer trying to capture a piece while in check. self.recursive_move is a list of blacklisted moves
def recurse_fix(self, recurse): #Removes the recursive moves from <piece>.possible_moves if recurse == True: # print(self.recursive_move) for i in self.recursive_move: select = self.recursive_move[self.recursive_move.index(i)][0] move = sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_valid_moves(self):\r\n # castling and en-passant rights are stored, because move affects these values\r\n temp_enpassant_possible = self.enpas_pos\r\n temp_castle = CastleRights(self.cr_castle_r.wks, self.cr_castle_r.bks,\r\n self.cr_castle_r.wqs, self...
[ "0.6435797", "0.6278216", "0.6252017", "0.61592704", "0.61344117", "0.61085063", "0.6066249", "0.60613513", "0.60312474", "0.60108995", "0.6007377", "0.6001272", "0.59988976", "0.5975665", "0.597399", "0.5933734", "0.592724", "0.5924062", "0.59091336", "0.5909046", "0.5904532...
0.75138515
0
Display game board on screen
def display_board(self, board): print("\n\t - A - B - C - D - E - F - G - H - \n") print("\t8 ", board[56], "|", board[57], "|", board[58], "|", board[59], "|", board[60], "|", board[61], "|", board[62], "|", board[63]) print("\t ", "---------------------------------------") pr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_board(self):\n self._game_board.display()", "def show_board(self, game):\n\n self.screen.clear()\n self.show_banner()\n self.show_score(game)\n self.show_towers(game.board)\n self.screen.refresh()", "def display_board(self):\n print(self.game_board)", ...
[ "0.8678167", "0.83532125", "0.8349347", "0.83242863", "0.8264461", "0.824662", "0.79697764", "0.7959786", "0.7956839", "0.7923558", "0.7922038", "0.7910964", "0.79016423", "0.78563464", "0.7760773", "0.7742415", "0.7722158", "0.7712943", "0.7707028", "0.764252", "0.7638022", ...
0.77047324
19
Populates the board with piece objects
def populate(self): counter = 0 placers = [piece_class.Rook, piece_class.Knight, piece_class.Bishop, piece_class.Queen, piece_class.King, piece_class.Bishop, piece_class.Knight, piece_class.Rook, piece_class.Pawn, piece_class.Pawn, piece_class....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def populate_board(self):\n for key, value in self.game.white_pieces.items():\n x_pos = self.width * value.x_pos\n y_pos = self.width * value.y_pos\n img = self.load_image(\"images/\" + value.image, value.starting_position)\n self.place_image_on_canvas(x_pos, y_po...
[ "0.76593214", "0.75936663", "0.7367415", "0.72926337", "0.7115361", "0.7082727", "0.70713323", "0.7070828", "0.7015153", "0.69468915", "0.6837631", "0.68237364", "0.68121535", "0.6800702", "0.66739005", "0.6650878", "0.6610713", "0.659756", "0.6571999", "0.6550281", "0.651255...
0.8106084
0
Tracks available moves for every piece
def loads_pathways(self, turn): black_coords, white_coords = self.parser() counter = 0 path_dict, poss_dict, check_dict, long_dict = {BLACK : [], WHITE : []}, {BLACK : [], WHITE : []}, {BLACK : [], WHITE : []}, {BLACK : [], WHITE : []} for i in self.board: if i != se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_moves(self):", "def getPossibleMoves(self): # called to get possible positions this piece can go\r\n \r\n moves = {}\r\n\r\n ids = []\r\n\r\n for piece in self.board.pieces.values():\r\n if piece.name == \"empty\":\r\n piece.glow = False\r\n ...
[ "0.7183788", "0.71057975", "0.68767446", "0.6852259", "0.6705842", "0.6636046", "0.6629116", "0.6602298", "0.651185", "0.6503754", "0.64848596", "0.64755505", "0.64447147", "0.63818496", "0.6336451", "0.63071597", "0.62893933", "0.62332284", "0.6224337", "0.62011695", "0.6181...
0.5866029
71
Turns the board index' which hold pieces into coordinates
def parser(self): hold = [i for i, val in enumerate(self.board) if val != self.empty and val.colour == BLACK] hold2 = [i for i, val in enumerate(self.board) if val != self.empty and val.colour == WHITE] #This is why dictionaries are better black_coords = [] white_coords ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_board_coordinates(self):\n\n temp_board = copy.deepcopy(self.get_board())\n board_columns = self.get_board_columns()\n board_rows = self.get_board_rows()\n\n for board_row in board_rows:\n\n for board_column in board_columns:\n \n index_colum...
[ "0.71379375", "0.70625293", "0.6820346", "0.67808604", "0.6744463", "0.6730689", "0.66997415", "0.6699165", "0.66525185", "0.662486", "0.65777856", "0.65033275", "0.64912", "0.6417787", "0.6387271", "0.638245", "0.63251114", "0.6315006", "0.625296", "0.6216417", "0.6207858", ...
0.0
-1
Checks to see if a player is in check
def checks_check(self, turn): opposite_colour = next_turn(turn) if piece_class.KING_LOCATION[opposite_colour] in self.path_dict[turn]: self.print_message("CHECK!") # self.checkmate(turn) self.mate_double(turn) self.mate_pinned(turn) self.mate_n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_in_check(self, player):\n\n current_player = player.upper()\n\n # Gathers current player's General and sets opponent player.\n if current_player == 'BLUE':\n\n current_player_general_position = self.get_general_position_blue()\n opponent_player = 'RED'\n\n e...
[ "0.7478128", "0.7422957", "0.7306489", "0.72766924", "0.72634876", "0.7202797", "0.71440995", "0.6985347", "0.6975687", "0.6958636", "0.6958488", "0.6942686", "0.6923067", "0.68779784", "0.6877642", "0.68572235", "0.685284", "0.6837244", "0.6819755", "0.6790949", "0.6739893",...
0.0
-1
Tests if a double check causes a checkmate
def mate_double(self, turn): opposite_colour = next_turn(turn) opp_king_index = (piece_class.KING_LOCATION[opposite_colour][0] + piece_class.KING_LOCATION[opposite_colour][1] * 8) opp_poss_moves = {tuple(i) for i in self.poss_dict[opposite_colour]} check_path = {tuple(i) for i in self.c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check():", "def test_recheck_fails(self):\n raise NotImplementedError", "def check(self) -> None:", "def test_version_check_outdated(self):\n output = self.run_command(\"selfupdate --check bennr01:selfupdate_test_outdated\", exitcode=0)\n self.assertIn(\"Target: bennr01:selfupdate_te...
[ "0.64797485", "0.6376622", "0.6094995", "0.60793626", "0.6064576", "0.6052561", "0.5955447", "0.5947425", "0.5947425", "0.5947425", "0.5947425", "0.59290624", "0.5913185", "0.58940095", "0.58906275", "0.5886973", "0.5885773", "0.58225274", "0.5817582", "0.58138984", "0.580961...
0.59306425
11
Checks piece(s) are pinned to the king, and can't prevent checkmate
def mate_pinned(self, turn): pinned_list = [] opposite_colour = next_turn(turn) opp_king_index = (piece_class.KING_LOCATION[opposite_colour][0] + piece_class.KING_LOCATION[opposite_colour][1] * 8) opp_poss_moves = {tuple(i) for i in self.poss_dict[opposite_colour]} check...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_move_knight_legally_blocked(self):\n for piece in [('N', True), ('N', False)]:\n self.c.board = \\\n [[('K', piece[1]) for i in range(8)] for i in range(8)]\n self.c.turn = piece[1]\n self.c.board[4][4] = piece\n for dest in ['d6', 'f6', 'c...
[ "0.68501544", "0.66945", "0.6639427", "0.64998174", "0.64502615", "0.644943", "0.64347035", "0.64299804", "0.6413221", "0.6408485", "0.6388782", "0.63560796", "0.6353194", "0.63430786", "0.6337254", "0.63203883", "0.6306646", "0.6304615", "0.62882274", "0.6250088", "0.6243981...
0.7173512
0
Tests for the most usual checkmate
def mate_normal(self, turn): opposite_colour = next_turn(turn) opp_king_index = (piece_class.KING_LOCATION[opposite_colour][0] + piece_class.KING_LOCATION[opposite_colour][1] * 8) opp_poss_moves = {tuple(i) for i in self.poss_dict[opposite_colour]} check_path = {tuple(i) for i i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check():", "def test_check(self):\n\n self.assertTrue(Naive().check(self.file_gitignore))\n self.assertTrue(Naive().check(self.file_tests))\n self.assertTrue(Naive().check(self.file_bin))\n self.assertTrue(Naive().check(self.file_py))\n self.assertTrue(Naive().check(self.fi...
[ "0.76886064", "0.7633155", "0.7092025", "0.6998297", "0.691067", "0.68761855", "0.6818562", "0.6818562", "0.6818562", "0.6818562", "0.6790198", "0.678656", "0.67435277", "0.6642163", "0.6612691", "0.6592765", "0.6569492", "0.6565059", "0.65569156", "0.6540621", "0.6509107", ...
0.0
-1
Checks if there's a draw by repitition
def draw_by_rep(self, turn, select, move): REPETITION_CURR[turn] = [self.coords[select], self.coords[move]] if REPETITION_PREV[turn] != []: if REPETITION_CURR[turn][0] == REPETITION_PREV[turn][1] and REPETITION_CURR[turn][1] == REPETITION_PREV[turn][0]: self.rep_counter += 1...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isdrawn(self):\n return hasattr(self, 'drawn')", "def checkDraw(self) -> D:\n if self.board.positions.count(\" \") == 0:\n print(\"DRAW!\")\n return True", "def draw(self):\n\n for row in self._board:\n for slot in row:\n if slot == 0:\n ...
[ "0.72048205", "0.68884087", "0.67064244", "0.656032", "0.65569574", "0.6467784", "0.6443536", "0.6437354", "0.62705666", "0.62168354", "0.6202882", "0.6179856", "0.6173285", "0.6105228", "0.6098985", "0.6077393", "0.6041107", "0.60317785", "0.5978021", "0.59643847", "0.594096...
0.57615733
30
Checks if there's a draw due to insufficient material
def draw_by_insufficient(self): if self.cap_counter > 100: self.draw_loop("draw due to none in 50") if self.board.count(self.empty) == 62: self.draw_loop("draw due to insufficient") if self.board.count(self.empty) == 61: for i i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insufficient_material(_user_id):\n _board = boards[_user_id]\n return _board.is_insufficient_material()", "def insufficient_material(self):\n piece_set = set()\n for row in range(8):\n for col in range(8):\n piece = self.board.squares[row][col]\n i...
[ "0.6823158", "0.65014744", "0.6312815", "0.62909424", "0.62909424", "0.5994646", "0.5992354", "0.5942213", "0.59327585", "0.58796394", "0.5844621", "0.58162147", "0.5812185", "0.5682749", "0.56119996", "0.5551076", "0.5534958", "0.5529477", "0.5487489", "0.5461284", "0.546109...
0.63086367
3
Adjusts the king moves to take into account opponent paths
def king_adjust(self, turn): opposite_turn = next_turn(turn) original_location_index = (piece_class.KING_LOCATION[turn][0] + piece_class.KING_LOCATION[turn][1] * 8) # if self.board[original_location_index] == self.empty: # print("yo") self.board[original_loc...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_king_moves(self, state):\n #king_moves = []\n possible_moves = []\n if self.color == cc.WHITE_ACTIVE:\n enemy_color = cc.BLACK_ACTIVE\n enemy_pieces = cc.BLACK_PIECES\n elif self.color == cc.BLACK_ACTIVE:\n enemy_color = cc.WHITE_ACTIVE\n ...
[ "0.65922093", "0.6517307", "0.6433317", "0.642922", "0.63771147", "0.63771147", "0.63771147", "0.63081336", "0.6298383", "0.6261358", "0.6192195", "0.6176605", "0.6164589", "0.6163104", "0.6143453", "0.61155224", "0.6101044", "0.6099099", "0.6098332", "0.6097228", "0.60883033...
0.85099286
0
Appends the possible move of the king if castling is possible
def castling(self, turn, ai): if self.board[self.coords.index(piece_class.KING_LOCATION[turn])].move_track == True: return None castling_queenside = [self.coords.index(piece_class.KING_LOCATION[turn]), self.coords.index(piece_class.KING_LOCATION[turn]) - 1, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def king_adjust(self, turn):\n\n opposite_turn = next_turn(turn)\n\n original_location_index = (piece_class.KING_LOCATION[turn][0] + piece_class.KING_LOCATION[turn][1] * 8)\n \n# if self.board[original_location_index] == self.empty:\n# print(\"yo\")\n \n self.bo...
[ "0.7224072", "0.6627195", "0.65229857", "0.6470024", "0.6182009", "0.6177418", "0.61430883", "0.6139011", "0.61076343", "0.6091473", "0.6086108", "0.60822123", "0.6072754", "0.6068784", "0.6068784", "0.6068784", "0.60567504", "0.60416263", "0.6029341", "0.6026139", "0.6018981...
0.72807145
0
Checks if castling is possible
def castling_valid(self, turn, direction): opposite_colour = next_turn(turn) if self.board[direction[0]] and self.board[direction[-1]] != self.empty: if ((self.board[direction[0]].graphic) == piece_class.PIECEDICT[turn][piece_class.King] and (self.board[direct...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _can_cast_to(self, value, cast_type):\n try:\n _ = cast_type(value)\n return True\n except ValueError:\n return False", "def is_casting(self):\n # type: () -> bool\n return self._is_casting", "def test_canConvert(string, cast, expected):\n assert canConvert(string, cast)...
[ "0.75801295", "0.7562737", "0.6442058", "0.6417883", "0.6306073", "0.6138935", "0.6129317", "0.6065727", "0.6046611", "0.6044432", "0.60181624", "0.5920204", "0.5906511", "0.58403975", "0.57817537", "0.57176816", "0.56767637", "0.5561193", "0.5528392", "0.5521377", "0.5496391...
0.0
-1
Implements the castling by moving the rook
def castling_implement(self, turn, select, move): if select == self.coords.index(piece_class.KING_LOCATION[turn]): if self.board[self.coords.index(piece_class.KING_LOCATION[turn])].move_track == False: if move in [2, 58]: self.board[move+1] = self.board[m...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _walk(self):\n new_pos = self.rect.move((self.move, 0)) # move 9 pixel to the right per frame\n if self.rect.left < self.area.left or self.rect.right > self.area.right:\n self.move = -self.move # move to the opposite direction when the chimp position exceeds the screen\n n...
[ "0.7103401", "0.7072305", "0.6994009", "0.69171774", "0.68605596", "0.6859176", "0.6715968", "0.66763794", "0.6669459", "0.6627489", "0.6609323", "0.6591225", "0.6581653", "0.65799546", "0.65799546", "0.6564521", "0.65348953", "0.6508202", "0.64825106", "0.6464618", "0.645735...
0.6157545
63
Resets all attributes after a game has been played by AIvAI
def resets_attributes(self): self.path_dict = None self.poss_dict = None self.check_dict = None self.long_dict = None self.rep_counter = 0 self.cap_counter = 0 self.board = [] self.coords = [] self.chess_coords = [] self.e...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_game_fields(self):\n self.player = None\n self.event_status = 0 # set accordingly for player achievments\n self.event_status_list = [False, False, False, False, False, False, False, False]\n self.spaces = []\n self.characters = []\n self.exits = []\n self....
[ "0.7516117", "0.73008484", "0.7209318", "0.71248615", "0.70516896", "0.70516896", "0.7050974", "0.7039916", "0.70002186", "0.69693255", "0.69182575", "0.6885031", "0.6839155", "0.68244755", "0.676734", "0.67489743", "0.67342496", "0.67195565", "0.6716343", "0.66865003", "0.66...
0.73064816
1
Calculates how long a game takes
def time(self, start_time): TIME_LIST.append((time.time() - start_time)) print("--- %s seconds ---" % (time.time() - start_time))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def time(self) -> float:\n return self.state.game_loop / 22.4 # / (1/1.4) * (1/16)", "def time(n_games, time_per_game):\n\n total_time = n_games * time_per_game / 60\n return total_time", "def GAME_TIME_ADVANCE(dt):", "def time_elapsed(session, player):\n #TODO (also needs to be added to bot...
[ "0.77314806", "0.7411862", "0.7296464", "0.6975621", "0.6766241", "0.6730055", "0.6683318", "0.6671834", "0.6671834", "0.6671834", "0.6671834", "0.6671834", "0.6671834", "0.6656775", "0.6643553", "0.66259193", "0.6610059", "0.65386087", "0.6536", "0.6452645", "0.64100575", ...
0.0
-1
default formating as string
def default(self, obj): if isinstance(obj, (dt.date, dt.datetime)): return obj.isoformat()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def format(self) -> str:", "def formatted(self) -> str:\r\n ...", "def format(self, *args, **kwargs) -> String:\n pass", "def __format__(self, fmt):\n if not isinstance(fmt, str):\n raise TypeError(\"must be str, not %s\" % type(fmt).__name__)\n if len(fmt) != 0:\n ...
[ "0.837017", "0.78593856", "0.78285396", "0.77283126", "0.7577578", "0.74514586", "0.74457926", "0.72434765", "0.7181104", "0.7149438", "0.7149438", "0.70565635", "0.70547104", "0.7050457", "0.6980099", "0.6979376", "0.6970662", "0.6964501", "0.69569725", "0.69133925", "0.6911...
0.0
-1
Read scraped profiles parse them and write to json and yamls
def main(): # %% CFG.profiles_yamls_path.mkdir(parents=True, exist_ok=True) fpaths = list( _Config.raw_profiles_path.glob('*.html') ) print( f'{len(fpaths)} htmls found' ) # %% fpath = CFG.raw_profiles_path / 'luis-mario-urrea-murillo.html' # %% fpath = CFG.raw_profiles_path / 'cristian-...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loadProfiles():\n with open(userProfilesDir, \"r\") as infile:\n profiles = json.loads(\"\\n\".join(infile.readlines()))\n infile.close()\n return profiles", "def scrape_profile(inhandle, outfile, year, month):\n #Read file\n html = inhandle.read()\n soup = BeautifulSoup(html, 'htm...
[ "0.6808882", "0.67222965", "0.66820586", "0.6603268", "0.6544514", "0.6352096", "0.625899", "0.62085044", "0.60912347", "0.6039629", "0.6026319", "0.5911269", "0.5884196", "0.58651155", "0.58599305", "0.58528185", "0.5841541", "0.5834487", "0.58279127", "0.5772486", "0.573618...
0.6291534
6
Extract data from one scraped html
def extract_one( html: str, fpath: Path ): # %% doc = BeautifulSoup( html, features='html.parser') ret = { 'linkedin_handle': fpath.name.split('.')[0] } _parse_top_card( ret, doc ) # %% ret['about'] = _extract_about( doc ) # if len(ret['about']) < 100 and ret['about'].find('ver más') > 0: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_data_listing(html):\n id_finder = re.compile(r'PR[\\d]+~')\n return html.find_all('div', id=id_finder)", "def page_data():\n return scrape()", "def _extract_data(self,data,tag=None,cssid=None,cssclass=None,attrs=None,regexp=None,index=0):\n \n# cssclass = \"song\"\n# c...
[ "0.70408916", "0.6867916", "0.67792255", "0.66598994", "0.65740573", "0.6546643", "0.6389909", "0.6372902", "0.6365779", "0.636015", "0.63392663", "0.6330602", "0.63226384", "0.63203055", "0.6284733", "0.6260619", "0.6241101", "0.6239079", "0.6200324", "0.61735535", "0.617248...
0.6600914
4
Calculate total_experience_yrs and other stats
def calc_work_stats( work_xps: List[Dict[str, Any]] ): durations = [ rec['duration'] for rec in work_xps if 'duration' in rec ] total_years = sum( durations ) if durations else None avg_years = np.round( total_years / len(durations), 2) if durations else None poss_lt2_years = sum( 1 for dur in durations...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def years_job_experience(self) -> int:\n return sum([job.years_employed for job in self._history_jobs])", "def get_experience(self):\n return sum([i.get_experience for i in self.__units])", "async def yearlystats(self, ctx, *, iracing_id=None):\n await self.yearly_stats_db.call(ctx, iracin...
[ "0.6512815", "0.63359934", "0.5996619", "0.5913304", "0.57828826", "0.5751886", "0.5728529", "0.5614757", "0.5604025", "0.5573763", "0.55307776", "0.55264235", "0.5497981", "0.5462642", "0.5450629", "0.54372895", "0.54367644", "0.5427174", "0.5389119", "0.5351539", "0.5340693...
0.6127486
2
some metrics on the whole profile text
def profile_text_stats( doc: BeautifulSoup ): text = doc.find('main', {'class': 'core-rail'}).text.strip() words = text.split() eng_ratio = sum(1 for word in words if word in COMMON_ENGLISH) * 10/ (len(words) + 0.001) return { 'length': len( text ), 'eng_ratio': np.round( eng_ratio, 2)} ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _profile(self, text):\n prof = zeros(len(self.alph)**self.N)\n ngs = ngrams(text, self.N)\n for tup in ngs:\n loc = 0\n for i in range(len(tup)):\n loc += (len(self.alph)**i) * self.alph.index(tup[i])\n prof[loc] += 1\n return prof", ...
[ "0.6908674", "0.64373267", "0.61230284", "0.60225594", "0.6013804", "0.5936111", "0.5932316", "0.5845712", "0.58176684", "0.57707936", "0.576293", "0.5743936", "0.57346797", "0.5728267", "0.5687166", "0.56419724", "0.56302047", "0.5594292", "0.55903494", "0.5582322", "0.55770...
0.72970635
0
process one employment summary and extract info from it
def proc_employment_summary(summary: Tag) -> Dict: xp_record = dict() xp_record['position'] = summary.find('h3').text.strip() company = summary.find_all('p', {'class': 'pv-entity__secondary-title'})[0] xp_record['company'] = "; ".join( [ line.strip() for line in company.text.split('\n') ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def proc_education_summary( summary: Tag ) -> Dict[str, str]:\n edu_record = dict()\n edu_record['school'] = summary.find('h3').text.strip()\n edu_record['is_abroad_school'] = _is_abroad_school( edu_record['school'] )\n\n for parag in summary.find_all('p'):\n spans = [span.text.strip() for span ...
[ "0.647423", "0.61216635", "0.59458005", "0.56278527", "0.5343209", "0.53211635", "0.52993035", "0.52750313", "0.5241437", "0.5197236", "0.51397026", "0.5090858", "0.5073519", "0.50543827", "0.5022594", "0.5021494", "0.5021494", "0.5011691", "0.4984092", "0.49774346", "0.49728...
0.81081915
0