我想提取一段文本并从给定数量的字符中提取尽可能多的单词。我可以使用哪些工具/库来完成此任务?
例如,在给定的文本块中:
Have you managed to get your hands on Nikon's elusive D4 full-frame DSLR?
It should be smooth sailing from here, with the occasional firmware update being
your only critical acquisition going forward. D4 firmware 1.02 brings a handful of
minor fixes, but if you're in need of any of the enhancements listed below, it's
surely a must have:
如果我将它分配给一个字符串,然后 make string = string[0:100]
,那将得到前 100 个字符,但是“sailing”这个词将被截断为“sailin”,我希望文本被截断在“航行”之前的空格之前或之后。