Skip to content

Instantly share code, notes, and snippets.

View wpm's full-sized avatar

W.P. McNeill wpm

View GitHub Profile
@wpm
wpm / birthday_corpus.py
Created January 3, 2018 20:37
Generate a corpus of texts mentioning birthdays that can be used to train a Prodigy named entity recognizer.
import json
import re
import time
from random import choice, random
from typing import TextIO, Callable, Sequence, Tuple, Optional
import click
NAME = DATE = str
SPAN_OFFSET = Tuple[int, int]
@wpm
wpm / maximal_fully_ordered_sublists.py
Created March 1, 2019 22:48
Maximal Fully-Ordered Sublists
def maximal_fully_ordered_sublists(s: List[T]) -> List[List[T]]:
"""
Find maximum-length sequences of in-order items in a list.
Let s be a list of items over which there exists a total ordering defined by the < operator.
Let a fully-ordered sublist s' of s be s with elements removed so that the elements of s' are monotonically
increasing.
The maximal fully-ordered sublists of s are the set of fully-ordered sublists such that no sublist is contained in
another one.
@wpm
wpm / celery_copy_directory.py
Last active December 22, 2019 00:11
Use Celery workers to copy a directory of files in parallel, with error tracking and a progress bar.
#!/usr/bin/env python
import shutil
from pathlib import Path
from typing import Iterable, Tuple, Optional
import click
from celery import Celery
from celery.utils.log import get_task_logger
from tqdm import tqdm
@wpm
wpm / log.txt
Created October 5, 2021 19:09
Pip backtracking when installing spaCy from source
$ pip install --no-build-isolation --editable ".[transformers,ray]"
Obtaining file:///Users/wmcneill/Documents/src/spaCy
Preparing wheel metadata ... done
Requirement already satisfied: spacy-legacy<3.1.0,>=3.0.8 in /Users/wmcneill/opt/anaconda3/envs/spaCy/lib/python3.9/site-packages (from spacy==3.1.3) (3.0.8)
Requirement already satisfied: setuptools in /Users/wmcneill/opt/anaconda3/envs/spaCy/lib/python3.9/site-packages (from spacy==3.1.3) (58.0.4)
Requirement already satisfied: typer<0.5.0,>=0.3.0 in /Users/wmcneill/opt/anaconda3/envs/spaCy/lib/python3.9/site-packages (from spacy==3.1.3) (0.4.0)
Requirement already satisfied: requests<3.0.0,>=2.13.0 in /Users/wmcneill/opt/anaconda3/envs/spaCy/lib/python3.9/site-packages (from spacy==3.1.3) (2.26.0)
Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /Users/wmcneill/opt/anaconda3/envs/spaCy/lib/python3.9/site-packages (from spacy==3.1.3) (2.0.5)
Requirement already satisfied: packaging>=20.0 in /Users/wmcneill/opt/anaconda3/envs/spaCy/lib/python3.9/s