Skip to content

Instantly share code, notes, and snippets.

@oubiwann
Last active August 29, 2015 14:03
Using Levenshtein Distance and Team Analysis to Reveal Inherent Engineering Org Structure
> (defun int-exp (a b)
(trunc (math:pow a b)))
int-exp
> (set lfe (int-exp 2 0))
1
> (set hy (int-exp 2 5))
32
> (set clojure (int-exp 2 6))
64
> (bxor clojure (bxor lfe hy))
97
> (integer_to_list (bxor clojure (bxor lfe hy)) 2)
"1100001"
>
> (set lookup-abbr
'(#(#b10000011000010100111100011011001100111001000101010 "DAPT")
#(#b01100000001000110001000100101010010011001100010010 "GRBAT")
#(#b00000100000010001000100100100110001111000101010001 "DICT")
#(#b00001000010100001010110101000110000100000100110010 "JPUST")
#(#b00010000000100010000110101000101000101000000100011 "JPPSST")
#(#b00000000010100000010111111110101000110101001110010 "UDAT")
#(#b00000001100011000110100011001010000100101100100011 "VRPRST")
#(#b00010000000100010000011110010011010010001100001100 "OT")
#(#b01000100000010001001111111000011010010001010000100 "QAT")
#(#b11010111111111111111101111000011010111011000100100 "CT")))
> (set lookup-name
'(#("DAPT" "Digital Anvil Product Team")
#("GRBAT" "Giant Rubber Band App Team")
#("DICT" "Digital Iron Carrot Team")
#("JPUST" "Jet Propelled Unicycle Service Team")
#("JPPSST" "Jet Propelled Pogo Stick Service Team")
#("UDAT" "Ultimatum Dispatcher API Team")
#("VRPRST" "Virtual Rocket Powered Roller Skates Team")
#("OT" "Operations Team")
#("QAT" "QA Team")
#("CT" "Community Team")))
> (lfe-utils:levenshtein-distance
"11010111111111111111101111000011010111011000100100"
"00000100000010001000100100100110001111000101010001")
25
> (defun get-bins (data)
(proplists:get_keys data))
> (defun format-bin (bin)
(string:right (integer_to_list bin 2) 50 #\0))
> (defun get-str-bins (data)
(lists:map
#'format-bin/1
(get-bins data)))
> (defun swap (data)
(lists:map
(match-lambda (((tuple a b ))
(tuple b a)))
data))
> (defun bin->abbr (bin data)
(proplists:get_value bin data))
> (defun abbr->bin (team-abbr data)
(proplists:get_value team-abbr (swap data)))
> (defun abbr->name (team-abbr data)
(proplists:get_value team-abbr data))
> (defun name->abbr (name name-data)
(proplists:get_value name (swap name-data)))
> (defun name->bin (name data name-data)
(abbr->bin
(name->abbr name name-data)
data))
> (lfe-utils:levenshtein-sort
"00000100000010001000100100100110001111000101010001"
(get-str-bins lookup-abbr))
#("00000100000010001000100100100110001111000101010001"
((0 "00000100000010001000100100100110001111000101010001")
(12 "00010000000100010000110101000101000101000000100011")
(13 "00001000010100001010110101000110000100000100110010")
(14 "00010000000100010000011110010011010010001100001100")
(14 "01000100000010001001111111000011010010001010000100")
(14 "01100000001000110001000100101010010011001100010010")
(15 "10000011000010100111100011011001100111001000101010")
(16 "00000000010100000010111111110101000110101001110010")
(16 "00000001100011000110100011001010000100101100100011")
(25 "11010111111111111111101111000011010111011000100100")))
> (defun sort-data (name data name-data)
(let* ((bin (name->bin name data name-data))
((tuple _ results) (lfe-utils:levenshtein-sort
(format-bin bin)
(get-str-bins data))))
(lists:map
(match-lambda (((list dist bin-str))
(list dist
(abbr->name
(bin->abbr
(list_to_integer bin-str 2)
data)
name-data))))
results)))
> (sort-data "Digital Iron Carrot Team"
lookup-abbr
lookup-name)
((0 "Digital Iron Carrot Team")
(12 "Jet Propelled Pogo Stick Service Team")
(13 "Jet Propelled Unicycle Service Team")
(14 "Operations Team")
(14 "QA Team")
(14 "Giant Rubber Band App Team")
(15 "Digital Anvil Product Team")
(16 "Ultimatum Dispatcher API Team")
(16 "Virtual Rocket Powered Roller Skates Team")
(25 "Community Team"))
> (sort-data "Community Team"
lookup-abbr
lookup-name)
((0 "Community Team")
(18 "Digital Anvil Product Team")
(19 "QA Team")
(22 "Operations Team")
(22 "Giant Rubber Band App Team")
(23 "Virtual Rocket Powered Roller Skates Team")
(24 "Ultimatum Dispatcher API Team")
(24 "Jet Propelled Unicycle Service Team")
(25 "Digital Iron Carrot Team")
(26 "Jet Propelled Pogo Stick Service Team"))
> (sort-data "Giant Rubber Band App Team"
lookup-abbr
lookup-name)
((0 "Giant Rubber Band App Team")
(13 "Virtual Rocket Powered Roller Skates Team")
(13 "Operations Team")
(13 "Jet Propelled Pogo Stick Service Team")
(14 "Digital Iron Carrot Team")
(15 "Jet Propelled Unicycle Service Team")
(16 "Ultimatum Dispatcher API Team")
(16 "QA Team")
(16 "Digital Anvil Product Team")
(22 "Community Team"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment