python generator + java recognizer