From 447c1ded8cb54f9a43128119f201865898cc6de7 Mon Sep 17 00:00:00 2001 From: fxsjy Date: Sat, 15 Nov 2014 13:44:30 +0800 Subject: [PATCH] fix problem for python3.2 --- jieba/__init__.py | 4 ++-- jieba/finalseg/__init__.py | 2 +- jieba/posseg/__init__.py | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/jieba/__init__.py b/jieba/__init__.py index e507111..37e2e62 100644 --- a/jieba/__init__.py +++ b/jieba/__init__.py @@ -242,9 +242,9 @@ def cut(sentence, cut_all=False, HMM=True): # \r\n|\s : whitespace characters. Will not be handled. if cut_all: - re_han, re_skip = re.compile(r"([\u4E00-\u9FA5]+)", re.U), re.compile(r"[^a-zA-Z0-9+#\n]", re.U) + re_han, re_skip = re.compile("([\u4E00-\u9FA5]+)", re.U), re.compile("[^a-zA-Z0-9+#\n]", re.U) else: - re_han, re_skip = re.compile(r"([\u4E00-\u9FA5a-zA-Z0-9+#&\._]+)", re.U), re.compile(r"(\r\n|\s)", re.U) + re_han, re_skip = re.compile("([\u4E00-\u9FA5a-zA-Z0-9+#&\._]+)", re.U), re.compile("(\r\n|\s)", re.U) blocks = re_han.split(sentence) if cut_all: cut_block = __cut_all diff --git a/jieba/finalseg/__init__.py b/jieba/finalseg/__init__.py index a7694fc..5e676ad 100644 --- a/jieba/finalseg/__init__.py +++ b/jieba/finalseg/__init__.py @@ -88,7 +88,7 @@ def cut(sentence): sentence = sentence.decode('utf-8') except UnicodeDecodeError: sentence = sentence.decode('gbk', 'ignore') - re_han, re_skip = re.compile(r"([\u4E00-\u9FA5]+)"), re.compile(r"(\d+\.\d+|[a-zA-Z0-9]+)") + re_han, re_skip = re.compile("([\u4E00-\u9FA5]+)"), re.compile("(\d+\.\d+|[a-zA-Z0-9]+)") blocks = re_han.split(sentence) for blk in blocks: if re_han.match(blk): diff --git a/jieba/posseg/__init__.py b/jieba/posseg/__init__.py index 52e3382..865a07d 100644 --- a/jieba/posseg/__init__.py +++ b/jieba/posseg/__init__.py @@ -104,8 +104,8 @@ def __cut(sentence): yield pair(sentence[next:], pos_list[next][1]) def __cut_detail(sentence): - re_han, re_skip = re.compile(r"([\u4E00-\u9FA5]+)"), re.compile(r"([\.0-9]+|[a-zA-Z0-9]+)") - re_eng, re_num = re.compile(r"[a-zA-Z0-9]+"), re.compile(r"[\.0-9]+") + re_han, re_skip = re.compile("([\u4E00-\u9FA5]+)"), re.compile("([\.0-9]+|[a-zA-Z0-9]+)") + re_eng, re_num = re.compile("[a-zA-Z0-9]+"), re.compile("[\.0-9]+") blocks = re_han.split(sentence) for blk in blocks: if re_han.match(blk): @@ -129,7 +129,7 @@ def __cut_DAG_NO_HMM(sentence): x = 0 N = len(sentence) buf = '' - re_eng = re.compile(r'[a-zA-Z0-9]',re.U) + re_eng = re.compile('[a-zA-Z0-9]',re.U) while x < N: y = route[x][1]+1 l_word = sentence[x:y] @@ -194,8 +194,8 @@ def __cut_internal(sentence, HMM=True): sentence = sentence.decode('utf-8') except UnicodeDecodeError: sentence = sentence.decode('gbk', 'ignore') - re_han, re_skip = re.compile(r"([\u4E00-\u9FA5a-zA-Z0-9+#&\._]+)"), re.compile(r"(\r\n|\s)") - re_eng, re_num = re.compile(r"[a-zA-Z0-9]+"), re.compile(r"[\.0-9]+") + re_han, re_skip = re.compile("([\u4E00-\u9FA5a-zA-Z0-9+#&\._]+)"), re.compile("(\r\n|\s)") + re_eng, re_num = re.compile("[a-zA-Z0-9]+"), re.compile("[\.0-9]+") blocks = re_han.split(sentence) if HMM: __cut_blk = __cut_DAG