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
Initializes the Generator network.
def __init__(self, in_channels, ofp_name='Optical Flow Predictor'): super(OFPredictor, self).__init__() self.ofp_name = ofp_name # definition of all layer channels self.layer_out_channels = {1: 128, 2: 64, 3: 32, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_net(self):\r\n # initialize the generator network\r\n g_net = Net(\r\n self.architecture['generator'], net_name='gen',\r\n data_format=FLAGS.IMAGE_FORMAT, num_class=self.num_class)\r\n # define layer connections in generator\r\n self.Gen = Routine(g_net)\r...
[ "0.81265664", "0.75276977", "0.7346039", "0.7256937", "0.70575345", "0.693526", "0.6913095", "0.6912832", "0.676234", "0.662226", "0.66039085", "0.6594192", "0.6580022", "0.65705234", "0.65510106", "0.6539857", "0.6511585", "0.65068555", "0.6443831", "0.6431111", "0.63988996"...
0.0
-1
Function to compute a single forward pass through the network, according to the architecture.
def forward(self, rep, kp): x = torch.cat([rep, kp], dim=1) # dim=channel x = self.layers(x) return x # bsz
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward_pass(X,architecture):\n \n architecture['layer1'][0] = X\n kernel_shape1 = architecture['layer1'][7]\n stride1 = architecture['layer1'][8]\n if kernel_shape1 is not None and not isinstance(kernel_shape1,int):\n X_input_1_im2col,imX = im2col(X,kernel_shape1,stride1,im_needed = Fals...
[ "0.70519215", "0.6851133", "0.68151206", "0.68046707", "0.67846954", "0.6776149", "0.6751489", "0.6748744", "0.6711352", "0.66513306", "0.6621835", "0.66118675", "0.6604177", "0.65992516", "0.65739995", "0.65739995", "0.65739995", "0.6563378", "0.653694", "0.6536814", "0.6521...
0.0
-1
Returns the conditional loglikelihood of the observations.
def _log_likelihood(self, theta, f, x, y, yerr): sigma2 = yerr**2 return -0.5*np.sum((y - f(theta, x))**2 / sigma2 + 2*np.log(sigma2))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_likelihood(self):\r\n return (-0.5 * self.num_data * self.output_dim * np.log(2.*np.pi) -\r\n 0.5 * self.output_dim * self.K_logdet + self._model_fit_term() + self.likelihood.Z)", "def log_likelihood_function(self, instance):\r\n\r\n xvalues = np.arange(self.data.shape[0])\r\n ...
[ "0.7378853", "0.7304213", "0.7241666", "0.7125939", "0.7054042", "0.70123684", "0.69925195", "0.69223547", "0.6895047", "0.68253577", "0.6810189", "0.6802465", "0.6785051", "0.6773284", "0.6751977", "0.67441165", "0.6710317", "0.67056346", "0.669349", "0.66932", "0.6670858", ...
0.0
-1
Returns the prior logprobability of the model parameters.
def _log_prior(self, theta, bounds): if not ((bounds[0] < theta).all() and (theta < bounds[1]).all()): return -np.inf else: return 0.0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_prior(self, params):\n # log likelihood function, see:\n # https://en.wikipedia.org/wiki/Multivariate_normal_distribution#Likelihood_function\n variance = self.std ** 2\n ndim = params.ndim\n mean_diff = params - self.mean\n scaled_sq_err = jnp.dot(mean_diff, mean_...
[ "0.7703106", "0.7564021", "0.7556586", "0.7543695", "0.7523004", "0.7460024", "0.7460024", "0.7293357", "0.726926", "0.7212998", "0.71421045", "0.7124713", "0.709318", "0.70578134", "0.7026564", "0.69897103", "0.69895947", "0.69756615", "0.6955453", "0.69510067", "0.6860235",...
0.6559603
42
Returns the Bayes numerator logprobability.
def _log_probability(self, theta, model, bounds, x, y, yerr): lp = self._log_prior(theta, bounds) if not np.isfinite(lp): return -np.inf return lp + self._log_likelihood(theta, model, x, y, yerr)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_prob(self):", "def sentence_logprob(self, sentence):\n line = get_ngrams(sentence,3)\n log_por = 0.0\n for item in line:\n raw_por = self.smoothed_trigram_probability(item)\n log_por = log_por+math.log2(raw_por)\n\n return float(log_por)", "def lnprobab...
[ "0.7335864", "0.71539515", "0.711939", "0.6993325", "0.69717914", "0.6897869", "0.6868799", "0.684763", "0.67927825", "0.6784907", "0.6784907", "0.6756561", "0.67523694", "0.67367864", "0.6711099", "0.669755", "0.6691705", "0.6649628", "0.6599368", "0.6557143", "0.65558773", ...
0.0
-1
Checks if the model has been fitted.
def _check_if_fitted(self): if not self.fitted: raise AssertionError('Model is not fitted! Fit the model to a ' 'dataset before attempting to plot results.')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_been_fit(self):\n return self.predictor.has_been_fit", "def _check_if_fitted(self):\n if self.covar_module is None:\n raise RuntimeError(\n \"Model has not been fitted. You need to call \"\n \"`fit_fully_bayesian_model_nuts` to fit the model.\"\n ...
[ "0.84510565", "0.8341908", "0.80420315", "0.78471446", "0.76460594", "0.7363085", "0.7329144", "0.7243502", "0.6904458", "0.68524843", "0.6768016", "0.6768016", "0.67104214", "0.65335727", "0.6428695", "0.6424164", "0.63796276", "0.637692", "0.6376009", "0.63072443", "0.62974...
0.8522283
0
Samples the posterior distribution to fit the model to the data.
def fit(self, p0=None, pool=None, moves=None): self._p0 = p0 # self._bounds = self.param_bounds self.ndim = self.param_bounds.shape[1] if self._p0 is None: self._p0 = np.random.uniform(*self.param_bounds, (self.nwalkers, self.ndim)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def posterior_sample(self):\n pass", "def sample_posterior(self):\n \n# print (\"SAMPLING FROM LINEAR SIMILARITY VB\")\n if (self.posterior_mean == False):\n self.weight = Vil.sample_posterior(self.mu_weight, Vil.softplus(self.rho_weight))\n self.bias = Vil.sampl...
[ "0.7270848", "0.7082263", "0.67933387", "0.6556029", "0.6509716", "0.64833724", "0.6433063", "0.6410651", "0.641042", "0.6386421", "0.63349533", "0.6258219", "0.61917496", "0.61873734", "0.6183915", "0.615199", "0.6147017", "0.61315185", "0.6121277", "0.61200947", "0.61011916...
0.0
-1
Gets the MCMC chains from a fitted model.
def get_chain(self, **kwargs): self._check_if_fitted() return self._sampler.get_chain(**kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def chains(self, model_num = 0):\n return [c for c in self.struct]", "def iter_chains(self):\n if self.default_model:\n return iter(self.default_model.chain_list)\n return iter(list())", "def mcmc(guess, nu, D, Ninv, beam_mat, models_fit, label=None, nwalkers=50, burn=500, steps...
[ "0.6416719", "0.5682124", "0.55172515", "0.53585184", "0.52665263", "0.523426", "0.51154137", "0.50814307", "0.5026937", "0.5012058", "0.49715763", "0.4924447", "0.49119356", "0.48740694", "0.4869272", "0.4849639", "0.48269346", "0.47564632", "0.4753034", "0.4740829", "0.4732...
0.5572626
2
Returns a Polynomial Decomposition impedance.
def forward(self, theta, w): return Decomp_cyth(w, self.taus, self.log_taus, self.c_exp, R0=theta[0], a=theta[1:])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deriv(self):\n poly_deriv = []\n for i, val in enumerate(self.coeff):\n poly_deriv.append(i*val)\n # Removes the differentiated constant (which is always 0).\n del poly_deriv[0]\n return Poly(poly_deriv)", "def anti_deriv(self):\n poly_anti_deriv = [0]\n ...
[ "0.6602687", "0.6434507", "0.61124486", "0.594507", "0.59432936", "0.5882449", "0.5757533", "0.571267", "0.5697987", "0.56913066", "0.5650294", "0.5599147", "0.55832195", "0.55588233", "0.5545277", "0.5538527", "0.5534198", "0.55121106", "0.55069256", "0.5482732", "0.54679424...
0.0
-1
Returns a ColeCole impedance.
def forward(self, theta, w): return ColeCole_cyth(w, R0=theta[0], m=theta[1:1+self.n_modes], lt=theta[1+self.n_modes:1+2*self.n_modes], c=theta[1+2*self.n_modes:])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cole_coeff(self):\n return self.diseq_coeff(standardize=True)", "def circpol(self):\n return self._circpol", "def rc_impedance(R, X):\n if isinstance(X, tuple):\n X = capacitive_reactance(X[0], X[1])\n Z = math.sqrt(R**2 + X**2)\n return _Res(Z)", "def reflection_coefficient...
[ "0.58506185", "0.58204633", "0.57930845", "0.57545364", "0.5430616", "0.54134864", "0.5342721", "0.5340746", "0.531498", "0.52990055", "0.52800167", "0.5265645", "0.525901", "0.5239153", "0.5209121", "0.518048", "0.5123653", "0.51234806", "0.5104862", "0.50781995", "0.5072264...
0.50014687
28
Returns a Dias (2000) impedance.
def forward(self, theta, w): return Dias2000_cyth(w, *theta)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def duty_translate(self, n):\n return int((float(n) / 255) * 1023)", "def dc(self):\n return np.array(self['dc'], dtype=np.float32) / 1000", "def dBtoLinear(db):\r\n return 10**(db/20)", "def intrinsic_impedance(self,freq):\n if freq == 0:\n return cmath.sqrt(self.mu/self.e...
[ "0.58910507", "0.5807247", "0.57104003", "0.5660627", "0.5608719", "0.5592587", "0.5563866", "0.5548893", "0.5501863", "0.54738", "0.543523", "0.53981644", "0.5391949", "0.5346082", "0.5294509", "0.5250999", "0.5223875", "0.52220315", "0.5217054", "0.52103794", "0.5208293", ...
0.0
-1
Returns a Shin (2015) impedance.
def forward(self, theta, w): return Shin2015_cyth(w, R=theta[:2], log_Q=theta[2:4], n=theta[4:] )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def renishaw_1d_si():\r\n\r\n import os\r\n from ..raman_hyperspectra_read_files import read_RAMAN_RENISHAW_txt_0D\r\n\r\n fname = os.path.join(os.path.dirname(__file__), \"RENISHAW_1D_Si.txt\")\r\n da_sliced, da_sliced_interp, da, da_interp = read_RAMAN_RENISHAW_txt_0D(fname)\r\n\r\n return da_slic...
[ "0.5767429", "0.56498814", "0.5597143", "0.55202895", "0.5478017", "0.5405477", "0.53588426", "0.53514975", "0.5316064", "0.5277444", "0.5276314", "0.52613115", "0.52432704", "0.52143633", "0.5153139", "0.5152581", "0.51391906", "0.51382667", "0.5116501", "0.5104855", "0.5092...
0.0
-1
This function calls measure distance command and return distances between atoms
def measure_distance(self, mat): if len(mat) == 1: print("chain has only one CAatom") return self.dists = [] for num in range(0, len(mat)): if num + 1 <= len(mat) - 1: c1 = mat[num] c2 = mat[num + 1] d = c2 - c1 ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_distance(atom1,atom2): #dot string to show when you go into the help doc of this function\n x_distance = atom1[0]-atom2[0]\n y_distance = atom1[1]-atom2[1]\n z_distance = atom1[2]-atom2[2]\n distance = numpy.sqrt(x_distance**2+ y_distance**2+z_distance**2)\n return distance", "def _c...
[ "0.69215775", "0.6625629", "0.66220516", "0.6382407", "0.6372567", "0.63564414", "0.6245087", "0.62364805", "0.6187293", "0.61466056", "0.60757715", "0.6070278", "0.60611844", "0.605809", "0.60450953", "0.60312355", "0.60054964", "0.59860754", "0.5966108", "0.5955413", "0.590...
0.6309999
6
This function computes standard deviations of distances between atoms list given
def standarddeviation_of_distances(self, distances, mean=None): if len(distances) == 1: mean = 3.50 self.stddev = 0.2 else: sum = 0 for dis in distances: sum = sum + dis # finding mean mean = sum / len(distances) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def standard_deviation(list):\n num_items = len(list)\n mean = sum(list) / num_items\n differences = [x - mean for x in list]\n sq_differences = [d ** 2 for d in differences]\n ssd = sum(sq_differences)\n\n\n variance = ssd / num_items\n\n sd = sqrt(variance)\n\n return sd", "def _calcula...
[ "0.7164316", "0.7109992", "0.7048701", "0.70070904", "0.69621277", "0.6905012", "0.68864226", "0.6842125", "0.67247325", "0.66839546", "0.6622081", "0.6622081", "0.6580844", "0.6364406", "0.6293041", "0.62749994", "0.6272102", "0.62253296", "0.62046343", "0.61940634", "0.6178...
0.7279174
0
This function computes max and min value and finds the atoms where distance between them is more than max and residues which are not connected
def compute_max_min(self, mean, distances, mat, mol, atoms=[]): min = mean - 0.300 max = mean + 0.500 ats = [] if len(distances) == 1: if distances[0] > max: caats = self.chain.getAtoms().get(lambda x: x.name == "CA") ats.append([caats[0], caat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_min_max_electrode_distances(self):\n distances = pdist(self.get_electrode_positions())\n return distances.min(), distances.max()", "def get_max_and_min(self):\n max_x = float('-inf')\n min_x = float('inf')\n max_y = float('-inf')\n min_y = float('inf')\n m...
[ "0.63975495", "0.6353354", "0.62732863", "0.60797185", "0.60425997", "0.6017662", "0.59481037", "0.5922569", "0.5826767", "0.5818462", "0.57839507", "0.57807755", "0.5779295", "0.5773055", "0.57633895", "0.5706294", "0.5696797", "0.5695814", "0.56732357", "0.5646929", "0.5628...
0.6639326
0
Convert between a Penn Treebank tag to a simplified Wordnet tag
def penn_to_wn(tag): if tag.startswith('N'): return 'n' if tag.startswith('V'): return 'v' if tag.startswith('J'): return 'a' if tag.startswith('R'): return 'r' return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def penn_to_wn(tag):\r\n if tag.startswith('N'):\r\n return 'n'\r\n \r\n if tag.startswith('V'):\r\n return 'v'\r\n \r\n if tag.startswith('J'):\r\n return 'a'\r\n \r\n if tag.startswith('R'):\r\n return 'r'\r\n \r\n return 'n'", "def penn_to_wn(tag):\r\n if tag.star...
[ "0.7503625", "0.7503625", "0.7440842", "0.7378811", "0.7376264", "0.7358257", "0.73056555", "0.7207639", "0.70650107", "0.70051056", "0.68536615", "0.6828216", "0.65609425", "0.65086913", "0.6497413", "0.6439208", "0.6272912", "0.61927736", "0.6163601", "0.61525345", "0.61522...
0.7378214
4
compute the sentence similarity using Wordnet
def sentence_similarity_asym(sentence1, sentence2): # Tokenize and tag sentence1 = pos_tag(word_tokenize(sentence1)) sentence2 = pos_tag(word_tokenize(sentence2)) # Get the synsets for the tagged words synsets1 = [tagged_to_synset(*tagged_word) for tagged_word in sentence1] synsets2 = [tagged_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wordSimilarityRatio(sent_1,sent_2):", "def wordNet_similarity(sentence1, sentence2):\r\n # Tokenize and tag\r\n \r\n # sentence1 = pos_tag(word_tokenize(sentence1))\r\n sentence1=st_tagger.tag(word_tokenize(sentence1))\r\n \r\n # sentence2 = pos_tag(word_tokenize(sentence2))\r\n sentence...
[ "0.8176473", "0.7891114", "0.7886794", "0.7635196", "0.7469397", "0.737969", "0.7375463", "0.73530227", "0.73361194", "0.7256091", "0.7135701", "0.7113992", "0.7112951", "0.7011426", "0.698791", "0.6977041", "0.6971011", "0.6920748", "0.6867374", "0.68184453", "0.6798726", ...
0.7148714
10
This is the main game loop for playing accordion solitaire
def accordion_game_loop(): while True: # Shows player the cards on the table deck.cards_on_table() # Prompt player to choose from available cards on table or quit player_choice = input( "Pick a card index number or deal a card = d or quit game = q: ") ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GAME_LOOP():\n pass", "def play_game(self):\n # need everyone to pass to move to next phase?\n self.deal_cards()\n self.plant_food()", "def play_game():\n pass", "def play_game():\n\n _initial_deal()\n\n main_window.mainloop()", "def GAMEOVER_LOOP():\n ...
[ "0.73572654", "0.71851116", "0.7171762", "0.71476305", "0.70981914", "0.7089904", "0.70830375", "0.7030875", "0.6965971", "0.6901151", "0.6791792", "0.6775212", "0.67203623", "0.67143553", "0.6714", "0.66939676", "0.6681823", "0.6675617", "0.66722625", "0.66714734", "0.662073...
0.7252437
1
Try sending markdown and revert to normal text if broken
def __actual_send_message(bot, chat_id, text, parse_mode=None, disable_web_page_preview=None, disable_notification=False, reply_to_message_id=None, reply_markup=None, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_to_markdown(self, text: str) -> str:", "def markdown(text):\n text = gfm(text)\n text = markdown_lib.markdown(text)\n return text", "def markdown_post(post):\n post['entry'] = markdown(post['entry'].replace(\"\\n\",\" \\n\"), output=\"html5\")\n return post", "def render_markdown_...
[ "0.6429384", "0.63258183", "0.6232665", "0.62162316", "0.6201989", "0.607612", "0.6075034", "0.60221326", "0.6016422", "0.5995724", "0.5976146", "0.59642905", "0.58939266", "0.5892673", "0.5820269", "0.5817999", "0.5816363", "0.57908636", "0.5773369", "0.57693034", "0.5751285...
0.0
-1
Return True if bot was able to actually send private message
def send_private_message(bot, user_id, text): try: __actual_send_message(bot=bot, chat_id=user_id, text=text) return True except TelegramError as e: if e.message == "Unauthorized": return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allow_sudo(message):\n if message.author.id == Guard.AUTHOR and message.channel.type == discord.ChannelType.private:\n return True\n if message.author.id in Guard.SUDO_IDS and message.channel.id in Guard.SUDO_CHANNELS:\n return True\n return False", "def can_send(se...
[ "0.69425625", "0.6856079", "0.6826255", "0.6720108", "0.6696828", "0.66692317", "0.6608927", "0.6549641", "0.6446773", "0.6336873", "0.63162243", "0.62268645", "0.61660624", "0.61466724", "0.612538", "0.6072842", "0.607221", "0.60678214", "0.6051874", "0.60329306", "0.6015381...
0.73651165
0
Return True if bot was able to actually send private photo
def send_private_photo(bot, user_id, url, caption): # Truncate caption if it's too long... if len(caption) >= telegram.constants.MAX_CAPTION_LENGTH: token = "[...]" caption = caption[:-len(token)] + token try: bot.sendPhoto(user_id, photo=url, caption=caption) return True ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def media_image_remotely_accessible(self) -> bool:\n return True", "def send_private_link(bot, user_id, url):\n try:\n __actual_send_message(bot=bot, chat_id=user_id, text=url + \" \")\n return True\n except Unauthorized:\n return False\n except TelegramError as e:\n #...
[ "0.69891006", "0.63934034", "0.6243591", "0.62283254", "0.60614157", "0.60280484", "0.59461737", "0.5909658", "0.58902806", "0.5760746", "0.574469", "0.57446885", "0.57138896", "0.5699035", "0.5682138", "0.56351286", "0.56053644", "0.5594147", "0.5589981", "0.5575158", "0.556...
0.73184806
0
Return True if bot was able to actually send private photo
def send_private_link(bot, user_id, url): try: __actual_send_message(bot=bot, chat_id=user_id, text=url + " ") return True except Unauthorized: return False except TelegramError as e: # Todo try to send failed to message photo... pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_private_photo(bot, user_id, url, caption):\n\n # Truncate caption if it's too long...\n if len(caption) >= telegram.constants.MAX_CAPTION_LENGTH:\n token = \"[...]\"\n caption = caption[:-len(token)] + token\n try:\n bot.sendPhoto(user_id, photo=url, caption=caption)\n ...
[ "0.73168516", "0.6989355", "0.6244311", "0.62291497", "0.6061357", "0.6027259", "0.5947171", "0.59112054", "0.58908", "0.57627594", "0.5744586", "0.5742839", "0.57133824", "0.57034403", "0.5682764", "0.5638972", "0.560661", "0.559506", "0.5587423", "0.5570435", "0.55625397", ...
0.6391627
2
Send a custom message (not predefined)
def send_custom_message(bot, chat_id, message, parse_mode=None, disable_web_page_preview=None, disable_notification=False, reply_to_message_id=None, reply_markup=None, timeout=None): __actual_send...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send(self, msg):\n self.message('Me', msg)", "def send_message(self, message):\n pass", "def send(self, msg):\n pass", "def send(self, msg):\n pass", "def send(self, msg):\n pass", "def send(self, message):\n pass", "def send(self, msg: str):\n\t\tself.client.s...
[ "0.8322891", "0.7971607", "0.79242545", "0.79242545", "0.79242545", "0.782539", "0.7554915", "0.7442413", "0.7422757", "0.7404954", "0.72999096", "0.7290856", "0.7252667", "0.72094226", "0.71426684", "0.7112199", "0.7105945", "0.70600796", "0.70494735", "0.70370215", "0.70288...
0.6658285
74
Find input channels of the yolo model from layer configs.
def get_c(layer_configs): net_config = layer_configs['000_net'] return net_config.get('channels', 3)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def output_channels(self, input_channels):\n return input_channels", "def infer_channels(inputs, transpose=False):\n out_type = infer_type(inputs)\n out_shapes = [get_const_tuple(out_type.checked_type.shape)]\n channels = out_shapes[0][0] if not transpose else out_shapes[0][1]\n return channel...
[ "0.58312744", "0.5742968", "0.56544346", "0.5654426", "0.5552283", "0.54746956", "0.5446388", "0.5428018", "0.5343479", "0.5341048", "0.53252137", "0.53120375", "0.52911556", "0.5288412", "0.5281511", "0.52737856", "0.527295", "0.52729017", "0.5260956", "0.52438396", "0.52409...
0.63726634
0
Read the ONNX file.
def load_onnx(model_name): onnx_path = '%s.onnx' % model_name if not os.path.isfile(onnx_path): print('ERROR: file (%s) not found! You might want to run yolo_to_onnx.py first to generate it.' % onnx_path) return None else: with open(onnx_path, 'rb') as f: return f.read()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read(self, filename):\n pass", "def read(self, filename):\n pass", "def read_from_file(self, filename: str) -> None:", "def read(self, filename):\n raise NotImplementedError", "def read():\n # TODO", "def readFromFile(filename):\n raise NotImplementedError", "def _rea...
[ "0.6746281", "0.6746281", "0.6521646", "0.6459207", "0.63081074", "0.62845105", "0.6245893", "0.6220834", "0.6212407", "0.6155629", "0.61270404", "0.61025923", "0.6095804", "0.6050429", "0.60348177", "0.59660417", "0.5933632", "0.58970493", "0.5861567", "0.5832417", "0.580760...
0.6105649
11
Set network input batch size. The ONNX file might have been generated with a different batch size, say, 64.
def set_net_batch(network, batch_size): if trt.__version__[0] >= '7': shape = list(network.get_input(0).shape) shape[0] = batch_size network.get_input(0).shape = shape return network
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_batch_size(self, batch_size):\n self.batch_size = batch_size\n self.n_batch = math.ceil(self.n_samples / batch_size)", "def set_batch_size(self, batch_size):\n self.batch_size = batch_size", "def batch_size(self, batch_size: ConfigNodePropertyInteger):\n\n self._batch_size =...
[ "0.7431989", "0.7298853", "0.7241127", "0.69462866", "0.6937012", "0.67112094", "0.6516663", "0.64337176", "0.6352927", "0.6261257", "0.6261257", "0.6261257", "0.6261257", "0.6261257", "0.62382287", "0.61667866", "0.6156479", "0.6126977", "0.60776895", "0.60061693", "0.600216...
0.78923297
0
Build a TensorRT engine from ONNX using the older API.
def build_engine(model_name, do_int8, dla_core, verbose=False): cfg_file_path = model_name + '.cfg' parser = DarkNetParser() layer_configs = parser.parse_cfg_file(cfg_file_path) net_c = get_c(layer_configs) net_h, net_w = get_h_and_w(layer_configs) print('Loading the ONNX file...') onnx_dat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_engine():\n with trt.Builder(TRT_LOGGER) as builder, builder.create_network() as network, trt.OnnxParser(network, TRT_LOGGER) as parser:\n builder.max_workspace_size = 1 << 30 # 1GB\n builder.max_batch_size = 1\n builder.fp16_mode = mode_fp16\n # builder...
[ "0.75302416", "0.73794323", "0.7356037", "0.7165194", "0.63997895", "0.6384399", "0.6346997", "0.63233453", "0.5783392", "0.5469623", "0.54011154", "0.5373637", "0.53584635", "0.53226984", "0.5289722", "0.5102888", "0.50943995", "0.5093108", "0.5031483", "0.50289315", "0.4997...
0.6941727
4
Create a TensorRT engine for ONNXbased YOLO.
def main(): parser = argparse.ArgumentParser() parser.add_argument( '-v', '--verbose', action='store_true', help='enable verbose output (for debugging)') parser.add_argument( '-c', '--category_num', type=int, help='number of object categories (obsolete)') parser.add_argum...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_engine(model_name, do_int8, dla_core, verbose=False):\n cfg_file_path = model_name + '.cfg'\n parser = DarkNetParser()\n layer_configs = parser.parse_cfg_file(cfg_file_path)\n net_c = get_c(layer_configs)\n net_h, net_w = get_h_and_w(layer_configs)\n\n print('Loading the ONNX file...')\...
[ "0.7240884", "0.7089738", "0.7071886", "0.66323364", "0.6563251", "0.62431705", "0.60698307", "0.60199344", "0.5975187", "0.597299", "0.59692544", "0.5869984", "0.56920403", "0.54563993", "0.5443414", "0.5427093", "0.53920895", "0.53632927", "0.534049", "0.5320027", "0.531242...
0.69439214
3
Measures angle between points u, v and w in positive or negative direction
def _angle(u, v, w, d='+'): vu = np.arctan2(u[1] - v[1], u[0] - v[0]) vw = np.arctan2(w[1] - v[1], w[0] - v[0]) phi = vw - vu if phi < 0: phi += 2 * np.pi if d == '-': phi = 2 * np.pi - phi return np.round(phi, 6)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def angle(v,w):\n cosx = dot_product(v,w) / (length(v) * length(w))\n #det = determinant(A,B)\n rad = math.acos(cosx) # in radians\n return rad\n #return rad*180/math.pi # returns degrees", "def signed_angle(self, u, v):\n return atan2(u.x * v.y - u.y * v.x, u.x * v.x + u.y * v.y)", "def ...
[ "0.79517096", "0.7312548", "0.7312548", "0.72500753", "0.7232059", "0.7214304", "0.712939", "0.71266484", "0.7106797", "0.70677173", "0.7058549", "0.70381576", "0.70160705", "0.69562507", "0.69332904", "0.6918083", "0.6891398", "0.68336743", "0.6822264", "0.6813132", "0.68025...
0.8139179
0
Returns intersection of lines AB and CD
def _intersect(A, B, C, D): d = (B[0] - A[0]) * (D[1] - C[1]) - (D[0] - C[0]) * (B[1] - A[1]) x = ((B[0] * A[1] - A[0] * B[1]) * (D[0] - C[0]) - (D[0] * C[1] - C[0] * D[1]) * (B[0] - A[0])) / d y = ((B[0] * A[1] - A[0] * B[1]) * (D[1] - C[1]) - (D[0] * C[1] - C[0] * D[1]) * (B[1] - A[1])) / d return (np...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def intersect(A,B,C,D):\n i = ccw(A,C,D) != ccw(B,C,D) and ccw(A,B,C) != ccw(A,B,D)\n #if i:\n # canvas.polyline( [ A,B ], style=4 , tags = (\"debug\"))\n # canvas.polyline( [ C,D ], style=4 , tags = (\"debug\"))\n #else:\n # canvas.polyline( [ A,B ], style=1...
[ "0.745266", "0.7374789", "0.7243203", "0.6923169", "0.68880177", "0.6886507", "0.686967", "0.68426377", "0.68232024", "0.68200475", "0.6819899", "0.67877644", "0.67731494", "0.67715836", "0.67273533", "0.6700855", "0.66976535", "0.6671102", "0.66155475", "0.6599032", "0.65976...
0.71551526
3
Constructs optimal polygon and returns pivot points. Based on 'An Optimal Algorithm for Approximating a. Piecewise Linear Function. HIROSHI IMAI and MASAO Iri.'
def optimal_polygon(y, w=0.5, debug=False): # Make sure that we use numpy array y = np.array(y) x = np.arange(len(y)) # Initialization y = np.round(y, 6) p_plus = (x[0], y[0] + w) l_plus = (x[0], y[0] + w) r_plus = (x[1], y[1] + w) s_plus = {(x[0], y[0] + w): (x[1], y[1] + w)} t...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def AH_polytope_vertices(P,N=200,epsilon=0.001,solver=\"Gurobi\"):\n try:\n P.vertices_2D\n if type(P.vertices_2D) == type(None):\n raise Exception\n except:\n Q=pp.to_AH_polytope(P)\n v=np.empty((N,2))\n prog=MP.MathematicalProgram()\n zeta=prog.NewContin...
[ "0.57646203", "0.5670267", "0.5659422", "0.5649031", "0.5645295", "0.5642635", "0.5558218", "0.5536285", "0.5507396", "0.5487818", "0.548102", "0.54647756", "0.54523736", "0.54472464", "0.5441451", "0.5440161", "0.54328644", "0.54283845", "0.54261845", "0.540085", "0.538319",...
0.64187914
0
Initializes the model with weights and bias Conv layers get random weights from a normal distribution and bias is set to 0
def _initialize_weights(self): for m in self.modules(): if isinstance(m, nn.Conv2d): m.weight.data.normal_(0, 0.05) if m.bias is not None: m.bias.data.zero_()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def weights_init(model):\n classname = model.__class__.__name__\n if classname.find('Conv') != -1:\n nn.init.normal_(model.weight.data, 0.0, 0.02)\n elif classname.find('BatchNorm') != -1:\n nn.init.normal_(model.weight.data, 1.0, 0.02)\n nn.init.constant_(model.bias.data, 0)", "def...
[ "0.7880966", "0.77078766", "0.76977557", "0.7682001", "0.7630087", "0.7623425", "0.7612172", "0.7602894", "0.7602894", "0.7602894", "0.75905013", "0.7564779", "0.7564779", "0.75269467", "0.7512145", "0.751193", "0.75105506", "0.75105506", "0.75105506", "0.7505411", "0.748072"...
0.7725655
1
Iterates the model for a single batch of data, calculates the loss and updates the model parameters.
def step(self, data: torch.Tensor) -> Tuple: image, _ = data image = image.to(self.device) batch_size = image.shape[0] label = torch.full( (batch_size,), self.label, dtype=torch.float, device=self.device ) self.zero_grad() # Forward pass ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _step(self):\n # Make a minibatch of training data\n num_train = self.X_train.shape[0]\n # random choose the samples\n batch_mask = np.random.choice(num_train, self.batch_size)\n X_batch = self.X_train[batch_mask]\n y_batch = self.y_train[batch_mask]\n\n # Compu...
[ "0.7212915", "0.7017608", "0.6971652", "0.6964363", "0.69216657", "0.69077504", "0.6877378", "0.6855926", "0.68448675", "0.6819717", "0.6796839", "0.6751691", "0.67510575", "0.6746935", "0.6739293", "0.6734196", "0.6725004", "0.67016226", "0.66975546", "0.66851646", "0.667173...
0.0
-1
Test that int coefficients list is the same as int args.
def test_polynomial_from_int_list_same_as_from_int_args(self): coeffs = list(range(10)) p1 = Polynomial(coeffs) p2 = Polynomial(*coeffs) self.assertEqual(p1, p2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_polynomial_from_complex_list_same_as_from_complex_args(self):\n coeffs = [1j, 2j, 3j, 4j, 5j]\n\n p1 = Polynomial(coeffs)\n p2 = Polynomial(*coeffs)\n\n self.assertEqual(p1, p2)", "def test_polynomial_from_float_list_same_as_from_float_args(self):\n coeffs = [1.0, 2.0,...
[ "0.6644739", "0.65174896", "0.63068694", "0.6154316", "0.6090756", "0.6005572", "0.5953733", "0.59250826", "0.58949125", "0.5890805", "0.58439744", "0.5775465", "0.56965137", "0.56900537", "0.56873983", "0.5670121", "0.5649684", "0.56389946", "0.5596872", "0.5583224", "0.5582...
0.7663754
0
Test that float coefficients list is the same as float args.
def test_polynomial_from_float_list_same_as_from_float_args(self): coeffs = [1.0, 2.0, 3.0, 4.0, 5.0] p1 = Polynomial(coeffs) p2 = Polynomial(*coeffs) self.assertEqual(p1, p2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_float():\n floatify = fields.FloatField().adapt\n\n for input, expect in [\n (1.1, 1.1),\n (11, 11.0),\n (int(5.7), 5)\n ]:\n assert floatify(input) == expect", "def test_float_single_precision(self):\n data = service_call.encode_call(\"foo\", 1. + 1e-8)\n ...
[ "0.6789111", "0.66062117", "0.6594493", "0.65153867", "0.6490171", "0.6432928", "0.6408931", "0.63205534", "0.621962", "0.62155515", "0.6156101", "0.6154042", "0.6144872", "0.6143194", "0.61035675", "0.609526", "0.6072951", "0.6066457", "0.60082364", "0.60078156", "0.5991443"...
0.7843906
0
Test that complex coefficients list is the same as complex args.
def test_polynomial_from_complex_list_same_as_from_complex_args(self): coeffs = [1j, 2j, 3j, 4j, 5j] p1 = Polynomial(coeffs) p2 = Polynomial(*coeffs) self.assertEqual(p1, p2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_coefficients(self):\n\n coefs = self.cs.coefficients\n\n self.assertEqual(coefs, (1, 0, 1, 0, 0, -1))", "def complex_check(*args, func=None):\n func = func or inspect.stack()[2][3]\n for var in args:\n if not isinstance(var, numbers.Complex):\n name = type(var).__na...
[ "0.64052147", "0.63521355", "0.63007945", "0.62753785", "0.6151941", "0.61271626", "0.61183167", "0.61162865", "0.611375", "0.61096394", "0.6094857", "0.6062941", "0.6048559", "0.60343206", "0.5961963", "0.589964", "0.58850867", "0.58730483", "0.5854286", "0.583472", "0.58049...
0.76808316
0
Test that char coefficients list is the same as string args.
def test_polynomial_from_string_the_same_as_string_args(self): coeffs = "abcdefghijklmnopqrstuvwxyz" p1 = Polynomial(coeffs) p2 = Polynomial(*coeffs) self.assertEqual(p1, p2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_polynomial_from_complex_list_same_as_from_complex_args(self):\n coeffs = [1j, 2j, 3j, 4j, 5j]\n\n p1 = Polynomial(coeffs)\n p2 = Polynomial(*coeffs)\n\n self.assertEqual(p1, p2)", "def test_polynomial_from_float_list_same_as_from_float_args(self):\n coeffs = [1.0, 2.0,...
[ "0.6426459", "0.62890345", "0.61752516", "0.57198757", "0.5683991", "0.56493175", "0.55491936", "0.5545193", "0.5514456", "0.54702836", "0.5439413", "0.5420576", "0.5401311", "0.5392905", "0.5379616", "0.5357651", "0.534969", "0.53487754", "0.5347308", "0.53468424", "0.532293...
0.70586073
0
Test leading terms with coefficients equal to zero are removed.
def test_leading_zeroes_are_removed(self): p1 = Polynomial(1, 2, 3, 0) p2 = Polynomial(0, 0, 0, 1, 2, 3, 0) self.assertEqual(repr(p1), repr(p2)) self.assertEqual(str(p1), str(p2)) self.assertEqual(p1, p2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def RemoveZeroVar(chain):\n return chain[:, np.invert((np.sum(np.var(chain, axis=0), axis=1)<1e-10)), :]", "def RemoveZeroVar(chain):\n\treturn chain[:, np.invert((np.sum(np.var(chain, axis=0), axis=1)<1e-10)), :]", "def filter_zeros(X):\n\tnoNonzeros = np.count_nonzero(X, axis=1)\n\tmask = np.where(noNonze...
[ "0.6658199", "0.661656", "0.6323092", "0.63190866", "0.63174623", "0.63161105", "0.62660897", "0.614358", "0.59933215", "0.5926543", "0.5891914", "0.58808076", "0.5664288", "0.56272715", "0.5626824", "0.5616741", "0.5593082", "0.5560264", "0.55594355", "0.55326587", "0.551336...
0.64608777
2
Test that the default Monomial is 'x'.
def test_default_monomial_is_x(self): m = Monomial() expect = Monomial(1, 1) self.assertEqual(repr(expect), repr(m)) self.assertEqual(str(expect), str(m)) self.assertEqual(expect, m)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_binomial_default_init(self):\n expected = Polynomial(1, 1, 0)\n\n b = Binomial()\n\n self.assertEqual(expected, b)", "def test_binomial(self):\n with Model() as model:\n Binomial('x', 10, 0.5)\n steps = assign_step_methods(model, [])\n assert isin...
[ "0.6709728", "0.6651543", "0.6318743", "0.6294019", "0.6075693", "0.6065729", "0.59952956", "0.597316", "0.5902657", "0.5834677", "0.57665014", "0.5745749", "0.57422376", "0.5699372", "0.5690261", "0.5690261", "0.56779015", "0.5614231", "0.5602316", "0.5587988", "0.55691445",...
0.82594764
0
Test that the default Constant is '1'.
def test_default_constant_is_one(self): c = Constant() expect = Constant(1) self.assertEqual(expect, c)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def constant(_):\n return 1.", "def test_default(self):\r\n self.assertEqual(self.option.default, 1234)", "def test_constant(x):\n return 18 * x", "def test_const(self):\n\n constvar = const(232)\n for x in constvar.sample(1000):\n self.assertEqual(x, 232)", "def test_...
[ "0.687723", "0.6777304", "0.6772265", "0.66257215", "0.6550163", "0.6449326", "0.64484346", "0.64447016", "0.6430842", "0.6398146", "0.63644564", "0.63301975", "0.6204521", "0.6198143", "0.6190211", "0.61711526", "0.6158516", "0.61557084", "0.61342233", "0.61279845", "0.60566...
0.8484716
0
Test that a binomial is successfully initialized from monomials.
def test_binomial_init_from_monomials(self): m1 = Monomial(3, 3) m2 = Monomial(4, 4) t1 = (3, 3) t2 = (4, 4) expected = Polynomial([m1, m2], from_monomials=True) b1 = Binomial(m1, m2) b2 = Binomial(t1, t2) self.assertEqual(expected, b1) self.asse...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_binomial_default_init(self):\n expected = Polynomial(1, 1, 0)\n\n b = Binomial()\n\n self.assertEqual(expected, b)", "def test_linear_binomial_init(self):\n a, b = 6, 9\n expected = Polynomial(a, b)\n\n lb = LinearBinomial(a, b)\n\n self.assertEqual(expec...
[ "0.77222264", "0.7684172", "0.75849617", "0.73196894", "0.70824516", "0.68907064", "0.67966276", "0.6383654", "0.6381743", "0.6369938", "0.62478167", "0.6190149", "0.6160251", "0.61240447", "0.61185217", "0.6089801", "0.6064514", "0.6060454", "0.60261905", "0.6021926", "0.599...
0.8368487
0
Test that the default binomial is 'x^2 + x'.
def test_binomial_default_init(self): expected = Polynomial(1, 1, 0) b = Binomial() self.assertEqual(expected, b)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_binomial(self):\r\n # Check over two calls to see if the random state is correctly updated.\r\n rng_R = random_state_type()\r\n # Use non-default parameters, and larger dimensions because of\r\n # the integer nature of the result\r\n post_r, bin = binomial(rng_R, (7, 12)...
[ "0.71698135", "0.7143859", "0.7033473", "0.699451", "0.67489547", "0.64821094", "0.6462715", "0.6461001", "0.6435561", "0.64303493", "0.6430253", "0.6393817", "0.63917583", "0.6366536", "0.63607436", "0.62750036", "0.623247", "0.62285364", "0.6214193", "0.61374", "0.6132766",...
0.73975796
0
Test that a linear binomial is successfully initialized.
def test_linear_binomial_init(self): a, b = 6, 9 expected = Polynomial(a, b) lb = LinearBinomial(a, b) self.assertEqual(expected, lb)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_linear_binomial_default_init(self):\n expected = Polynomial(1, 1)\n\n b = LinearBinomial()\n\n self.assertEqual(expected, b)", "def test_binomial_default_init(self):\n expected = Polynomial(1, 1, 0)\n\n b = Binomial()\n\n self.assertEqual(expected, b)", "def t...
[ "0.811033", "0.77347654", "0.7542717", "0.73373723", "0.71329874", "0.68804437", "0.63971347", "0.6260769", "0.61828727", "0.6143738", "0.6031708", "0.6009319", "0.59835136", "0.5914772", "0.5914414", "0.5891909", "0.5872258", "0.58556885", "0.58434486", "0.5841006", "0.58192...
0.86035264
0
Test that the default linear binomial is 'x + 1'.
def test_linear_binomial_default_init(self): expected = Polynomial(1, 1) b = LinearBinomial() self.assertEqual(expected, b)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_linear_binomial_init(self):\n a, b = 6, 9\n expected = Polynomial(a, b)\n\n lb = LinearBinomial(a, b)\n\n self.assertEqual(expected, lb)", "def test_binomial_default_init(self):\n expected = Polynomial(1, 1, 0)\n\n b = Binomial()\n\n self.assertEqual(expe...
[ "0.7473286", "0.7114862", "0.7019656", "0.6945343", "0.6914386", "0.6560414", "0.65247864", "0.6313171", "0.63047546", "0.6264179", "0.6236071", "0.6144576", "0.6119696", "0.6113437", "0.60729533", "0.604535", "0.60433036", "0.5990155", "0.5965983", "0.592644", "0.58875066", ...
0.7432039
1
Test that a trinomial is successfully initialized from monomials.
def test_trinomial_init_from_monomials(self): m1 = Monomial(3, 3) m2 = Monomial(4, 4) m3 = Monomial(5, 5) expected = Polynomial([m1, m2, m3], from_monomials=True) t = Trinomial(m1, m2, m3) self.assertEqual(expected, t)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_trinomial_default_init(self):\n expected = Polynomial(1, 1, 1, 0)\n\n t = Trinomial()\n\n self.assertEqual(expected, t)", "def test_binomial_init_from_monomials(self):\n m1 = Monomial(3, 3)\n m2 = Monomial(4, 4)\n t1 = (3, 3)\n t2 = (4, 4)\n expect...
[ "0.7607789", "0.70820785", "0.68559223", "0.6678353", "0.66027355", "0.65215725", "0.6508552", "0.6466536", "0.63836294", "0.6359102", "0.6238134", "0.6004065", "0.5979927", "0.59176403", "0.5879079", "0.58340746", "0.575583", "0.57349175", "0.5723228", "0.56603", "0.5614115"...
0.85773104
0
Test that the default trinomial is 'x^3 + x^2 + x'.
def test_trinomial_default_init(self): expected = Polynomial(1, 1, 1, 0) t = Trinomial() self.assertEqual(expected, t)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_trinomial_init_from_monomials(self):\n m1 = Monomial(3, 3)\n m2 = Monomial(4, 4)\n m3 = Monomial(5, 5)\n expected = Polynomial([m1, m2, m3], from_monomials=True)\n\n t = Trinomial(m1, m2, m3)\n\n self.assertEqual(expected, t)", "def test_quadratic_trinomial_init...
[ "0.7251187", "0.6777519", "0.66679484", "0.61904955", "0.5993573", "0.5939095", "0.59343827", "0.5921262", "0.5867161", "0.5856125", "0.5820007", "0.5761722", "0.57567984", "0.5751864", "0.5721351", "0.5682329", "0.55713683", "0.55346286", "0.54696476", "0.54348075", "0.54323...
0.7325828
0
Test that a quadratic trinomial is successfully initialized.
def test_quadratic_trinomial_init(self): a, b, c = 2, 3, 4 expected = Polynomial(a, b, c) qt = QuadraticTrinomial(a, b, c) self.assertEqual(expected, qt)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_quadratic_trinomial_default_init(self):\n expected = Polynomial(1, 1, 1)\n\n qt = QuadraticTrinomial()\n\n self.assertEqual(expected, qt)", "def test_trinomial_default_init(self):\n expected = Polynomial(1, 1, 1, 0)\n\n t = Trinomial()\n\n self.assertEqual(expec...
[ "0.82322776", "0.74678355", "0.7265662", "0.70847714", "0.69415426", "0.6507963", "0.61808145", "0.61517614", "0.59596646", "0.5930612", "0.58924574", "0.58751446", "0.58665466", "0.58505654", "0.5826098", "0.5792503", "0.5769304", "0.5746371", "0.57374394", "0.5714344", "0.5...
0.87185836
0
Test that the default quadratic trinomial is 'x^2 + x + 1'.
def test_quadratic_trinomial_default_init(self): expected = Polynomial(1, 1, 1) qt = QuadraticTrinomial() self.assertEqual(expected, qt)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_quadratic_trinomial_init(self):\n a, b, c = 2, 3, 4\n expected = Polynomial(a, b, c)\n\n qt = QuadraticTrinomial(a, b, c)\n\n self.assertEqual(expected, qt)", "def test_trinomial_default_init(self):\n expected = Polynomial(1, 1, 1, 0)\n\n t = Trinomial()\n\n ...
[ "0.7804595", "0.69539523", "0.6805754", "0.64076424", "0.6281322", "0.61109155", "0.6068319", "0.5887185", "0.58835185", "0.58297175", "0.574804", "0.56945467", "0.5653709", "0.5635208", "0.55781317", "0.5573634", "0.5558299", "0.5552016", "0.55515176", "0.5544936", "0.553825...
0.7712339
1
Test that LinearBinomial(0, ?) raises a ValueError.
def test_linear_binomial_fails_leading_zero(self): self.assertRaises(ValueError, LinearBinomial, 0, 1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_monomial_degree_positive_int(self):\n self.assertRaises(ValueError, Monomial, 1, -1)\n self.assertRaises(ValueError, Monomial, 1, 1.2)", "def test_quadratic_trinomial_fails_leading_zero(self):\n self.assertRaises(ValueError, QuadraticTrinomial, 0, 1)", "def test_linear_binomial_in...
[ "0.72467434", "0.6912627", "0.6889316", "0.6815802", "0.6526083", "0.64662707", "0.64544886", "0.64476573", "0.62807524", "0.6230934", "0.6198869", "0.61734957", "0.6163279", "0.6097373", "0.60639113", "0.60281086", "0.6027279", "0.60225606", "0.6016836", "0.60164136", "0.601...
0.881032
0
Test that QuadraticTrinomial(0, ?) raises a ValueError.
def test_quadratic_trinomial_fails_leading_zero(self): self.assertRaises(ValueError, QuadraticTrinomial, 0, 1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_quadratic_trinomial_init(self):\n a, b, c = 2, 3, 4\n expected = Polynomial(a, b, c)\n\n qt = QuadraticTrinomial(a, b, c)\n\n self.assertEqual(expected, qt)", "def test_quadratic_trinomial_default_init(self):\n expected = Polynomial(1, 1, 1)\n\n qt = QuadraticTr...
[ "0.7169448", "0.6849368", "0.6651373", "0.6453824", "0.6274508", "0.6258277", "0.62512386", "0.6169402", "0.6141827", "0.6130322", "0.612695", "0.6112168", "0.6083564", "0.60681117", "0.60681117", "0.60443914", "0.6040365", "0.599971", "0.599907", "0.59918", "0.59833556", "...
0.88411075
0
Test that monomial only accepts a positive int.
def test_monomial_degree_positive_int(self): self.assertRaises(ValueError, Monomial, 1, -1) self.assertRaises(ValueError, Monomial, 1, 1.2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_linear_binomial_fails_leading_zero(self):\n self.assertRaises(ValueError, LinearBinomial, 0, 1)", "def assert_positive(x):\n \n assert(all(x) >= 0)", "def _is_non_negative_int(item):\n if not isinstance(item, int):\n return False\n return item >= 0", "def one_positive(self)...
[ "0.64496636", "0.64230645", "0.6393725", "0.6347339", "0.63327885", "0.6302501", "0.6286961", "0.62112695", "0.6187927", "0.6166724", "0.6150532", "0.6146198", "0.608574", "0.6075579", "0.60420036", "0.60391825", "0.6016536", "0.6016526", "0.6011341", "0.60089564", "0.5978152...
0.76611537
0
Test that Polynomial from monomials with > 2 tuples fails.
def test_polynomial_with_non_monomial_terms(self): self.assertRaises( TypeError, Polynomial, [(1, 2, 3)], from_monomials=True )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test():\n assert str(Polynomial(0, 1, 0, -1, 4, -2, 0, 1, 3, 0)) == \"3x^8 + x^7 - 2x^5 + 4x^4 - x^3 + x\"\n assert str(Polynomial([-5, 1, 0, -1, 4, -2, 0, 1, 3, 0])) == \"3x^8 + x^7 - 2x^5 + 4x^4 - x^3 + x - 5\"\n assert str(Polynomial(x7=1, x4=4, x8=3, x9=0, x0=0, x5=-2, x3=-1, x1=1)) == \"3x^8 + x^...
[ "0.6752848", "0.66205114", "0.6448485", "0.6309701", "0.619733", "0.6101042", "0.6054037", "0.60104465", "0.59679574", "0.59433794", "0.591065", "0.59005946", "0.58211356", "0.5815051", "0.5810266", "0.5763252", "0.57513654", "0.5706983", "0.5669737", "0.5645254", "0.56404215...
0.7779006
0
Returns True if word[i] is a consonant, False otherwise
def _is_consonant(self, word, i): if word[i] in self.vowels: return False if word[i] == "y": if i == 0: return True else: return not self._is_consonant(word, i - 1) return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_consonant(text):\n return text.lower() in AVRO_CONSONANTS", "def is_consonant(x):\n if is_vowel(x) == True:\n return False\n elif len(x) > 1 or type(x) == int:\n return False", "def basic_check(word):\n if word[-1] == \"b\" or word[-1] == \"g\":\n return False\n conso...
[ "0.756881", "0.7266516", "0.70983154", "0.66584325", "0.64638054", "0.63225394", "0.63023937", "0.6296", "0.606454", "0.6029257", "0.5995777", "0.59618133", "0.58478487", "0.5808676", "0.57903886", "0.5783822", "0.5721623", "0.56929076", "0.5665967", "0.5625816", "0.55507475"...
0.87187904
0
r"""Returns the 'measure' of stem, per definition in the paper
def _measure(self, stem): cv_sequence = "" # Construct a string of 'c's and 'v's representing whether each # character in `stem` is a consonant or a vowel. # e.g. 'falafel' becomes 'cvcvcvc', # 'architecture' becomes 'vcccvcvccvcv' for i in range(len(stem)): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getStem(self,):\n\t\treturn self.stem;", "def stem(self) -> str:", "def stemWord(self,word):\n if(\"stem\" in self._classes):\n return self._stem.stemmingWord(word)", "def stem(s):\r\n if len(s) < 5 :\r\n return s\r\n \r\n if s[-3:] == 'ing':\r\n if s[-4] == s[-5]...
[ "0.71413904", "0.6885746", "0.6649694", "0.65597755", "0.64486533", "0.6432257", "0.63764393", "0.6274381", "0.6102599", "0.60810894", "0.6079473", "0.6050913", "0.5986306", "0.5979911", "0.5979911", "0.5920591", "0.5897531", "0.58566743", "0.58331126", "0.58018064", "0.57997...
0.725565
0
Returns True if stem contains a vowel, else False
def _contains_vowel(self, stem): for i in range(len(stem)): if not self._is_consonant(stem, i): return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_vowel(text):\n return text.lower() in AVRO_VOWELS", "def is_vowel(self, letter):\n\n if letter in (\"a\", \"e\", \"i\", \"o\", \"u\", \"A\", \"E\", \"I\", \"O\", \"U\"):\n return True\n return False", "def isvowel(phone, semivowels=True):\n if semivowels:\n return (...
[ "0.774371", "0.7515274", "0.71859574", "0.71172595", "0.7006897", "0.6654589", "0.6616312", "0.6613333", "0.65657127", "0.6405958", "0.62813777", "0.6215642", "0.62133026", "0.6119609", "0.6114145", "0.61074984", "0.60806847", "0.60606885", "0.6021445", "0.6012325", "0.600550...
0.8641102
0
Implements condition d from the paper Returns True if word ends with a double consonant
def _ends_double_consonant(self, word): return ( len(word) >= 2 and word[-1] == word[-2] and self._is_consonant(word, len(word) - 1) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _ends_cvc(self, word):\n return (\n len(word) >= 3\n and self._is_consonant(word, len(word) - 3)\n and not self._is_consonant(word, len(word) - 2)\n and self._is_consonant(word, len(word) - 1)\n and word[-1] not in (\"w\", \"x\", \"y\")\n ) o...
[ "0.7559633", "0.71442723", "0.70636475", "0.68884534", "0.68107796", "0.64119506", "0.6324027", "0.63016343", "0.62774265", "0.6181726", "0.6108568", "0.5940099", "0.59349805", "0.5891619", "0.58743113", "0.5873399", "0.58639944", "0.58625084", "0.583633", "0.57959324", "0.57...
0.86897075
0
Implements condition o from the paper
def _ends_cvc(self, word): return ( len(word) >= 3 and self._is_consonant(word, len(word) - 3) and not self._is_consonant(word, len(word) - 2) and self._is_consonant(word, len(word) - 1) and word[-1] not in ("w", "x", "y") ) or ( se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def condition(self) -> global___Expression:", "def condition(self) -> global___Expression:", "def condition(i,n,los):\n\n return i < n", "def conditions():\n pass", "def conditional(self) -> global___Statement.Conditional:", "def condition(self):\n return True", "def logic(self):\r\n ...
[ "0.75834596", "0.75834596", "0.68898284", "0.6680457", "0.6488428", "0.63894796", "0.63375384", "0.6156285", "0.61141753", "0.6024125", "0.602071", "0.5994629", "0.5994629", "0.59736264", "0.59429175", "0.59028864", "0.59028864", "0.5874801", "0.58645445", "0.58484", "0.58244...
0.0
-1
Replaces `suffix` of `word` with `replacement
def _replace_suffix(self, word, suffix, replacement): assert word.endswith(suffix), "Given word doesn't end with given suffix" if suffix == "": return word + replacement else: return word[: -len(suffix)] + replacement
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_suffix(word, suffix):\n suffix, sep, rest = suffix.partition(' ')\n expanded = _add_suffix(word, suffix)\n return expanded + sep + rest", "def suffix_replace(original, old, new):\n ...", "def replace_suffix (name, new_suffix):\n assert isinstance(name, basestring)\n assert isinstance(...
[ "0.7701713", "0.7665795", "0.66624486", "0.64749455", "0.63054746", "0.6149442", "0.61022633", "0.6039127", "0.6027953", "0.6017234", "0.59906757", "0.59685665", "0.5966546", "0.5966546", "0.5966546", "0.5966546", "0.5965606", "0.5955456", "0.59381366", "0.59128815", "0.58945...
0.89509475
0
Applies the first applicable suffixremoval rule to the word Takes a word and a list of suffixremoval rules represented as 3tuples, with the first element being the suffix to remove, the second element being the string to replace it with, and the final element being the condition for the rule to be applicable, or None i...
def _apply_rule_list(self, word, rules): for rule in rules: suffix, replacement, condition = rule if suffix == "*d" and self._ends_double_consonant(word): stem = word[:-2] if condition is None or condition(stem): return stem + replaceme...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def apply_rule(word):\n return re.sub(search, replace, word)", "def word_clean(self, word):\n word_ori = word\n if word not in self.vocab_list: # if the word is not in the vocabulary\n word = word.strip(\",.!?\") # delete punctuation, such as periods, commas\n for i in ra...
[ "0.6241091", "0.6044743", "0.58442014", "0.56673056", "0.5549546", "0.55156666", "0.5505275", "0.53335893", "0.53203624", "0.52443767", "0.5229112", "0.52215064", "0.5208779", "0.51806766", "0.51736385", "0.5163402", "0.51501673", "0.51331615", "0.5123183", "0.5071901", "0.50...
0.68673265
0
Implements Step 1a from "An algorithm for suffix stripping"
def _step1a(self, word): # this NLTK-only rule extends the original algorithm, so # that 'flies'->'fli' but 'dies'->'die' etc if self.mode == self.NLTK_EXTENSIONS: if word.endswith("ies") and len(word) == 4: return self._replace_suffix(word, "ies", "ie") retu...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def removesuffix(self, x) -> String:\n pass", "def strip_suffix(s, suffixes):\n for suffix in suffixes:\n if s.endswith(suffix):\n return s.rstrip(suffix)\n return s", "def FindSuffix(self):\n self.numSuffixes = 0\n self.forceStress = 0\n resultslist = []\n ...
[ "0.7110432", "0.6868396", "0.6854343", "0.6673925", "0.65046847", "0.64575976", "0.63519484", "0.6296716", "0.62657344", "0.6229608", "0.6207564", "0.6196186", "0.6186707", "0.6150748", "0.61226726", "0.6098476", "0.60928965", "0.60082465", "0.5958626", "0.5953981", "0.594008...
0.0
-1
Implements Step 1b from "An algorithm for suffix stripping"
def _step1b(self, word): # this NLTK-only block extends the original algorithm, so that # 'spied'->'spi' but 'died'->'die' etc if self.mode == self.NLTK_EXTENSIONS: if word.endswith("ied"): if len(word) == 4: return self._replace_suffix(word, "ied"...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def removesuffix(self, x) -> String:\n pass", "def strip_suffix(s, suffixes):\n for suffix in suffixes:\n if s.endswith(suffix):\n return s.rstrip(suffix)\n return s", "def FindSuffix(self):\n self.numSuffixes = 0\n self.forceStress = 0\n resultslist = []\n ...
[ "0.71120393", "0.6927874", "0.68953496", "0.6655125", "0.6539592", "0.64849085", "0.6369599", "0.6365083", "0.62968457", "0.6283579", "0.62531453", "0.6191985", "0.6188154", "0.6157653", "0.61504936", "0.6122239", "0.6086603", "0.6043726", "0.60027677", "0.59654695", "0.59466...
0.54680014
60
Implements Step 1c from "An algorithm for suffix stripping"
def _step1c(self, word): def nltk_condition(stem): """ This has been modified from the original Porter algorithm so that y->i is only done when y is preceded by a consonant, but not if the stem is only a single consonant, i.e. (*c and not c) Y -> ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def removesuffix(self, x) -> String:\n pass", "def strip_suffix(s, suffixes):\n for suffix in suffixes:\n if s.endswith(suffix):\n return s.rstrip(suffix)\n return s", "def FindSuffix(self):\n self.numSuffixes = 0\n self.forceStress = 0\n resultslist = []\n ...
[ "0.7151827", "0.7035866", "0.68370575", "0.6659626", "0.658684", "0.65657824", "0.6438374", "0.6393294", "0.638715", "0.633172", "0.62455475", "0.6197732", "0.61885804", "0.61792827", "0.61698663", "0.6149805", "0.61285746", "0.60832727", "0.60544956", "0.60506916", "0.597244...
0.0
-1
This has been modified from the original Porter algorithm so that y>i is only done when y is preceded by a consonant, but not if the stem is only a single consonant, i.e. (c and not c) Y > I So 'happy' > 'happi', but 'enjoy' > 'enjoy' etc This is a much better rule. Formerly 'enjoy'>'enjoi' and 'enjoyment'>'enjoy'. Ste...
def nltk_condition(stem): return len(stem) > 1 and self._is_consonant(stem, len(stem) - 1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stem(s):\n special = {'appall', 'kill', 'stroll', 'kiss', 'thrill', 'chugg', 'dress', 'err', 'express', 'fall', 'free', 'gall', 'add','cross', 'impress', 'inn', 'call', 'ball', 'bill', 'buzz'} \n ie_words = {'vying', 'lying', 'dying', 'tying'}\n short_ing = {'bring','sling','sping', 'bring', 'sing'...
[ "0.70180184", "0.6745574", "0.66085917", "0.6387136", "0.63155925", "0.62699425", "0.6264865", "0.60885984", "0.6063813", "0.58862096", "0.5852858", "0.5784101", "0.57241833", "0.57237595", "0.56696635", "0.5628905", "0.5615199", "0.5613108", "0.5591084", "0.5576031", "0.5508...
0.6145883
7
Implements Step 2 from "An algorithm for suffix stripping"
def _step2(self, word): if self.mode == self.NLTK_EXTENSIONS: # Instead of applying the ALLI -> AL rule after '(a)bli' per # the published algorithm, instead we apply it first, and, # if it succeeds, run the result through step2 again. if word.endswith("alli") an...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def removesuffix(self, x) -> String:\n pass", "def strip_suffix(s, suffixes):\n for suffix in suffixes:\n if s.endswith(suffix):\n return s.rstrip(suffix)\n return s", "def FindSuffix(self):\n self.numSuffixes = 0\n self.forceStress = 0\n resultslist = []\n ...
[ "0.7174014", "0.7044921", "0.6938263", "0.6760312", "0.6657653", "0.6591127", "0.6561763", "0.64970803", "0.6432604", "0.6431131", "0.63297945", "0.63296896", "0.63131934", "0.6276994", "0.6267812", "0.6217017", "0.617954", "0.61749345", "0.60950685", "0.6058206", "0.6054848"...
0.0
-1
Implements Step 3 from "An algorithm for suffix stripping"
def _step3(self, word): return self._apply_rule_list( word, [ ("icate", "ic", self._has_positive_measure), ("ative", "", self._has_positive_measure), ("alize", "al", self._has_positive_measure), ("iciti", "ic", self._has_pos...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def removesuffix(self, x) -> String:\n pass", "def strip_suffix(s, suffixes):\n for suffix in suffixes:\n if s.endswith(suffix):\n return s.rstrip(suffix)\n return s", "def FindSuffix(self):\n self.numSuffixes = 0\n self.forceStress = 0\n resultslist = []\n ...
[ "0.7154443", "0.69809604", "0.6785923", "0.6628499", "0.65961885", "0.6545103", "0.6521387", "0.6452334", "0.6346543", "0.63407284", "0.62667495", "0.6227932", "0.6224696", "0.6217707", "0.61861646", "0.615874", "0.6079407", "0.60647845", "0.604152", "0.60256207", "0.5979804"...
0.0
-1
Implements Step 4 from "An algorithm for suffix stripping" Step 4 (m>1) AL > revival > reviv (m>1) ANCE > allowance > allow (m>1) ENCE > inference > infer (m>1) ER > airliner > airlin (m>1) IC > gyroscopic > gyroscop (m>1) ABLE > adjustable > adjust (m>1) IBLE > defensible > defens (m>1) ANT > irritant > irrit (m>1) EM...
def _step4(self, word): measure_gt_1 = lambda stem: self._measure(stem) > 1 return self._apply_rule_list( word, [ ("al", "", measure_gt_1), ("ance", "", measure_gt_1), ("ence", "", measure_gt_1), ("er", "", measure_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strip_suffix(s, suffixes):\n for suffix in suffixes:\n if s.endswith(suffix):\n return s.rstrip(suffix)\n return s", "def FindSuffix(self):\n self.numSuffixes = 0\n self.forceStress = 0\n resultslist = []\n for f in self.suffixes.finditer(self.wd):\n ...
[ "0.6112485", "0.6055196", "0.58494586", "0.57650787", "0.57041234", "0.56558377", "0.55929184", "0.55482364", "0.54530394", "0.54426837", "0.5434866", "0.5426362", "0.53883106", "0.5387961", "0.5376159", "0.5358029", "0.5308571", "0.5295212", "0.52756095", "0.52300066", "0.52...
0.0
-1
Implements Step 5a from "An algorithm for suffix stripping"
def _step5a(self, word): # Note that Martin's test vocabulary and reference # implementations are inconsistent in how they handle the case # where two rules both refer to a suffix that matches the word # to be stemmed, but only the condition of the second one is # true. #...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def removesuffix(self, x) -> String:\n pass", "def strip_suffix(s, suffixes):\n for suffix in suffixes:\n if s.endswith(suffix):\n return s.rstrip(suffix)\n return s", "def FindSuffix(self):\n self.numSuffixes = 0\n self.forceStress = 0\n resultslist = []\n ...
[ "0.71540284", "0.6939131", "0.69001156", "0.66733253", "0.66010237", "0.65600574", "0.6411394", "0.63860726", "0.6374319", "0.6342698", "0.62385917", "0.62244904", "0.6186158", "0.616226", "0.6115118", "0.61146325", "0.6087781", "0.6084946", "0.60729676", "0.6071903", "0.6019...
0.0
-1
Implements Step 5a from "An algorithm for suffix stripping"
def _step5b(self, word): return self._apply_rule_list( word, [("ll", "l", lambda stem: self._measure(word[:-1]) > 1)] )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def removesuffix(self, x) -> String:\n pass", "def strip_suffix(s, suffixes):\n for suffix in suffixes:\n if s.endswith(suffix):\n return s.rstrip(suffix)\n return s", "def FindSuffix(self):\n self.numSuffixes = 0\n self.forceStress = 0\n resultslist = []\n ...
[ "0.71540284", "0.6939131", "0.69001156", "0.66733253", "0.66010237", "0.65600574", "0.6411394", "0.63860726", "0.6374319", "0.6342698", "0.62385917", "0.62244904", "0.6186158", "0.616226", "0.6115118", "0.61146325", "0.6087781", "0.6084946", "0.60729676", "0.6071903", "0.6019...
0.0
-1
A demonstration of the porter stemmer on a sample from the Penn Treebank corpus.
def demo(): from nltk import stem from nltk.corpus import treebank stemmer = stem.PorterStemmer() orig = [] stemmed = [] for item in treebank.fileids()[:3]: for (word, tag) in treebank.tagged_words(item): orig.append(word) stemmed.append(stemmer.stem(word)) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_stemming():\n normalizer = TextNormalizer(stem=True, lemmatize=False)\n assert normalizer.transform([[\"running\"]])[\"corpus\"][0] == [\"run\"]", "def stemming(self,sentence):", "def stemming(data):\n stemmer = PorterStemmer()\n tokens = word_tokenize(str(data))\n new = \"\"\n for w...
[ "0.66189396", "0.60756886", "0.59906495", "0.5933146", "0.586991", "0.58544207", "0.579849", "0.5790065", "0.57402635", "0.57275397", "0.56813854", "0.56547403", "0.55455273", "0.55287206", "0.55226535", "0.547887", "0.545246", "0.541334", "0.53944755", "0.539182", "0.5376576...
0.73346746
0
Autoencoder on the MNIST data set
def my_model(features, labels, mode, params): #input layer input_layer = tf.reshape(features["x"], [-1, num_input]) net = input_layer #Encoder for units in params['autoenc_units']: net = tf.layers.dense(net, units=units, activation=tf.sigmoid, use_bias=True) net = tf.layers.dense(n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def auto_encoder(data: np.ndarray) -> np.ndarray:\n input_img = Input(shape=(784,))\n encoded = Dense(128, activation='relu')(input_img)\n encoded = Dense(64, activation='relu')(encoded)\n encoded = Dense(32, activation='relu')(encoded)\n\n decoded = Dense(64, activation='relu')(encoded)\n decode...
[ "0.7200988", "0.6723397", "0.6663144", "0.66376185", "0.65676796", "0.65568644", "0.64852685", "0.6439443", "0.6413675", "0.6366824", "0.63295513", "0.6324487", "0.6312767", "0.63117355", "0.6298141", "0.6278324", "0.6252111", "0.61931074", "0.61367524", "0.6129784", "0.60892...
0.0
-1
Return username and circle.
def __str__(self): return 'Shipment #{} whith package #{}'.format( self.shipment.pk, self.package.pk, )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def username(self) -> str:", "def username(self) -> str:", "def get_name(username):\n print(\"We halo \" + username + \" , piye kabare?\")", "def get_user_info_by_name(self, username: str) -> dict:", "def get_userinfo():\n import socket\n import os \n import time\n\n hostname = socket.getho...
[ "0.6529795", "0.6529795", "0.6385549", "0.5929949", "0.5916509", "0.5915624", "0.5914403", "0.58779097", "0.58395433", "0.5786138", "0.57843494", "0.57522917", "0.57485974", "0.571082", "0.5698436", "0.56953645", "0.56304526", "0.56168526", "0.5596225", "0.5596225", "0.558747...
0.0
-1
Utility to make CompeteExperiment instance with HyperGBM.
def make_experiment(train_data, target=None, eval_data=None, test_data=None, task=None, id=None, callbacks=None, searcher=None, search_space=None, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_model(n_estimators=100, max_depth=3, learning_rate=0.1):\n n_estimators = int(n_estimators)\n max_depth = int(max_depth)\n\n xgb = XGBClassifier(\n max_depth=max_depth,\n n_estimators=n_estimators,\n learning_rate=learning_rate,\n n_jobs=4, # S...
[ "0.57217205", "0.54344875", "0.53623545", "0.5332581", "0.5328322", "0.5291525", "0.5282335", "0.5249221", "0.5209219", "0.519198", "0.51718086", "0.51625144", "0.5155", "0.5141992", "0.50965846", "0.5070264", "0.5041546", "0.5023969", "0.5018331", "0.50119567", "0.50007975",...
0.5751189
0
method to extract token from the Authorization header
def extract_bearer_token(request): return request.headers['Authorization'].split(" ")[-1].strip()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_token_auth_header():\n auth = request.headers.get(\"Authorization\", None)\n if not auth:\n return \"authorization_header_missing\"\n\n parts = auth.split()\n\n if parts[0].lower() != \"bearer\":\n return \"invalid_header\"\n elif len(parts) == 1:\n return \"invalid_head...
[ "0.84299767", "0.84009445", "0.8395567", "0.83108723", "0.8233791", "0.82143587", "0.81781316", "0.8138437", "0.79267466", "0.7818896", "0.7775216", "0.77675885", "0.77000767", "0.76513875", "0.7575239", "0.7444681", "0.7417673", "0.7381695", "0.7370867", "0.72474146", "0.723...
0.8390992
3
Add an Agent object to the schedule and logger.
def add(self, agent): self._agents[agent.unique_id] = agent self.logger.add(agent)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def append(self, agent):\n self.agents.append(agent)", "def add_transport(self, agent):\n with self.simulation_mutex:\n self.get(\"transport_agents\")[agent.name] = agent", "def add_manager(self, agent):\n with self.simulation_mutex:\n self.get(\"manager_agents\")[age...
[ "0.70725477", "0.6694526", "0.64406854", "0.63798493", "0.62856185", "0.62606156", "0.614796", "0.60502934", "0.60470253", "0.58610034", "0.5816065", "0.5804319", "0.5753335", "0.57344615", "0.5694131", "0.56772673", "0.5663141", "0.5599108", "0.5599108", "0.55642706", "0.555...
0.7993833
0
Get agents' belief and interaction history, respectively.
def logs(self): return self.logger.logs()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_history(self):\r\n\r\n return self.board_history", "def get_history(self):\n return self.history", "def history(self):\n return self.board.history", "def get_action_history(self):\n\t\treturn self._action_history", "def history(self):\n return self.info['history']", "def _...
[ "0.64450026", "0.6385849", "0.6332744", "0.62916195", "0.62715936", "0.61747575", "0.61431235", "0.61431235", "0.61320794", "0.60951924", "0.5958087", "0.5838318", "0.58224434", "0.5807819", "0.58053684", "0.57923603", "0.5774104", "0.5766799", "0.56772685", "0.5628197", "0.5...
0.0
-1
Chooses pair of neighboring agents for interaction.
def choose(self): # pick agent A keys = list(self._agents.keys()) keyA = random.choice(keys) agentA = self.model.schedule.agents[keyA] # pick pick agent B keyB = random.choice(agentA.neighbors) agentB = self.model.schedule.agents[keyB] return agentA, age...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getNeighbors(self, current: MstarNode):\n neighbors = []\n options = []\n # Loop over all the agents\n for i in range(self.n_agents):\n node: Node = current.nodes[i]\n options_i = []\n if i in current.collision_set:\n # If the agent in...
[ "0.6246131", "0.6160659", "0.6013721", "0.5978769", "0.59235823", "0.59171003", "0.5906191", "0.58011556", "0.5798789", "0.5789229", "0.5733525", "0.57054895", "0.5646919", "0.563309", "0.5606196", "0.55937165", "0.5591221", "0.55759096", "0.5569078", "0.5550985", "0.55452394...
0.6392958
0
Increments the timer for all agents, then lets one pair of agents interact.
def step(self): #_increment timers for agent in self.agents: agent.tick() # choose agent pair agentA, agentB = self.choose() # interact agentA.step(agentB) agentB.step(agentA) # log results self.logger.log(agentA, agentB) # ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def take_one_step(self):\n\t\tfor i in range(len(self.agents)):\n\t\t\tself.agents[i].action(0)", "def _advance_by_action(game, agents, action):\n getLogger(__name__).debug(\"Agent {} action {}\".format(game.current_agent_id, action))\n agent_id_for_action = game.current_agent_id\n\n game.ta...
[ "0.65375125", "0.6455464", "0.64317334", "0.6098815", "0.6074385", "0.60499936", "0.59659934", "0.58917546", "0.58917546", "0.58714443", "0.5799771", "0.57929397", "0.5773467", "0.5762189", "0.57041514", "0.56671137", "0.566299", "0.5604475", "0.5582845", "0.5573922", "0.5562...
0.7061951
0
No. 1 tests collection for Practitioner.
def test_practitioner_1(base_settings): filename = base_settings["unittest_data_dir"] / "practitioner-example-f203-jvg.json" inst = practitioner.Practitioner.parse_file( filename, content_type="application/json", encoding="utf-8" ) assert "Practitioner" == inst.resource_type impl_practition...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tests():", "def test(self):\n # -- Test --\n\n # (1)\n\n # (2)\n\n # (3)\n\n # (4)\n # -- Test --", "def test_get_learners(self):\n pass", "def spec_tests():\n pass", "def testBeliefs1sk(self):", "def test(self):\n pass", "def _test(self):\...
[ "0.7134564", "0.6787694", "0.6755833", "0.6700649", "0.6694151", "0.66736376", "0.6638133", "0.6638133", "0.6638133", "0.6630275", "0.6590062", "0.6564321", "0.65413755", "0.65291166", "0.65291166", "0.65291166", "0.65291166", "0.65291166", "0.64992297", "0.6488366", "0.64004...
0.59895766
80
No. 2 tests collection for Practitioner.
def test_practitioner_2(base_settings): filename = base_settings["unittest_data_dir"] / "practitioner-example-f201-ab.json" inst = practitioner.Practitioner.parse_file( filename, content_type="application/json", encoding="utf-8" ) assert "Practitioner" == inst.resource_type impl_practitione...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tests():", "def test(self):\n # -- Test --\n\n # (1)\n\n # (2)\n\n # (3)\n\n # (4)\n # -- Test --", "def test_get_learners(self):\n pass", "def test(self):\n pass", "def spec_tests():\n pass", "def _test(self):\n pass", "def _test(se...
[ "0.7369992", "0.69981796", "0.68859595", "0.688489", "0.68792", "0.68766", "0.68766", "0.68766", "0.6846748", "0.6835696", "0.6835696", "0.6835696", "0.6835696", "0.6835696", "0.67921025", "0.67522293", "0.6719341", "0.6693692", "0.6656919", "0.6596785", "0.6596785", "0.657...
0.6226182
70
No. 3 tests collection for Practitioner.
def test_practitioner_3(base_settings): filename = base_settings["unittest_data_dir"] / "practitioner-example-f202-lm.json" inst = practitioner.Practitioner.parse_file( filename, content_type="application/json", encoding="utf-8" ) assert "Practitioner" == inst.resource_type impl_practitione...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tests():", "def test(self):\n # -- Test --\n\n # (1)\n\n # (2)\n\n # (3)\n\n # (4)\n # -- Test --", "def test_3():", "def test_get_learners(self):\n pass", "def alltests(opts):\n \n print \"API Root: %s\" % options.apiroot\n print \"Token: %s\"...
[ "0.7311619", "0.69389737", "0.6782225", "0.674639", "0.6690336", "0.66903013", "0.6686184", "0.6657042", "0.66540545", "0.66537106", "0.6646451", "0.6646451", "0.6600782", "0.6578841", "0.6571164", "0.6571164", "0.6571164", "0.65693885", "0.6556365", "0.6556365", "0.6556365",...
0.6419828
30
No. 4 tests collection for Practitioner.
def test_practitioner_4(base_settings): filename = ( base_settings["unittest_data_dir"] / "practitioner-example-xcda-author.json" ) inst = practitioner.Practitioner.parse_file( filename, content_type="application/json", encoding="utf-8" ) assert "Practitioner" == inst.resource_type ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tests():", "def test(self):\n # -- Test --\n\n # (1)\n\n # (2)\n\n # (3)\n\n # (4)\n # -- Test --", "def test_4():", "def test_get_learners(self):\n pass", "def test(self):\n pass", "def _test(self):\n pass", "def _test(self):\n ...
[ "0.72248155", "0.6968816", "0.6848714", "0.676003", "0.67274076", "0.66989803", "0.66989803", "0.66989803", "0.6687554", "0.6668544", "0.66536045", "0.6637639", "0.6606794", "0.66046673", "0.6600896", "0.6600896", "0.6600896", "0.6600896", "0.6600896", "0.6581954", "0.6569555...
0.64884555
26
No. 5 tests collection for Practitioner.
def test_practitioner_5(base_settings): filename = base_settings["unittest_data_dir"] / "practitioner-example-f003-mv.json" inst = practitioner.Practitioner.parse_file( filename, content_type="application/json", encoding="utf-8" ) assert "Practitioner" == inst.resource_type impl_practitione...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tests():", "def test_5():", "def test(self):\n # -- Test --\n\n # (1)\n\n # (2)\n\n # (3)\n\n # (4)\n # -- Test --", "def test_get_learners(self):\n pass", "def test_generate_all_testing(self):\n pass", "def spec_tests():\n pass", "def test...
[ "0.7314952", "0.6887173", "0.6877993", "0.67968845", "0.67604977", "0.67196435", "0.6707374", "0.6702602", "0.6698803", "0.66764206", "0.66610456", "0.66610456", "0.66610456", "0.6585562", "0.6567697", "0.6567697", "0.6567697", "0.6567697", "0.6567697", "0.6557706", "0.654831...
0.62826437
42
No. 6 tests collection for Practitioner.
def test_practitioner_6(base_settings): filename = base_settings["unittest_data_dir"] / "practitioner-example-f002-pv.json" inst = practitioner.Practitioner.parse_file( filename, content_type="application/json", encoding="utf-8" ) assert "Practitioner" == inst.resource_type impl_practitione...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tests():", "def test(self):\n # -- Test --\n\n # (1)\n\n # (2)\n\n # (3)\n\n # (4)\n # -- Test --", "def test_generate_all_testing(self):\n pass", "def spec_tests():\n pass", "def test(self):\n pass", "def test_get_learners(self):\n pa...
[ "0.7326869", "0.690404", "0.6839643", "0.6751121", "0.67465395", "0.6719968", "0.67097247", "0.66961044", "0.66961044", "0.66961044", "0.6691932", "0.66904056", "0.66563714", "0.6630362", "0.6630362", "0.6630362", "0.6630362", "0.6630362", "0.66246873", "0.6598546", "0.656255...
0.6458022
27
No. 7 tests collection for Practitioner.
def test_practitioner_7(base_settings): filename = base_settings["unittest_data_dir"] / "practitioner-example.json" inst = practitioner.Practitioner.parse_file( filename, content_type="application/json", encoding="utf-8" ) assert "Practitioner" == inst.resource_type impl_practitioner_7(inst...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tests():", "def test(self):\n # -- Test --\n\n # (1)\n\n # (2)\n\n # (3)\n\n # (4)\n # -- Test --", "def test_generate_all_testing(self):\n pass", "def alltests(opts):\n \n print \"API Root: %s\" % options.apiroot\n print \"Token: %s\" % options....
[ "0.7262856", "0.68205714", "0.6758854", "0.6704464", "0.6648625", "0.6646107", "0.6629853", "0.6612695", "0.65750575", "0.65750575", "0.65750575", "0.6566583", "0.6553205", "0.6550712", "0.65416145", "0.6533619", "0.6533619", "0.6533619", "0.6533619", "0.6533619", "0.6501971"...
0.6392469
28
No. 8 tests collection for Practitioner.
def test_practitioner_8(base_settings): filename = base_settings["unittest_data_dir"] / "practitioner-example-f007-sh.json" inst = practitioner.Practitioner.parse_file( filename, content_type="application/json", encoding="utf-8" ) assert "Practitioner" == inst.resource_type impl_practitione...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tests():", "def test(self):\n # -- Test --\n\n # (1)\n\n # (2)\n\n # (3)\n\n # (4)\n # -- Test --", "def spec_tests():\n pass", "def test_generate_all_testing(self):\n pass", "def test_get_scenarios(self):\n pass", "def test(self):\n p...
[ "0.7372738", "0.69317466", "0.6861522", "0.6845753", "0.6834681", "0.6780007", "0.6755908", "0.6755908", "0.6755908", "0.67130166", "0.67109954", "0.67109954", "0.67109954", "0.67109954", "0.67109954", "0.6678252", "0.66741705", "0.6660228", "0.665537", "0.6578866", "0.657649...
0.63559926
42
No. 9 tests collection for Practitioner.
def test_practitioner_9(base_settings): filename = base_settings["unittest_data_dir"] / "practitioner-example-f204-ce.json" inst = practitioner.Practitioner.parse_file( filename, content_type="application/json", encoding="utf-8" ) assert "Practitioner" == inst.resource_type impl_practitione...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tests():", "def test(self):\n # -- Test --\n\n # (1)\n\n # (2)\n\n # (3)\n\n # (4)\n # -- Test --", "def spec_tests():\n pass", "def test(self):\n pass", "def _test(self):\n pass", "def _test(self):\n pass", "def _test(self):\n ...
[ "0.7350845", "0.6929755", "0.68425804", "0.68048006", "0.67819405", "0.67819405", "0.67819405", "0.67812234", "0.67445767", "0.67445767", "0.67445767", "0.67445767", "0.67445767", "0.6693966", "0.6646028", "0.6644397", "0.6637566", "0.6624624", "0.6615607", "0.65986365", "0.6...
0.6293964
48
No. 10 tests collection for Practitioner.
def test_practitioner_10(base_settings): filename = base_settings["unittest_data_dir"] / "practitioner-example-xcda1.json" inst = practitioner.Practitioner.parse_file( filename, content_type="application/json", encoding="utf-8" ) assert "Practitioner" == inst.resource_type impl_practitioner...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tests():", "def alltests(opts):\n \n print \"API Root: %s\" % options.apiroot\n print \"Token: %s\" % options.token\n print \"Output dir: %s\" % options.output\n print \"Running %d%% of tests\" % options.percent\n print\n \n # need to use DEPT-001, not ID#\n coursehistory_tests = [\n #...
[ "0.69817436", "0.67881966", "0.6621588", "0.66090757", "0.65970397", "0.6592075", "0.6537486", "0.6522151", "0.64384097", "0.64384097", "0.6414787", "0.6400614", "0.6375108", "0.636496", "0.63621455", "0.63202417", "0.62964195", "0.62565356", "0.6244528", "0.6241661", "0.6240...
0.63118726
16
Set up the tests
def setup(): for dir_path in [train_dir, output_dir]: Path(dir_path).mkdir(exist_ok=True) # create the training and test data files that we will use create_jsonlines_feature_files(train_dir)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setUp(self):\n MainTests.setUp(self)", "def setUp(self):\n logging.debug('setting up')", "def setUp(self):\n logging.debug('setting up')", "def setUp(self):\n \n pass", "def setUp(self):\n\n pass", "def setUp(self):\n\n pass", "def setUp(self):\n ...
[ "0.8344514", "0.82070535", "0.82070535", "0.8188769", "0.8142251", "0.8142251", "0.81246495", "0.8071177", "0.80650306", "0.80650306", "0.80650306", "0.80650306", "0.80650306", "0.80650306", "0.80650306", "0.80650306", "0.80650306", "0.80650306", "0.80650306", "0.80650306", "...
0.0
-1
Clean up after tests
def tearDown(): for output_file_path in Path(output_dir).glob("test_voting_learner_cross_validate*"): output_file_path.unlink() for output_file_path in Path(".").glob("test_voting_learner_cross_validate*"): output_file_path.unlink() config_file_path = Path(config_dir) / "test_voting_learne...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tearDown(self):\n self.tmp.cleanup()", "def cleanup():", "def cleanUp(self):\r\n pass", "def cleanUp():\n pass", "def _clean_up(self):", "def cleanup(self):\n pass", "def cleanup(self):\n pass", "def cleanup(self):\n pass", "def cleanup(self):\n pass...
[ "0.8406943", "0.83678037", "0.83351654", "0.82998216", "0.82936525", "0.82640386", "0.82640386", "0.82640386", "0.82640386", "0.82640386", "0.82640386", "0.82640386", "0.82640386", "0.82640386", "0.82640386", "0.82640386", "0.82626957", "0.82626957", "0.82626957", "0.82422036",...
0.0
-1
Check given combination of crossvalidation configuration options
def check_xval_task(learner_type, options_dict): # create a configuration file with the given options (config_path, estimator_names, job_name, custom_learner, objectives, output_metrics, model_kwargs_list, param_grid_list, sampler_list, num_cv_folds, _, _)...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def crossValidate(self, args):\n\n ##################################\n # Read the training data\n ##################################\n if not os.path.isdir(args.annotationPath):\n print('annotation path does not exist: {}' \\\n .format(args.annotationP...
[ "0.6687642", "0.6479873", "0.6382023", "0.6245997", "0.61212516", "0.61105317", "0.60336494", "0.6023771", "0.6017304", "0.59759605", "0.59713924", "0.5944983", "0.59411436", "0.59192646", "0.5915955", "0.5907505", "0.59054077", "0.58736354", "0.5869191", "0.5866223", "0.5860...
0.59237695
13
Remove punctuations of several languages, including Japanese.
def remove_punctuation(text: str) -> str: return "".join( itertools.filterfalse(lambda x: unicodedata.category(x).startswith("P"), text) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_punct(self,text):", "def punct_remove(text):\n return(re.sub(punct_characters,' ',text))", "def remove_punctuations(text):\n return text.translate(str.maketrans('', '', string.punctuation))", "def punct_filter_(w):\n return w in {u'.', u',', u';', u'?', u'!', u'(', u')', u'[', u']'}",...
[ "0.7311671", "0.711764", "0.6981424", "0.68968636", "0.68956965", "0.6886261", "0.6881745", "0.68812156", "0.68133545", "0.6796841", "0.6787725", "0.67857873", "0.67852384", "0.6783421", "0.6764929", "0.6761497", "0.6751957", "0.6729602", "0.6729602", "0.6718826", "0.67166024...
0.69718033
3
Characterlevel segmentation for Korean and Japanese
def segment(text: str) -> str: import regex # Chinese text = regex.sub(r"(\p{Han})", r" \1 ", text) # Korean text = regex.sub(r"(\p{Hangul})", r" \1 ", text) # Japenese text = regex.sub(r"(\p{Hiragana})", r" \1 ", text) text = regex.sub(r"(\p{Katakana})", r" \1 ", text) text = text...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def uCSIsKatakanaPhoneticExtensions(code):\n ret = libxml2mod.xmlUCSIsKatakanaPhoneticExtensions(code)\n return ret", "def phoc_levels(word: str, levels=DEFAULT_PHOC_LEVELS):\n if levels <= 1:\n return [word]\n # cut_len = float(len(word)) / float(levels)\n # # length of cuts\n # regions...
[ "0.5655067", "0.53225625", "0.5267243", "0.52642506", "0.5255642", "0.52491516", "0.52491516", "0.52444214", "0.5241108", "0.5239331", "0.5196398", "0.5184633", "0.51652074", "0.5114331", "0.5098518", "0.505684", "0.50446427", "0.50386804", "0.5029255", "0.4988901", "0.498705...
0.54035604
1
This reads a file in the shared task format, returns a list of Tuples containing ID and text for each prompt.
def read_trans_prompts(lines: List[str], lowercase=True) -> List[Tuple[str,str]]: ids_prompts = [] first = True for line in lines: if lowercase: line = line.strip().lower() else: line = line.strip() # in a group, the first one is the KEY. # all other...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_prompt_file(prompt_file):\n with io.open(prompt_file, mode=\"r\", encoding='utf-8', errors='ignore') as prompt_f:\n return [prompt_f.readline().rstrip(),\n prompt_f.readline().rstrip()]", "def read_shared_secrets_from_file(f):\n shares = []\n words = []\n for line in f...
[ "0.64376706", "0.60924566", "0.58151025", "0.57231516", "0.5679147", "0.56595516", "0.55473155", "0.55078036", "0.5376893", "0.53262085", "0.528849", "0.52704746", "0.52672356", "0.5224767", "0.51990306", "0.5157543", "0.5151916", "0.50994694", "0.5096022", "0.5082734", "0.50...
0.61813223
1
This reads a file in the shared task format, and returns a dictionary with prompt IDs as keys, and each key associated with a dictionary of responses.
def read_transfile(lines: List[str], strip_punc=True, weighted=False, lowercase=True, length=0) -> Dict[str, Dict[str, float]]: data = OrderedDict() first = True options = {} key = "" keylen = 0 for line in lines: if lowercase: line = line.strip().lower() else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_prompt_file(prompt_file):\n with io.open(prompt_file, mode=\"r\", encoding='utf-8', errors='ignore') as prompt_f:\n return [prompt_f.readline().rstrip(),\n prompt_f.readline().rstrip()]", "def read_default_prompts():\n if os.path.exists(DEFAULT_PROMPTS_PATH):\n with o...
[ "0.5814567", "0.5640938", "0.56229466", "0.5342384", "0.52831453", "0.524801", "0.51320285", "0.51265144", "0.50202674", "0.49958473", "0.49940932", "0.49795607", "0.49669075", "0.49486187", "0.49446806", "0.49439514", "0.49403074", "0.49400342", "0.4921348", "0.4907984", "0....
0.0
-1
Init method for helper class.
def __init__(self): self.CVE_BUCKET = os.environ.get("REPORT_BUCKET_NAME", '') self.AWS_KEY = os.environ.get("AWS_S3_ACCESS_KEY_ID_REPORT_BUCKET", '') self.AWS_SECRET = os.environ.get("AWS_S3_SECRET_ACCESS_KEY_REPORT_BUCKET", '') self.AWS_REGION = os.environ.get("AWS_S3_REGION", "us-east...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _init(self):\n pass", "def init(self):\n pass", "def init(self):\n pass", "def init(self):\n pass", "def init(self):\n pass", "def init(self):\n pass", "def init(self):\n pass", "def init(self):\n pass", "def init(self):\n pass", ...
[ "0.8610245", "0.84196734", "0.84196734", "0.84196734", "0.84196734", "0.84196734", "0.84196734", "0.84196734", "0.84196734", "0.8380376", "0.8373575", "0.8353151", "0.82789344", "0.82789344", "0.8152919", "0.8116294", "0.7993546", "0.7993546", "0.7993546", "0.79501164", "0.79...
0.0
-1
Set HTTP Adapter with retries to session.
def get_session_retry(self, retries=3, backoff_factor=0.2, status_forcelist=(404, 500, 502, 504), session=None): session = session or requests.Session() retry = Retry(total=retries, read=retries, connect=retries, backoff_factor=ba...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(\n self,\n retries=3,\n backoff_factor=0.3,\n status_forcelist=(500, 502, 504),\n **session_options,\n ):\n super().__init__(**session_options)\n retries = retries or 0\n\n self.retry_ = Retry(\n total=retries,\n read=ret...
[ "0.68190426", "0.656107", "0.65234107", "0.6376474", "0.63384855", "0.6149356", "0.60859877", "0.59891427", "0.5915869", "0.5900037", "0.56298727", "0.56103295", "0.54669577", "0.5369005", "0.53306866", "0.53249484", "0.52559197", "0.52061677", "0.520381", "0.51781654", "0.51...
0.6642945
1
Execute the gremlin query and return the response.
def execute_gremlin_dsl(self, payloads): url = "http://{host}:{port}".format( host=os.environ.get("BAYESIAN_GREMLIN_HTTPINGESTION_SERVICE_HOST", "localhost"), port=os.environ.get("BAYESIAN_GREMLIN_HTTPINGESTION_SERVICE_PORT", "8181")) try: payload = json.dumps(payload...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gremlin_action(token, query):\n http = urllib3.PoolManager(\n cert_reqs=\"CERT_REQUIRED\", ca_certs=certifi.where())\n # Headers are how we pass through the token.\n headers = {\"Content-Type\": \"application/json\"}\n headers[\"X-Language\"] = \"en-us\"\n headers[\"X-Auth-Token\"] = toke...
[ "0.6971977", "0.68545705", "0.68396306", "0.648774", "0.64229923", "0.6413053", "0.62823623", "0.6230398", "0.6107883", "0.60947967", "0.5950436", "0.5908044", "0.5868579", "0.58055663", "0.5708583", "0.57053006", "0.5696164", "0.5694277", "0.5672222", "0.56569475", "0.564822...
0.69799536
0
Store the report content to the S3 storage.
def store_json_content(self, content, obj_key): try: logger.info('Storing the data into the S3 file %s' % obj_key) self.s3_resource.Object(self.CVE_BUCKET, obj_key).put( Body=json.dumps(content, indent=2).encode('utf-8')) except Exception as e: logger....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def s3_store_data(self):\n\n USERHOMEDIR = os.path.expanduser('~')\n TESTFILEPATH = \"%s/3MBFILE\" % USERHOMEDIR\n if not os.path.exists(TESTFILEPATH):\n with open(TESTFILEPATH, \"wb\") as out:\n out.truncate(1024 * 1024 * 3)\n self.k.set_contents_from_filename(TESTFILEPATH)", "def writ...
[ "0.686773", "0.6856555", "0.6635318", "0.6452791", "0.6358319", "0.6351033", "0.63241166", "0.6314031", "0.6267207", "0.62471694", "0.616967", "0.61287165", "0.59705794", "0.59511316", "0.5942337", "0.5938072", "0.5931062", "0.5896632", "0.58732337", "0.5843609", "0.5823253",...
0.64595914
3
Retrieve a dictionary stored as JSON from S3.
def _retrieve_dict(self, object_key): return json.loads(self._retrieve_blob(object_key).decode('utf-8'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __retrieve_from_bucket(fname):\n blob = BUCKET.blob(fname)\n json_data = json.loads(blob.download_as_string())\n return json_data", "def get_amazon_adj_cls_from_s3(s3_resource, bucket_name, prefix='') -> dict:\n amzn_filename = \"AMZN.json\"\n complete_path = os.path.join(prefix, amzn_filename...
[ "0.7405809", "0.7002301", "0.6989927", "0.6943178", "0.68357503", "0.6811579", "0.6775019", "0.6765076", "0.67535394", "0.67111343", "0.66732424", "0.6659228", "0.6640712", "0.663355", "0.6630252", "0.65800554", "0.6568119", "0.64453495", "0.642794", "0.6390214", "0.6329198",...
0.6381734
20
Retrieve remote object content.
def _retrieve_blob(self, object_key): return self.s3_resource.Object(self.CVE_BUCKET, object_key).get()['Body'].read()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getObject(self):\n # try getting the remote object by unique id\n remote_obj = self._getObjectByUid()\n if remote_obj is not None:\n return remote_obj\n\n utool = getUtility(IURLTool)\n return utool.getPortalObject().restrictedTraverse(self.remote_url)", "def get...
[ "0.69937205", "0.6545057", "0.6417782", "0.63836384", "0.6261528", "0.6251807", "0.6178698", "0.61709577", "0.61447203", "0.614206", "0.6140592", "0.6113577", "0.61032605", "0.60779417", "0.60344654", "0.6033025", "0.600181", "0.5966634", "0.59529024", "0.5910655", "0.5892479...
0.5384759
92