An algebraic approach to translating Japanese