file() was removed from Py3, use ‘with open()’
file() no longer exists in Python 3. The current version does not explicitly close file handles but this version fixes that.
This commit is contained in:
@@ -16,8 +16,10 @@ class SEG(object):
|
|||||||
curpath=_curpath
|
curpath=_curpath
|
||||||
self.d = {}
|
self.d = {}
|
||||||
print("loading dict...", file=sys.stderr)
|
print("loading dict...", file=sys.stderr)
|
||||||
self.set([x.rstrip() for x in file(os.path.join(curpath,"main.dic")) ])
|
with open(os.path.join(curpath, "main.dic")) as in_file:
|
||||||
self.specialwords= set([x.rstrip().decode('utf-8') for x in file(os.path.join(curpath,"suffix.dic"))])
|
self.set([x.rstrip() for x in in_file])
|
||||||
|
with open(os.path.join(curpath,"suffix.dic")) as in_file:
|
||||||
|
self.specialwords= set([x.rstrip().decode('utf-8') for x in in_file])
|
||||||
print('dict ok.', file=sys.stderr)
|
print('dict ok.', file=sys.stderr)
|
||||||
#set dictionary(a list)
|
#set dictionary(a list)
|
||||||
def set(self,keywords):
|
def set(self,keywords):
|
||||||
|
|||||||
Reference in New Issue
Block a user