word segment tool writen by scala