Skip to content

Commit 03fbe53

Browse files
authored
Merge pull request #193 from bact/dev
Small code refactor in pythainlp.tokenize.etcc, pythainlp.tokenize.tcc, pythainlp.util.date.thai_strftime(), and pythainlp.corpus.ttc
2 parents bfae642 + af3e59f commit 03fbe53

File tree

18 files changed

+19892
-247
lines changed

18 files changed

+19892
-247
lines changed

README-pypi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![PyThaiNLP Logo](https://avatars0.githubusercontent.com/u/32934255?s=200&v=4)
22

3-
# PyThaiNLP 2.0.2
3+
# PyThaiNLP 2.0.3
44

55
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/cb946260c87a4cc5905ca608704406f7)](https://www.codacy.com/app/pythainlp/pythainlp_2?utm_source=github.com&utm_medium=referral&utm_content=PyThaiNLP/pythainlp&utm_campaign=Badge_Grade)[![pypi](https://img.shields.io/pypi/v/pythainlp.svg)](https://pypi.python.org/pypi/pythainlp)
66
[![Build Status](https://travis-ci.org/PyThaiNLP/pythainlp.svg?branch=develop)](https://travis-ci.org/PyThaiNLP/pythainlp)

bin/pythainlp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,46 @@
11
#!python3
22
# -*- coding: utf-8 -*-
3+
4+
_VERSION = "2.0.3"
5+
36
import argparse
7+
48
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)
1317
args = parser.parse_args()
18+
1419
if args.corpus:
1520
from pythainlp.corpus import *
1621
print("PyThaiNLP Corpus")
1722
temp=""
1823
while temp!="exit":
19-
print("\n\nPlease fill this out.\n1. install\n2. remove\n3. update\n4. exit\nex 1 or 2")
20-
temp=input("input (1,2,3 or 4) : ")
24+
print("\n1. Install\n2. Remove\n3. Update\n4. Exit\n")
25+
temp=input("Choose 1, 2, 3, or 4: ")
2126
if temp=="1":
22-
name=input("name corpus : ")
27+
name=input("Corpus name:")
2328
download(name)
2429
elif temp=="2":
25-
name=input("name corpus : ")
30+
name=input("Corpus name:")
2631
remove(name)
2732
elif temp=="3":
28-
name=input("name corpus : ")
33+
name=input("Corpus name:")
2934
download(name)
3035
elif temp=="4":
3136
break
3237
else:
33-
print("Please input 1,2,3 or 4.")
38+
print("Choose 1, 2, 3, or 4:")
3439
elif args.text!=None:
3540
from pythainlp.tokenize import word_tokenize
36-
tokens=word_tokenize(args.text,engine=args.engine)
41+
tokens=word_tokenize(args.text, engine=args.engine)
3742
if args.segment:
38-
print('|'.join(tokens))
43+
print("|".join(tokens))
3944
elif args.postag:
4045
from pythainlp.tag import pos_tag
4146
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:
4550
args.engine="lk82"
4651
print(soundex(args.soundex, engine=args.engine))
4752
else:
48-
print("PyThaiNLP 2.0.2")
53+
print(f"PyThaiNLP {_VERSION}")

conda.recipe/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% set version = "2.0.2" %}
1+
{% set version = "2.0.3" %}
22

33
package:
44
name: pythainlp

docs/api/tokenize.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ Modules
1414
.. autofunction:: sent_tokenize
1515
.. autofunction:: dict_trie
1616
.. autoclass:: Tokenizer
17-
:members: word_tokenize,set_tokenize_engine
17+
:members: word_tokenize, set_tokenize_engine

meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% set version = "2.0.2" %}
1+
{% set version = "2.0.3" %}
22

33
package:
44
name: pythainlp

0 commit comments

Comments
 (0)