Update TextMap and Word class to support new algorithm