import * as $I from './interfaces' ; export const setSimFuncs = { jaccard , overlap } ; const PRECISION = 5 ; param a param b function jaccard ( a , b ) { const ui = unionIntersect ( a , b ) ; return { isect : ui . isectSize , sim : + ( ui . isectSize / ui . unionSize ) . toPrecision ( PRECISION ) } ; } description param a param b function overlap ( a , b ) { const ui = unionIntersect ( a , b ) ; return { isect : ui . isectSize , sim : + ( ui . isectSize / Math . min ( a . size , b . size ) ) . toPrecision ( PRECISION ) } ; } function unionIntersect ( a , b ) { const unionSize = new Set ( [ ... Array . from ( a ) , ... Array . from ( b ) ] ) . size ; const isectSize = a . size + b . size - unionSize ; return { unionSize , isectSize } ; }