Simple word matching written in Scala