Skip to content

Commit 557dd7c

Browse files
committed
Improve docstring
1 parent e56aa62 commit 557dd7c

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

pythainlp/tag/locations.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ def tag_provinces(tokens: List[str]) -> List[Tuple[str, str]]:
1212
"""
1313
This function recognize Thailand provinces in text.
1414
15+
Note that it uses exact match and considers no context.
16+
1517
:param list[str] tokens: a list of words
1618
:reutrn: a list of tuple indicating NER for `LOCATION` in IOB format
1719
:rtype: list[tuple[str, str]]
@@ -24,13 +26,6 @@ def tag_provinces(tokens: List[str]) -> List[Tuple[str, str]]:
2426
text = ['หนองคาย', 'น่าอยู่']
2527
tag_provinces(text)
2628
# output: [('หนองคาย', 'B-LOCATION'), ('น่าอยู่', 'O')]
27-
28-
text = ['อำเภอ', 'ฝาง','เป็น','ส่วน','หนึ่ง','ของ', 'จังหวัด', \\
29-
'เชียงใหม่']
30-
tag_provinces(text)
31-
# output: [('อำเภอ', 'O'), ('ฝาง', 'O'), ('เป็น', 'O'), ('ส่วน', 'O'),
32-
# ('หนึ่ง', 'O'), ('ของ', 'O'), ('จังหวัด', 'O'),
33-
# ('เชียงใหม่', 'B-LOCATION')]
3429
"""
3530
province_list = provinces()
3631
output = [

pythainlp/tag/perceptron.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def _lst20_tagger():
5151
def tag(words: List[str], corpus: str = "pud") -> List[Tuple[str, str]]:
5252
"""
5353
:param list words: a list of tokenized words
54-
:param str corpus: name corpus (orchid or pud)
55-
:return: returns a list of labels regarding which part of speech it is
54+
:param str corpus: corpus name (orchid, pud, or lst20)
55+
:return: a list of tuples (word, POS tag)
5656
:rtype: list[tuple[str, str]]
5757
"""
5858
if not words:

pythainlp/tag/pos_tag.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def pos_tag(
2525
* *pud* - `Parallel Universal Dependencies (PUD)\
2626
<https://github.com/UniversalDependencies/UD_Thai-PUD>`_ \
2727
treebanks, natively use Universal POS tags
28-
:return: a list of (word, POS) as their members
28+
:return: a list of tuples (word, POS tag)
2929
:rtype: list[tuple[str, str]]
3030
3131
:Example:
@@ -121,7 +121,7 @@ def pos_tag_sents(
121121
* *pud* - `Parallel Universal Dependencies (PUD)\
122122
<https://github.com/UniversalDependencies/UD_Thai-PUD>`_ \
123123
treebanks, natively use Universal POS tags
124-
:return: returns a list of lists with (word, POS) as their members
124+
:return: a list of lists of tuples (word, POS tag)
125125
:rtype: list[list[tuple[str, str]]]
126126
127127
:Example:

pythainlp/tag/unigram.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,12 @@ def _find_tag(
5959
]
6060

6161

62-
def tag(words: List[str], corpus: str) -> List[Tuple[str, str]]:
62+
def tag(words: List[str], corpus: str = "pud") -> List[Tuple[str, str]]:
6363
"""
64-
รับค่าเป็น ''list'' คืนค่าเป็น ''list'' เช่น [('คำ', 'ชนิดคำ'), ('คำ', 'ชนิดคำ'), ...]
64+
:param list words: a list of tokenized words
65+
:param str corpus: corpus name (orchid, pud, or lst20)
66+
:return: a list of tuples (word, POS tag)
67+
:rtype: list[tuple[str, str]]
6568
"""
6669
if not words:
6770
return []

0 commit comments

Comments
 (0)