中英文混合,词数如何统计? ::-- ZoomQuiet [DateTime(2007-05-08T02:39:44Z)] TableOfContents

Include(CPUGnav)

1. batfree.混合字串统计

[http://groups.google.com/group/python-cn/t/76703597d06173de CPyUG:26258- 中英文混合,词数如何统计?]

   1 import re
   2 cjkReg = re.compile(u'[\u1100-\uFFFDh]+?')
   3 trimedCJK = cjkReg.sub( ' a ', inputString, 0)# replace the CJK with the word a
   4 return  len(trimedCJK.split())

1.1. 反馈