Skip to content

Instantly share code, notes, and snippets.

View epicure24's full-sized avatar
🎯
Focusing

Shweta Sharma epicure24

🎯
Focusing
View GitHub Profile
@zapalote
zapalote / extract-gbooks-terms.py
Last active April 2, 2024 11:31
Example of multi-threading and memory mapped file processing.
# extraction pattern: ngram TAB year TAB match_count TAB volume_count NEWLINE
# out: unique_ngram TAB sum(match_count) NEWLINE
import re
import os, sys, mmap
from pathlib import Path
from tqdm import tqdm
from concurrent.futures import ThreadPoolExecutor
abv = re.compile(r'^(([A-Z]\.){1,})(_|[^\w])') # A.B.C.
@kendricktan
kendricktan / gabor_filter.py
Created May 16, 2016 01:07
Gabor kernel filter example in python
import numpy as np
import cv2
# cv2.getGaborKernel(ksize, sigma, theta, lambda, gamma, psi, ktype)
# ksize - size of gabor filter (n, n)
# sigma - standard deviation of the gaussian function
# theta - orientation of the normal to the parallel stripes
# lambda - wavelength of the sunusoidal factor
# gamma - spatial aspect ratio
# psi - phase offset
@ngcrawford
ngcrawford / multiprocessing_template.py
Created March 29, 2012 12:49
Template for multiprocessing large files line by line
#!/usr/bin/env python
# encoding: utf-8
import multiprocessing
from textwrap import dedent
from itertools import izip_longest
def process_chunk(d):
"""Replace this with your own function
that processes data one line at a