File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change 33import os
44from nine import nimport ,str
55json = nimport ('json' )
6- codecs = nimport ('codecs' )
7- reader = codecs .getreader ("utf-8" )
86templates_dir = os .path .join (os .path .dirname (pythainlp .__file__ ), 'corpus' )
97template_file = os .path .join (templates_dir , 'thaipos.json' )
108def 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
Original file line number Diff line number Diff line change 1- # -*- coding: utf-8 -*-
21from __future__ import absolute_import ,division ,print_function
32from nine import nimport ,str
43from pythainlp .segment import segment
54import pythainlp
65import os
7- import nltk .tag , nltk .data
86json = nimport ('json' )
9- codecs = nimport ('codecs' )
10- reader = codecs .getreader ("utf-8" )
7+ import nltk .tag , nltk .data
118templates_dir = os .path .join (os .path .dirname (pythainlp .__file__ ), 'corpus' )
129template_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 ภาษาไทย
1517def tag (text ):
1618 """รับค่าเป็นข้อความ ''str'' คืนค่าเป็น ''list'' เช่น [('ข้อความ', 'ชนิดคำ')]"""
You can’t perform that action at this time.
0 commit comments