Generalized code to handle tri and bi gram expansions. Also added a simple test harness