diff --git a/jieba/analyse/__init__.py b/jieba/analyse/__init__.py index daccded..816e903 100644 --- a/jieba/analyse/__init__.py +++ b/jieba/analyse/__init__.py @@ -2,7 +2,7 @@ import jieba import os try: - from analyzer import ChineseAnalyzer + from .analyzer import ChineseAnalyzer except ImportError: pass diff --git a/jieba/finalseg/__init__.py b/jieba/finalseg/__init__.py index 831d8c2..50515b3 100644 --- a/jieba/finalseg/__init__.py +++ b/jieba/finalseg/__init__.py @@ -34,7 +34,7 @@ def load_model(): emit_p = {} abs_path = os.path.join(_curpath, PROB_EMIT_P) - with file(abs_path, 'rb') as f: + with open(abs_path, 'rb') as f: emit_p = marshal.load(f) f.closed diff --git a/jieba/posseg/__init__.py b/jieba/posseg/__init__.py index 19c0074..ac5b697 100644 --- a/jieba/posseg/__init__.py +++ b/jieba/posseg/__init__.py @@ -41,13 +41,13 @@ def load_model(f_name,isJython=True): emit_p = {} abs_path = os.path.join(_curpath, PROB_EMIT_P) - with file(abs_path, 'rb') as f: + with open(abs_path, 'rb') as f: emit_p = marshal.load(f) f.closed state = {} abs_path = os.path.join(_curpath, CHAR_STATE_TAB_P) - with file(abs_path, 'rb') as f: + with open(abs_path, 'rb') as f: state = marshal.load(f) f.closed diff --git a/test/test_whoosh.py b/test/test_whoosh.py index b72a967..c67e946 100644 --- a/test/test_whoosh.py +++ b/test/test_whoosh.py @@ -5,7 +5,7 @@ from whoosh.index import create_in,open_dir from whoosh.fields import * from whoosh.qparser import QueryParser -from jieba.analyse.analyzer import ChineseAnalyzer +from jieba.analyse import ChineseAnalyzer analyzer = ChineseAnalyzer() @@ -18,31 +18,31 @@ ix = create_in("tmp", schema) # for create new index writer = ix.writer() writer.add_document( - title="document1", + title="document1", path="/a", content="This is the first document we’ve added!" ) writer.add_document( - title="document2", + title="document2", path="/b", content="The second one 你 中文测试中文 is even more interesting! 吃水果" ) writer.add_document( - title="document3", + title="document3", path="/c", content="买水果然后来世博园。" ) writer.add_document( - title="document4", + title="document4", path="/c", content="工信处女干事每月经过下属科室都要亲口交代24口交换机等技术性器件的安装工作" ) writer.add_document( - title="document4", + title="document4", path="/c", content="咱俩交换一下吧。" ) @@ -55,7 +55,7 @@ for keyword in ("水果世博园","你","first","中文","交换机","交换"): print("result of ",keyword) q = parser.parse(keyword) results = searcher.search(q) - for hit in results: + for hit in results: print(hit.highlights("content")) print("="*10)