Skip to content

Instantly share code, notes, and snippets.

View vijay120's full-sized avatar

Vijay Ramakrishnan vijay120

  • Cisco Inc.
  • United States
View GitHub Profile
@vijay120
vijay120 / gist:0b7d7d1ce12b42e2ade1c76f2247e5c1
Last active December 2, 2019 07:33
MindMeld EMEAR demo
# Mindmeld getting started
docker pull mindmeldworkbench/dep:latest
docker run -p 0.0.0.0:9200:9200 -p 0.0.0.0:7151:7151 -p 0.0.0.0:9300:9300 mindmeldworkbench/dep -ti -d
bash -c "$(curl -s https://devcenter.mindmeld.com/scripts/mindmeld_lite_init.sh)"
# download dependencies
mkdir emear
cd emear
virtualenv -p python3 .
source bin/activate
@vijay120
vijay120 / test.txt
Created July 2, 2019 01:02
get_salary test file
What does {Nan Singh|name} get for {compensation|money}?
{susan|name} {earns|money} how much {day by day|time_recur}
Tell me who earned the {most|extreme} that has {been here|employment_action} {this year|sys_time}?
What is {Susan Ferguson|name} {earners|money} on a {on a monthly basis|time_recur} basis?
Ms.{Power|name}s {make|money} a lot {on a monthly basis|time_recur}
{incomes|money} {mia Brown|name}
What does {thelma petrowsky|name} {earner|money} {each day|time_recur}
Is {Leigh|name} being {paid|money} {40k|sys_number}?
What is {Samuel MacLenJulia Soto|name} {income|money}
What is Mrs.{Williams|name}'s {money|money}?
@vijay120
vijay120 / train.txt
Created July 2, 2019 01:02
get_salary train file
{Jumil Turpin|name} {month to month|time_recur} {dollars|money}
What is {ivan|name}'s {hourly|time_recur} {salary|money}
Does {Lisa Galia|name} {earner|money} {6 figures|sys_number}?
Is {Nicole Fancett|name} being {paid|money} {$50k|sys_amount-of-money}?
How much does {Ivan Rogers|name} get {paid|money}?
Does {60,000|sys_number} exceed what {julia soto|name} {earns|money} {every year|time_recur}?
According to the {payroll|money}, how much does {Libby Fidelia|name} {earn|money}?
Describe {sophia theamstern|name}'s {pay|money}
How much {pay|money} does {Phil Close|name} bring in {every day|time_recur}?
What does {Rose Ivey|name}'s {make|money} look like?
@vijay120
vijay120 / solution.py
Last active June 12, 2019 22:02
MindMeld Workshop solutions
# Slides:
# https://cisco.box.com/s/brm0recnlq96ducqywrbn94ac39acel8
# https://cisco.app.box.com/notes/474240338419?s=4yjprnc2gv1k0pchfxpnn8dtg23vff0a
# Solution 1:
@app.handle(intent='help')
def provide_help(request, responder):
"""
When the user asks for help, provide a help message
def weighted_img(img, initial_img, α=0.8, β=1., λ=0.):
"""
`img` is the output of the hough_lines(), An image with lines drawn on it.
Should be a blank image (all black) with lines drawn on it.
`initial_img` should be the image before any processing.
The result image is computed as follows:
initial_img * α + img * β + λ
@vijay120
vijay120 / line.py
Last active December 4, 2016 20:16
def draw_lines(img, lines, color=[255, 0, 0], thickness=2):
"""
This function draws `lines` with `color` and `thickness`.
"""
imshape = img.shape
# these variables represent the y-axis coordinates to which the line will be extrapolated to
ymin_global = img.shape[0]
ymax_global = img.shape[0]
@vijay120
vijay120 / hough.py
Last active December 4, 2016 07:52
def hough_lines(img, rho, theta, threshold, min_line_len, max_line_gap):
"""
`img` should be the output of a Canny transform.
Returns an image with hough lines drawn.
"""
lines = cv2.HoughLinesP(img, rho, theta, threshold, np.array([]), minLineLength=min_line_len, maxLineGap=max_line_gap)
line_img = np.zeros((*img.shape, 3), dtype=np.uint8)
draw_lines(line_img, lines)
def region_of_interest(img, vertices):
"""
Applies an image mask.
Only keeps the region of the image defined by the polygon
formed from `vertices`. The rest of the image is set to black.
"""
#defining a blank mask to start with
mask = np.zeros_like(img)
def canny(img, low_threshold, high_threshold):
"""Applies the Canny transform"""
return cv2.Canny(img, low_threshold, high_threshold)
# canny
minThreshold = 100
maxThreshold = 200
edgeDetectedImage = canny(gaussianBlur, minThreshold, maxThreshold)
def gaussian_blur(img, kernel_size):
"""Applies a Gaussian Noise kernel"""
return cv2.GaussianBlur(img, (kernel_size, kernel_size), 0)
# apply gaussian blur
kernelSize = 5
gaussianBlur = gaussian_blur(grayscaled, kernelSize)