calculating similarities and subtries -- api