Skip to content

Commit 9f0a1f2

Browse files
committed
fix json
1 parent b75cf8f commit 9f0a1f2

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

pythainlp/corpus/thaipos.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import os
44
from nine import nimport,str
55
json= nimport('json')
6-
codecs= nimport('codecs')
7-
reader = codecs.getreader("utf-8")
86
templates_dir = os.path.join(os.path.dirname(pythainlp.__file__), 'corpus')
97
template_file = os.path.join(templates_dir, 'thaipos.json')
108
def get_data():
11-
return json.load(reader(open(template_file).read()))
9+
with open(template_file) as f:
10+
model = json.load(f)
11+
return model

pythainlp/postaggers/text.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
# -*- coding: utf-8 -*-
21
from __future__ import absolute_import,division,print_function
32
from nine import nimport,str
43
from pythainlp.segment import segment
54
import pythainlp
65
import os
7-
import nltk.tag, nltk.data
86
json= nimport('json')
9-
codecs= nimport('codecs')
10-
reader = codecs.getreader("utf-8")
7+
import nltk.tag, nltk.data
118
templates_dir = os.path.join(os.path.dirname(pythainlp.__file__), 'corpus')
129
template_file = os.path.join(templates_dir, 'thaipos.json')
13-
data1 = json.load(reader(open(template_file).read()))
10+
#default_tagger = nltk.data.load(nltk.tag._POS_TAGGER)
11+
def data():
12+
with open(template_file) as handle:
13+
model = json.load(handle)
14+
return model
15+
data1 =data()
1416
#Postaggers ภาษาไทย
1517
def tag(text):
1618
"""รับค่าเป็นข้อความ ''str'' คืนค่าเป็น ''list'' เช่น [('ข้อความ', 'ชนิดคำ')]"""

0 commit comments

Comments
 (0)