If the AI company bought their book, then they didn't give it all away. If the AI company obtained it indirectly like a library or 2nd hand, then the author has already been paid when he first sold it. In either case, he could have refused to be so liberal in sharing it if he didn't want it to be used like that, but he preferred to make some money instead.