This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UnionFind: | |
def __init__(self, objects): | |
self.objects = list(objects) | |
self.weights = {i: 1 for i in range(len(self.objects))} | |
self.parents = list(range(len(self.objects))) | |
self.obj2num = {k: i for i, k in enumerate(self.objects)} | |
def add(self, obj): | |
self.objects.append(obj) | |
n = len(self.objects)-1 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[tool.poetry] | |
name = "foo" | |
version = "0.1.0" | |
description = "" | |
authors = ["Your Name <you@example.com>"] | |
[tool.poetry.dependencies] | |
python = "^3.7" | |
[tool.poetry.dev-dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SLACK_NOTIFY_ICON=":ghost:" | |
if [ ! -f ~/.notify-slack-cfg ]; then | |
echo "ERROR: A Webhook URL is required. Create yours here: https://my.slack.com/services/new/incoming-webhook/" | |
echo "Once you have your KEY, please create a file at ${HOME}/.notify-slack-cfg containng only the KEY. Eg: T02TKKSAX/B246MJ6HX/WXt2BWPfNhSKxdoFNFblczW9" | |
return | |
fi | |
SLACK_MESSAGE="$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Content-Type: $(file -b --mime-type $FILE)" \ | |
--data-binary @$FILE \ | |
"https://uploads.github.com/repos/$REPO/releases/$RELEASE/assets?name=$(basename $FILE)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import os | |
import re | |
import subprocess | |
import fire | |
import requests | |
ENDPOINT = "https://api.github.com" | |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
LOWER = "ぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮ" | |
UPPER = "あいうえおつやゆよわアイウエオツヤユヨワ" | |
MAP = str.maketrans(dict(zip(LOWER, UPPER))) | |
def ja_upper(text: str) -> str: | |
return text.translate(MAP) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import itertools as it | |
import copy | |
import srsly | |
from tqdm.notebook import tqdm | |
labels = [ | |
"movie-enter", | |
"it-life-hack", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
def beamsearch(probs: torch.Tensor, k: int) -> torch.Tensor: | |
"""Beam search for sequential probabilities. | |
Args: | |
data: tensor of shape (length, d). requires d > 0. Assumed all items in `probs` in range [0, 1]. | |
k: beam width | |
Returns: (k, length) tensor | |
""" |