NLP package for Vietnamese
Project description
ViNLP
Installation
To install ViNLP:
$ pip install ViNLP
Tutorials
1. Word Segmentation
Usage
>>> from ViNLP import word_tokenize
>>> sentence = 'Hà Nội test nhanh SARS-CoV-2 cho hành khách từ TP.HCM đến sân bay Nội Bài'
>>> word_tokenize(sentence)
['Hà_Nội', 'test', 'nhanh', 'SARS-CoV-2', 'cho', 'hành_khách', 'từ', 'TP.HCM', 'đến', 'sân_bay', 'Nội_Bài']
2. POS Tagging
Usage
>>> from ViNLP import pos_tag
>>> sentence = 'Bộ Y tế công bố kế hoạch phân bổ vaccine COVID-19 đợt 5, TP.HCM nhiều nhất'
>>> pos_tag(sentence)
[('Bộ', 'N'),
('Y_tế', 'N'),
('công_bố', 'V'),
('kế_hoạch', 'N'),
('phân_bổ', 'V'),
('vaccine', 'N'),
('COVID-19', 'V'),
('đợt', 'N'),
('5', 'M'),
(',', 'CH'),
('TP.HCM', 'Ny'),
('nhiều', 'A'),
('nhất', 'R')]
3. Chunking
Usage
>>> from ViNLP import chunk
>>> sentence = 'Tổng thống Nga Putin tuyên bố sẵn sàng tiếp tục đối thoại với Mỹ'
>>> chunk(sentence)
[('Tổng_thống', 'N', 'B-NP'),
('Nga', 'Np', 'B-NP'),
('Putin', 'Np', 'I-NP'),
('tuyên_bố', 'V', 'B-VP'),
('sẵn_sàng', 'A', 'B-AP'),
('tiếp_tục', 'V', 'B-VP'),
('đối_thoại', 'V', 'B-VP'),
('với', 'E', 'B-PP'),
('Mỹ', 'Np', 'B-NP')]
4. Named Entity Recognition
Usage
>>> from ViNLP import ner
>>> sentence = 'Hậu thượng đỉnh, Tổng thống Putin nói ông Biden khác xa truyền thông miêu tả'
>>> ner(sentence)
[('Hậu', 'N', 'B-NP', 'O'),
('thượng_đỉnh', 'N', 'B-NP', 'O'),
(',', 'CH', 'O', 'O'),
('Tổng_thống', 'N', 'B-NP', 'O'),
('Putin', 'Np', 'B-NP', 'B-PER'),
('nói', 'V', 'B-VP', 'O'),
('ông', 'Nc', 'B-NP', 'O'),
('Biden', 'Np', 'B-NP', 'B-PER'),
('khác', 'A', 'B-AP', 'O'),
('xa', 'A', 'B-AP', 'O'),
('truyền_thông', 'N', 'B-NP', 'O'),
('miêu_tả', 'V', 'B-VP', 'O')]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ViNLP-1.1.0.tar.gz
(325.6 kB
view hashes)
Built Distribution
ViNLP-1.1.0-py3-none-any.whl
(330.3 kB
view hashes)