标题: 求句子各单词的字符串长度 [打印本页] 作者: wpd0508 时间: 2014-06-21 11:12 标题: 求句子各单词的字符串长度 比如“ In statistics, a power lar is a functional relationship between two quantities, where one quantity varies as a power of another" 这句话中,按顺序得到的单词的字母数序列是“ 2 10 1 5 3 2 1 10 12 7 3 10 5 3 8 5 3 8 6 2 1 5 2 7.
将文件中的每一句话做一次这样的分析后,得到一长串的字数(x1,x2, x3, ... xn), 每一个数字代表一个单词的字母数(n 为文件中单词数),然后求平均值。作者: zerostudy 时间: 2014-06-21 11:33
[len(i.strip(',')) for i in "In statistics, a power lar is a functional relationship between two quantities, where one quantity varies as a power of another".split()]