Differences between revisions 2 and 3
Revision 2 as of 2007-05-08 02:41:41
Size: 702
Editor: ZoomQuiet
Comment:
Revision 3 as of 2009-11-28 15:04:55
Size: 684
Editor: Elias
Comment: 删除对PageComment2组件的引用
Deletions are marked like this. Additions are marked like this.
Line 24: Line 24:
[[PageComment2]]

中英文混合,词数如何统计? ::-- 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())
  • 做过一部分测试,与Word里面的字数统计数目一样,不过不知道是不是还有问题。

1.1. 反馈

MicroProj/2007-05-08 (last edited 2009-12-25 07:10:03 by localhost)