I will paste the algorithm in clojure below, but I guess the most important thing regarding spirits is not the ritual to bind them, but how you find their names so you can research the ritual itself. My favorite source of arcana regarding spirit names is . I advice it to any wizard, be they apprendice or warlock.
Well, here it goes my version of the ritual, hope you enjoy it.
 Steven Skiena: The Algorithm Design Manual