Skip to content

Instantly share code, notes, and snippets.

const lineItemLabels = ['Item Amount', 'Description', 'Unit Price', 'Unit Quantity'];
const lintIssues = []
export function lint(response) {
let all_record_annotations = [];
if (response.annotations && response.records) {
for (const record of response.records) {
if(record.annotations) {
for (const ann in record.annotations) {
all_record_annotations.push(ann.ref);
const REGEX_contains_hashtag = /[#]/;
const labelsToCheck = ['Invoice Number'];
export function lint(response) {
const lintIssues = [];
if (response.annotations) {
for (const annotation of response.annotations) {
if (labelsToCheck.includes(annotation.label)) {
const REGEX_no_dollar_sign = /[!@#$%^&*()_+\-=\[\]{};':"\\|<>\/?~]/;
const labelsToCheck = ['Invoice Total', 'Invoice Amount Due', 'Item Amount', 'Unit Price'];
export function lint(response) {
const lintIssues = [];
if (response.annotations) {
for (const annotation of response.annotations) {
if (labelsToCheck.includes(annotation.label)) {
const REGEX_ISO_CURRENCY_CODE = /[A-Z]{3}/;
const labelsToCheck = ['Invoice Total', 'Invoice Amount Due', 'Item Amount', 'Unit Price'];
export function lint(response) {
const lintIssues = [];
if (response.annotations) {
for (const annotation of response.annotations) {
if (labelsToCheck.includes(annotation.label)) {
export function lint(response) {
const lintIssues = [];
let isLabelable = true;
if (response.values) {
for (const value of response.values) {
if (value.field_id === 'invoice_labeling' && !value.selected.includes('yes')) {
isLabelable = false;
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
class Calibration:
"""Calibration matrices and utils.
3d XYZ are in 3D egovehicle coord.
2d box xy are in image coord, normalized by width and height
Point cloud are in egovehicle coord
::
xy_image = K * [R|T] * xyz_ego
@aerinkim
aerinkim / conjugate_prior.py
Created January 3, 2020 23:36
Calculate the posterior of binomial likelihood
import numpy as np
import scipy.stats as stats
success_prob = 0.3
data = np.random.binomial(n=1, p=success_prob, size=1000) # sucess is 1, failure is 0.
# Domain θ
theta_range = np.linspace(0, 1, 1000)
# Prior P(θ)
@aerinkim
aerinkim / beta_distribution_graph.py
Created January 1, 2020 23:48
Plotting the beta distribution with different shapes
import numpy as np
from scipy.stats import beta
import matplotlib.pyplot as plt
plt.rcParams['figure.figsize'] = [10, 7]
# Bell shape
x = np.linspace(0, 1, 10000)
y1 = beta.pdf(x, 2, 8)
y2 = beta.pdf(x, 5, 5)
y3 = beta.pdf(x, 8, 2)
@aerinkim
aerinkim / Kmeans.py
Created February 24, 2019 23:05
K-means Python Implementation from scratch
from sklearn import datasets
def Kmeans(X, K):
m = len(X)
X_centroid = dict() # Save which sample belong to which cluster.
X_centroid.fromkeys(range(0, m))
C = dict() # Save cluster's cordinate
C.fromkeys(range(0, K))
old_C = None # Cache to save old C. Used for an early termination.
# 1. Randomly initialize k centroids.