2005年05月29日 星期日 14:11
a = unicode ("信息安全技术主要是研究计算机系统信息的机密性、完整性、可
获取性和真实性,它的核心是加密技术。加密技术根据加密密钥与解密密钥是否相
同可分为对称加密技术(单密钥加密技术)和非对称加密技术(公开密钥加密技
术)。加个叹号!加个问号?试试句号加引号。“试试叹号加引号!”。“试试问号
加引号?” 加点废话", "cp936")
exp = unicode ("(.*?(?:。”|!”|?”|。|!|?))+?", "cp936")
import re
found = re.findall (exp, a)
for i in found:
print i
dimension 写道:
>python-chinese, 您好!
>
> 还有一个问题要请教.
> 就是如果在分句后的结果列表里的每一个句子,如何保留每一个分割的分隔符?
>也就是说对于下面的一段话:
>
>
>a = unicode ("信息安全技术主要是研究计算机系统信息的机密性、完整性、可
>获取性和真实性,它的核心是加密技术。加密技术根据加密密钥与解密密钥是否相
>同可分为对称加密技术(单密钥加密技术)和非对称加密技术(公开密钥加密技
>术)。加个叹号!加个问号?试试句号加引号。“试试叹号加引号!”。“试试问号
>加引号?” 加点废话", "cp936")
>
>分完句后的结果是:
>随着信息技术的发展,计算机应用渗透到社会生活的各个领域,特
>别是在电子商务中的应用,使人们对信息的依赖程度越来越大,从而使信息安全技
>术显得格外重要。
>
>包含这个“。”
>
>
>************下面是转发邮件************
>原邮件发件人名字: cpunion
>原邮件发件人地址:cpunion at 263.net
>原邮件收件人名字:python-chinese at lists.python.cn
>原邮件收件人地址:python-chinese at lists.python.cn
>原邮件抄送人名字:
>原邮件抄送人地址:
>
>
>
>>多字节文字一定要用unicode处理,先遵守这一点,再去做其它的。
>>
>>
>>
>>a = unicode ("随着信息技术的发展,计算机应用渗透到社会生活的各个领域,特
>>别是在电子商务中的应用,使人们对信息的依赖程度越来越大,从而使信息安全技
>>术显得格外重要。信息安全技术主要是研究计算机系统信息的机密性、完整性、可
>>获取性和真实性,它的核心是加密技术。加密技术根据加密密钥与解密密钥是否相
>>同可分为对称加密技术(单密钥加密技术)和非对称加密技术(公开密钥加密技
>>术)。加个叹号!加个问号?试试句号加引号。“试试叹号加引号!”。“试试问号
>>加引号?” 加点废话", "cp936")
>>
>>expression = unicode ("。|!|?|。”|!”|?", "cp936")
>>
>>import re
>>
>>listSentence = re.split (expression, a)
>>for i in listSentence:
>> print i
>>
>>
>>dimension wrote:
>>
>>
>>
>>>python-chinese,您好!
>>>
>>> 比如要实现一个句子分割器,
>>>只有是“。!?”以及
>>>。”
>>>!”
>>>?”
>>>等几种情况结尾的句子都分割称单独的句子。
>>>
>>>我利用正则表达式
>>>expression = r"。|!|?|。”|!”|?”"
>>>
>>>listSentence = re.split(expression, sentence)
>>>
>>>但是这样情况下,就会把汉字中某些字分开称乱码,比如:
>>>
>>>假如
>>>
>>>str1 = "【幸福】的人是很少的。"
>>>
>>>这样一个字符串就会被分开,因为“福”的后一半“】”的前一半正好是a3a1是一个“!”。当然,类似的情况肯定还有。
>>>
>>>不知道怎么解决。
>>>
>>> 致
>>>礼!
>>>
>>>
>>> dimension
>>> dimension at hit.edu.cn
>>> 2005-05-27
>>>
>>>
>>>------------------------------------------------------------------------
>>>
>>>_______________________________________________
>>>python-chinese list
>>>python-chinese at lists.python.cn
>>>http://python.cn/mailman/listinfo/python-chinese
>>>
>>>
>>>
>>>
>>_______________________________________________
>>python-chinese list
>>python-chinese at lists.python.cn
>>http://python.cn/mailman/listinfo/python-chinese
>>.
>>
>>
>
>= = = = = = = = = = = = = = = = = = = =
>
> 致
>礼!
>
>
> dimension
> dimension at hit.edu.cn
> 2005-05-29
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>python-chinese list
>python-chinese at lists.python.cn
>http://python.cn/mailman/listinfo/python-chinese
>
>
Zeuux © 2025
京ICP备05028076号