Skip to main content

Vietnamese NLP Toolkit

Project description

Under The Sea - Vietnamese NLP Toolkit

https://img.shields.io/pypi/v/underthesea.svg https://img.shields.io/pypi/pyversions/underthesea.svg https://img.shields.io/pypi/l/underthesea.svg https://img.shields.io/travis/magizbox/underthesea.svg Documentation Status Updates https://img.shields.io/badge/chat-on%20facebook-green.svg

https://raw.githubusercontent.com/magizbox/underthesea/master/logo.jpg

underthesea is a suite of open source Python modules, data sets and tutorials supporting research and development in Vietnamese Natural Language Processing.

Installation

To install underthesea, simply:

$ pip install underthesea==1.1.5rc1
✨🍰✨

Satisfaction, guaranteed.

Usage

1. Corpus

https://img.shields.io/badge/documents-18k-red.svg https://img.shields.io/badge/words-74k-red.svg

Collection of Vietnamese corpus

2. Word Segmentation

https://img.shields.io/badge/F1-94%25-red.svg https://img.shields.io/badge/%E2%98%85-experiments-blue.svg

Vietnamese Word Segmentation using Conditional Random Fields

>>> # -*- coding: utf-8 -*-
>>> from underthesea import word_sent
>>> sentence = u"Chúng ta thường nói đến Rau sạch, Rau an toàn để phân biệt với các rau bình thường bán ngoài chợ."

>>> word_sent(sentence)
[u"Chúng ta", u"thường", u"nói", u"đến", u"Rau sạch", u",", u"Rau", u"an toàn", u"để", u"phân biệt", u"với",
u"các", u"rau", u"bình thường", u"bán", u"ngoài", u"chợ", u"."]

>>> word_sent(sentence, format="text")
u'Chúng_ta thường nói đến Rau_sạch , Rau an_toàn để phân_biệt với các rau bình_thường bán ngoài chợ .'

3. POS Tagging

https://img.shields.io/badge/accuracy-92.3%25-red.svg https://img.shields.io/badge/%E2%98%85-experiments-blue.svg

Vietnamese Part of Speech Tagging using Conditional Random Fields

>>> # -*- coding: utf-8 -*-
>>> from underthesea import pos_tag
>>> text = u"Chợ thịt chó nổi tiếng ở TP Hồ Chí Minh bị truy quét"
>>> pos_tag(text)
[(u'Chợ', 'N'),
 (u'thịt', 'N'),
 (u'chó', 'N'),
 (u'nổi tiếng', 'A'),
 (u'ở', 'E'),
 (u'TP HCM', 'Np'),
 (u'bị', 'V'),
 (u'truy quét', 'V')]

4. Chunking

https://img.shields.io/badge/F1-77%25-red.svg https://img.shields.io/badge/%E2%98%85-experiments-blue.svg

Vietnamese Chunking using Conditional Random Fields

>>> # -*- coding: utf-8 -*-
>>> from underthesea import chunk
>>> text = u"Bác sĩ bây giờ có thể thản nhiên báo tin bệnh nhân bị ung thư?"
>>> chunk(text)
[(u'Bác sĩ', 'N', 'B-NP'),
 (u'bây giờ', 'P', 'I-NP'),
 (u'có thể', 'R', 'B-VP'),
 (u'thản nhiên', 'V', 'I-VP'),
 (u'báo tin', 'N', 'B-NP'),
 (u'bệnh nhân', 'N', 'I-NP'),
 (u'bị', 'V', 'B-VP'),
 (u'ung thư', 'N', 'I-VP'),
 (u'?', 'CH', 'O')]

5. Named Entity Recognition

https://img.shields.io/badge/F1-86.6%25-red.svg https://img.shields.io/badge/%E2%98%85-experiments-blue.svg

Vietnamese Chunking using Conditional Random Fields

>>> # -*- coding: utf-8 -*-
>>> from underthesea import ner
>>> text = u"Chưa tiết lộ lịch trình tới Việt Nam của Tổng thống Mỹ Donald Trump"
>>> ner(text)
[('Chưa', 'R', 'O', 'O'),
 ('tiết lộ', 'V', 'B-VP', 'O'),
 ('lịch trình', 'V', 'B-VP', 'O'),
 ('tới', 'E', 'B-PP', 'O'),
 ('Việt Nam', 'Np', 'B-NP', 'B-LOC'),
 ('của', 'E', 'B-PP', 'O'),
 ('Tổng thống', 'N', 'B-NP', 'O'),
 ('Mỹ', 'Np', 'B-NP', 'B-LOC'),
 ('Donald', 'Np', 'B-NP', 'B-PER'),
 ('Trump', 'Np', 'B-NP', 'I-PER')]

6. Text Classification

https://img.shields.io/badge/accuracy-86.7%25-red.svg https://img.shields.io/badge/%E2%98%85-experiments-blue.svg

Vietnamese Text Classification using Fasttext

Install dependencies and download default model

$ pip install Cython
$ pip install future scipy numpy scikit-learn
$ pip install -U fasttext --no-cache-dir --no-deps --force-reinstall
$ underthesea data

Run classify

>>> # -*- coding: utf-8 -*-
>>> from underthesea import classify
>>> classify("HLV đầu tiên ở Premier League bị sa thải sau 4 vòng đấu")
['The thao']
>>> classify("Hội đồng tư vấn kinh doanh Asean vinh danh giải thưởng quốc tế")
['Kinh doanh']
>>> classify("Đánh giá “rạp hát tại gia” Samsung Soundbar Sound+ MS750")
['Vi tinh']

Up Coming Features

Contributing

Do you want to contribute with underthesea development? Great! Please read more details at CONTRIBUTING.rst.

History

1.1.5 (2017-10-12)

  • New feature: named entity recognition

  • Refactor and update model for word_sent, pos_tag, chunking

1.1.4 (2017-09-12)

  • New feature: text classification

  • [bug] Fix Text error

  • [doc] Add facebook link

1.1.3 (2017-08-30)

1.1.2 (2017-08-22)

  • Add dictionary

1.1.1 (2017-07-05)

  • Support Python 3

  • Refactor feature_engineering code

1.1.0 (2017-05-30)

  • Add chunking feature

  • Add pos_tag feature

  • Add word_sent feature, fix performance

  • Add Corpus class

  • Add Transformer classes

  • Integrated with dictionary of Ho Ngoc Duc

  • Add travis-CI, auto build with PyPI

1.0.0 (2017-03-01)

  • First release on PyPI.

  • First release on Readthedocs

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

underthesea-1.1.5rc1.tar.gz (8.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

underthesea-1.1.5rc1-py2.py3-none-any.whl (7.9 MB view details)

Uploaded Python 2Python 3

File details

Details for the file underthesea-1.1.5rc1.tar.gz.

File metadata

File hashes

Hashes for underthesea-1.1.5rc1.tar.gz
Algorithm Hash digest
SHA256 07686fac9dd91c9f208fb8b46e085081f37a1c0ccbdfe5b6cdef969ba4fee7fb
MD5 636fe24d7260110e05f2e6003be974d9
BLAKE2b-256 d54b4b4415b2da8796f660ebf9c2b15100cff279861a4e35eb24fab368ccdc1c

See more details on using hashes here.

File details

Details for the file underthesea-1.1.5rc1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for underthesea-1.1.5rc1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 041fc09b2aa1a908eb63c4156970c9de40b8bafa1af92b543830d24bc8feafc6
MD5 2b65924c5ff26338c99feb7df96aa1c7
BLAKE2b-256 404ac4e7d42fc003ac56da6d55cf45d5186296e8258557c58c9e05fa0b63b39a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page