1
1
#!python3
2
2
# -*- coding: utf-8 -*-
3
+
4
+ _VERSION = "2.0.3"
5
+
3
6
import argparse
7
+
4
8
parser = argparse .ArgumentParser ()
5
- parser .add_argument ("-t" ,"--text" ,default = None , help = "text" ,type = str )
6
- parser .add_argument ("-seg" , "--segment" , help = "word segment" ,action = "store_true" )
7
- parser .add_argument ("-c" , "--corpus" , help = "mange corpus" ,action = "store_true" )
8
- parser .add_argument ("-pos" , "--postag" , help = "postag" ,action = "store_true" )
9
- parser .add_argument ("-soundex" , "--soundex" , help = "soundex" ,default = None )
10
- parser .add_argument ("-e" ,"--engine" ,default = "newmm" , help = "the engine" ,type = str )
11
- parser .add_argument ("-pos-e" ,"--postag_engine" ,default = "perceptron" , help = "the engine for word tokenize" ,type = str )
12
- parser .add_argument ("-pos-c" ,"--postag_corpus" ,default = "orchid" , help = "corpus for postag" ,type = str )
9
+ parser .add_argument ("-t" , "--text" , default = None , help = "text" , type = str )
10
+ parser .add_argument ("-seg" , "--segment" , help = "word segment" , action = "store_true" )
11
+ parser .add_argument ("-c" , "--corpus" , help = "mange corpus" , action = "store_true" )
12
+ parser .add_argument ("-pos" , "--postag" , help = "postag" , action = "store_true" )
13
+ parser .add_argument ("-soundex" , "--soundex" , help = "soundex" , default = None )
14
+ parser .add_argument ("-e" , "--engine" , default = "newmm" , help = "the engine" , type = str )
15
+ parser .add_argument ("-pos-e" , "--postag_engine" , default = "perceptron" , help = "the engine for word tokenize" , type = str )
16
+ parser .add_argument ("-pos-c" , "--postag_corpus" , default = "orchid" , help = "corpus for postag" , type = str )
13
17
args = parser .parse_args ()
18
+
14
19
if args .corpus :
15
20
from pythainlp .corpus import *
16
21
print ("PyThaiNLP Corpus" )
17
22
temp = ""
18
23
while temp != "exit" :
19
- print ("\n \n Please fill this out. \ n 1. install \n 2. remove \n 3. update \n 4. exit \n ex 1 or 2 " )
20
- temp = input ("input (1,2,3 or 4) : " )
24
+ print ("\n 1. Install \n 2. Remove \n 3. Update \n 4. Exit \n " )
25
+ temp = input ("Choose 1, 2, 3, or 4: " )
21
26
if temp == "1" :
22
- name = input ("name corpus : " )
27
+ name = input ("Corpus name: " )
23
28
download (name )
24
29
elif temp == "2" :
25
- name = input ("name corpus : " )
30
+ name = input ("Corpus name: " )
26
31
remove (name )
27
32
elif temp == "3" :
28
- name = input ("name corpus : " )
33
+ name = input ("Corpus name: " )
29
34
download (name )
30
35
elif temp == "4" :
31
36
break
32
37
else :
33
- print ("Please input 1,2,3 or 4. " )
38
+ print ("Choose 1, 2, 3, or 4: " )
34
39
elif args .text != None :
35
40
from pythainlp .tokenize import word_tokenize
36
- tokens = word_tokenize (args .text ,engine = args .engine )
41
+ tokens = word_tokenize (args .text , engine = args .engine )
37
42
if args .segment :
38
- print ('|' .join (tokens ))
43
+ print ("|" .join (tokens ))
39
44
elif args .postag :
40
45
from pythainlp .tag import pos_tag
41
46
print ("\t " .join ([i [0 ]+ "/" + i [1 ] for i in pos_tag (tokens , engine = args .postag_engine , corpus = args .postag_corpus )]))
@@ -45,4 +50,4 @@ elif args.soundex!=None:
45
50
args .engine = "lk82"
46
51
print (soundex (args .soundex , engine = args .engine ))
47
52
else :
48
- print ("PyThaiNLP 2.0.2 " )
53
+ print (f "PyThaiNLP { _VERSION } " )
0 commit comments