text-utils-vn 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ Copyright (c) [2026] [Nguyen Bao Duy]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
@@ -0,0 +1,63 @@
1
+ Metadata-Version: 2.4
2
+ Name: text-utils-vn
3
+ Version: 0.1.0
4
+ Summary: Các hàm tiện ích xử lý văn bản tiếng Việt
5
+ Author: Nguyen Bao Duy
6
+ License-Expression: MIT
7
+ Keywords: vietnamese,nlp,text-processing
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Natural Language :: Vietnamese
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Provides-Extra: test
15
+ Requires-Dist: pytest; extra == "test"
16
+ Dynamic: license-file
17
+
18
+ # text-utils-vn
19
+
20
+ Thư viện nhỏ gồm các hàm xử lý văn bản tiếng Việt: bỏ dấu, chuẩn hóa chuỗi, đếm từ và loại bỏ từ dừng (stopword).
21
+
22
+ ## Cài đặt
23
+
24
+ ```bash
25
+ pip install text-utils-vn
26
+ ```
27
+
28
+ ## Cách dùng
29
+
30
+ ```python
31
+ from text_utils_vn import remove_accents, normalize_text, count_words, remove_stopwords
32
+
33
+ remove_accents("Tiếng Việt") # 'Tieng Viet'
34
+ normalize_text(" Xin CHÀO bạn ") # 'xin chào bạn'
35
+ count_words("hôm nay trời đẹp") # 4
36
+ remove_stopwords("tôi là sinh viên") # 'sinh viên'
37
+ ```
38
+
39
+ ## Các hàm
40
+
41
+ | Hàm | Mô tả |
42
+ |---|---|
43
+ | `remove_accents(text)` | Bỏ dấu tiếng Việt, kể cả chữ `đ` / `Đ` |
44
+ | `normalize_text(text)` | Chuẩn hóa Unicode (NFC), chuyển chữ thường, gộp khoảng trắng thừa |
45
+ | `count_words(text)` | Đếm số từ tách theo khoảng trắng |
46
+ | `remove_stopwords(text)` | Bỏ các từ dừng thông dụng trong một danh sách nhỏ có sẵn |
47
+
48
+ ## Lưu ý
49
+
50
+ - `count_words` tách theo khoảng trắng nên thực chất đếm âm tiết, ví dụ "sinh viên" được tính là 2.
51
+ - Danh sách stopword có sẵn chỉ gồm một số từ phổ biến, mang tính minh họa.
52
+
53
+ ## Chạy test
54
+
55
+ ```bash
56
+ pip install -e ".[test]"
57
+ pytest
58
+ ```
59
+
60
+ ## Giấy phép
61
+
62
+ MIT License
63
+
@@ -0,0 +1,46 @@
1
+ # text-utils-vn
2
+
3
+ Thư viện nhỏ gồm các hàm xử lý văn bản tiếng Việt: bỏ dấu, chuẩn hóa chuỗi, đếm từ và loại bỏ từ dừng (stopword).
4
+
5
+ ## Cài đặt
6
+
7
+ ```bash
8
+ pip install text-utils-vn
9
+ ```
10
+
11
+ ## Cách dùng
12
+
13
+ ```python
14
+ from text_utils_vn import remove_accents, normalize_text, count_words, remove_stopwords
15
+
16
+ remove_accents("Tiếng Việt") # 'Tieng Viet'
17
+ normalize_text(" Xin CHÀO bạn ") # 'xin chào bạn'
18
+ count_words("hôm nay trời đẹp") # 4
19
+ remove_stopwords("tôi là sinh viên") # 'sinh viên'
20
+ ```
21
+
22
+ ## Các hàm
23
+
24
+ | Hàm | Mô tả |
25
+ |---|---|
26
+ | `remove_accents(text)` | Bỏ dấu tiếng Việt, kể cả chữ `đ` / `Đ` |
27
+ | `normalize_text(text)` | Chuẩn hóa Unicode (NFC), chuyển chữ thường, gộp khoảng trắng thừa |
28
+ | `count_words(text)` | Đếm số từ tách theo khoảng trắng |
29
+ | `remove_stopwords(text)` | Bỏ các từ dừng thông dụng trong một danh sách nhỏ có sẵn |
30
+
31
+ ## Lưu ý
32
+
33
+ - `count_words` tách theo khoảng trắng nên thực chất đếm âm tiết, ví dụ "sinh viên" được tính là 2.
34
+ - Danh sách stopword có sẵn chỉ gồm một số từ phổ biến, mang tính minh họa.
35
+
36
+ ## Chạy test
37
+
38
+ ```bash
39
+ pip install -e ".[test]"
40
+ pytest
41
+ ```
42
+
43
+ ## Giấy phép
44
+
45
+ MIT License
46
+
@@ -0,0 +1,26 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "text-utils-vn"
7
+ version = "0.1.0"
8
+ description = "Các hàm tiện ích xử lý văn bản tiếng Việt"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ license-files = ["LICENSE"]
13
+ authors = [{ name = "Nguyen Bao Duy" }]
14
+ keywords = ["vietnamese", "nlp", "text-processing"]
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "Operating System :: OS Independent",
18
+ "Natural Language :: Vietnamese",
19
+ ]
20
+ dependencies = []
21
+
22
+ [project.optional-dependencies]
23
+ test = ["pytest"]
24
+
25
+ [tool.setuptools.packages.find]
26
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,4 @@
1
+ from .core import remove_accents, normalize_text, count_words, remove_stopwords
2
+
3
+ __version__ = "0.1.0"
4
+ __all__ = ["remove_accents", "normalize_text", "count_words", "remove_stopwords"]
@@ -0,0 +1,46 @@
1
+ """Các hàm xử lý văn bản tiếng Việt."""
2
+ import unicodedata
3
+
4
+ STOPWORDS = {"tôi", "bạn", "là", "và", "của", "có", "những", "các", "một", "được", "này", "đó"}
5
+
6
+
7
+ def remove_accents(text: str) -> str:
8
+ """
9
+ Bỏ dấu tiếng Việt: 'Tiếng Việt' -> 'Tieng Viet'.
10
+ :param: text: Chuỗi văn bản đầu vào
11
+ :return: Chuỗi văn bản sau khi đã bỏ dấu
12
+ """
13
+ text = text.replace("đ", "d").replace("Đ", "D")
14
+ text = unicodedata.normalize("NFD", text)
15
+ text = "".join(c for c in text if unicodedata.category(c) != "Mn")
16
+ return unicodedata.normalize("NFC", text)
17
+
18
+
19
+ def normalize_text(text: str) -> str:
20
+ """
21
+ Chữ thường, bỏ khoảng trắng thừa.
22
+ :param: text: Chuỗi văn bản đầu vào
23
+ :return: Chuỗi văn bản sau khi được chuẩn hóa
24
+ """
25
+ text = unicodedata.normalize("NFC", text)
26
+ return " ".join(text.lower().split())
27
+
28
+
29
+
30
+ def count_words(text: str) -> int:
31
+ """
32
+ Đếm số từ (tách theo khoảng trắng).
33
+ :param: text: Chuỗi văn bản đầu vào
34
+ :return: Số lượng từ trong chuỗi văn bản"""
35
+ return len(text.split())
36
+
37
+
38
+ def remove_stopwords(text: str) -> str:
39
+ """
40
+ Bỏ các từ trong STOPWORDS.
41
+ :param: text: Chuỗi văn bản đầu vào
42
+ :return: Chuỗi văn bản sau khi bỏ stopwords
43
+ """
44
+ words = text.split()
45
+ filtered_words = [word for word in words if word.lower() not in STOPWORDS]
46
+ return " ".join(filtered_words)
@@ -0,0 +1,63 @@
1
+ Metadata-Version: 2.4
2
+ Name: text-utils-vn
3
+ Version: 0.1.0
4
+ Summary: Các hàm tiện ích xử lý văn bản tiếng Việt
5
+ Author: Nguyen Bao Duy
6
+ License-Expression: MIT
7
+ Keywords: vietnamese,nlp,text-processing
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Natural Language :: Vietnamese
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Provides-Extra: test
15
+ Requires-Dist: pytest; extra == "test"
16
+ Dynamic: license-file
17
+
18
+ # text-utils-vn
19
+
20
+ Thư viện nhỏ gồm các hàm xử lý văn bản tiếng Việt: bỏ dấu, chuẩn hóa chuỗi, đếm từ và loại bỏ từ dừng (stopword).
21
+
22
+ ## Cài đặt
23
+
24
+ ```bash
25
+ pip install text-utils-vn
26
+ ```
27
+
28
+ ## Cách dùng
29
+
30
+ ```python
31
+ from text_utils_vn import remove_accents, normalize_text, count_words, remove_stopwords
32
+
33
+ remove_accents("Tiếng Việt") # 'Tieng Viet'
34
+ normalize_text(" Xin CHÀO bạn ") # 'xin chào bạn'
35
+ count_words("hôm nay trời đẹp") # 4
36
+ remove_stopwords("tôi là sinh viên") # 'sinh viên'
37
+ ```
38
+
39
+ ## Các hàm
40
+
41
+ | Hàm | Mô tả |
42
+ |---|---|
43
+ | `remove_accents(text)` | Bỏ dấu tiếng Việt, kể cả chữ `đ` / `Đ` |
44
+ | `normalize_text(text)` | Chuẩn hóa Unicode (NFC), chuyển chữ thường, gộp khoảng trắng thừa |
45
+ | `count_words(text)` | Đếm số từ tách theo khoảng trắng |
46
+ | `remove_stopwords(text)` | Bỏ các từ dừng thông dụng trong một danh sách nhỏ có sẵn |
47
+
48
+ ## Lưu ý
49
+
50
+ - `count_words` tách theo khoảng trắng nên thực chất đếm âm tiết, ví dụ "sinh viên" được tính là 2.
51
+ - Danh sách stopword có sẵn chỉ gồm một số từ phổ biến, mang tính minh họa.
52
+
53
+ ## Chạy test
54
+
55
+ ```bash
56
+ pip install -e ".[test]"
57
+ pytest
58
+ ```
59
+
60
+ ## Giấy phép
61
+
62
+ MIT License
63
+
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/text_utils_vn/__init__.py
5
+ src/text_utils_vn/core.py
6
+ src/text_utils_vn.egg-info/PKG-INFO
7
+ src/text_utils_vn.egg-info/SOURCES.txt
8
+ src/text_utils_vn.egg-info/dependency_links.txt
9
+ src/text_utils_vn.egg-info/requires.txt
10
+ src/text_utils_vn.egg-info/top_level.txt
11
+ tests/test_core.py
@@ -0,0 +1,3 @@
1
+
2
+ [test]
3
+ pytest
@@ -0,0 +1 @@
1
+ text_utils_vn
@@ -0,0 +1,19 @@
1
+ from text_utils_vn import remove_accents, normalize_text, count_words, remove_stopwords
2
+
3
+
4
+ def test_remove_accents():
5
+ assert remove_accents("Tiếng Việt") == "Tieng Viet"
6
+ assert remove_accents("Học viện Kỹ thuật quân sự") == "Hoc vien Ky thuat quan su"
7
+
8
+
9
+ def test_normalize_text():
10
+ assert normalize_text(" Xin CHÀO bạn ") == "xin chào bạn"
11
+
12
+
13
+ def test_count_words():
14
+ assert count_words("hôm nay trời đẹp") == 4
15
+ assert count_words(" ") == 0
16
+
17
+
18
+ def test_remove_stopwords():
19
+ assert remove_stopwords("tôi là sinh viên") == "sinh viên"