【发布时间】:2012-07-05 09:45:55
【问题描述】:
我想提取一段文本并从给定数量的字符中提取尽可能多的单词。我可以使用哪些工具/库来完成此操作?
例如,在given 文本块中:
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:
如果我将它分配给一个字符串,然后生成 string = string[0:100],那将得到前 100 个字符,但“sailing”这个词将被截断为“sailin”,我想要'sailing' 之前或之后的空格将被截断的文本。
【问题讨论】: