Skip to main content

Python utils for processing Tibetan

Project description

PYBO - Tibetan NLP in Python

PyPI version Test Test Coverage Publish Code style: black

Overview

pybo tokenizes Tibetan text into words.

Basic usage

Getting started

Requires to have Python3 installed.

python3 -m pip install pybo

Tokenizing a string

drupchen@drupchen:~$ pybo tok-string "༄༅། །རྒྱ་གར་སྐད་དུ། བོ་དྷི་སཏྭ་ཙརྻ་ཨ་བ་ཏ་ར། བོད་སྐད་དུ། བྱང་ཆུབ་སེམས་དཔའི་སྤྱོད་པ་ལ་འཇུག་པ། །
སངས་རྒྱས་དང་བྱང་ཆུབ་སེམས་དཔའ་ཐམས་ཅད་ལ་ཕྱག་འཚལ་ལོ། །བདེ་གཤེགས་ཆོས་ཀྱི་སྐུ་མངའ་སྲས་བཅས་དང༌། །ཕྱག་འོས་ཀུན་ལའང་གུས་པར་ཕྱག་འཚལ་ཏེ། །བདེ་གཤེགས་
སྲས་ཀྱི་སྡོམ་ལ་འཇུག་པ་ནི། །ལུང་བཞིན་མདོར་བསྡུས་ནས་ནི་བརྗོད་པར་བྱ། །"
Loading Trie... (2s.)
༄༅།_། རྒྱ་གར་ སྐད་ དུ །_ བོ་ དྷི་ སཏྭ་ ཙརྻ་ ཨ་བ་ ཏ་  །_ བོད་སྐད་ དུ །_ བྱང་ཆུབ་ སེམས་དཔ འི་ སྤྱོད་པ་ ལ་ འཇུག་པ །_། སངས་རྒྱས་ དང་ བྱང་ཆུབ་
སེམས་དཔའ་ ཐམས་ཅད་ ལ་ ཕྱག་ འཚལ་ ལོ །_། བདེ་གཤེགས་ ཆོས་ ཀྱི་ སྐུ་ མངའ་ སྲས་ བཅས་ དང༌ །_། ཕྱག་འོས་ ཀུན་  འང་ གུས་པ ར་ ཕྱག་ འཚལ་
ཏེ །_། བདེ་གཤེགས་ སྲས་ ཀྱི་ སྡོམ་ ལ་ འཇུག་པ་ ནི །_། ལུང་ བཞིན་ མདོར་བསྡུས་ ནས་ ནི་ བརྗོད་པ ར་ བྱ །_།

Tokenizing a list of files

The command to tokenize a list of files in a directory:

pybo tok <path-to-directory>

For example to tokenize the file text.txt in a directory ./document/ with the following content:

བཀྲ་ཤི་ས་བདེ་ལེགས་ཕུན་སུམ་ཚོགས། །རྟག་ཏུ་བདེ་བ་ཐོབ་པར་ཤོག། །

I use the command:

$ pybo tok ./document/

...which create a file text.txt in a directory ./document_pybo containing:

བཀྲ་ ཤི་ ས་ བདེ་ལེགས་ ཕུན་སུམ་ ཚོགས །_། རྟག་ ཏུ་ བདེ་བ་ ཐོབ་པ ར་ ཤོག །_།

Sorting Tibetan words

$ pybo kakha to-sort.txt

The expected input is one word or entry per line in a .txt file. The file will be overwritten.

FNR - Find and Replace with a list of regexes

pybo fnr <in-dir> <regex-file> -o <out-dir> -t <tag>

-o and -t are optional

Text files should be UTF-8 plain text files. The regexes should be in the following format:

<find-pattern><tab>-<tab><replace-pattern>

Acknowledgements

  • pybo is an open source library for Tibetan NLP.

We are always open to cooperation in introducing new features, tool integrations and testing solutions.

Many thanks to the companies and organizations who have supported pybo's development, especially:

Contributing

First clone this repo. Create virtual environment and activate it. Then install the dependencies

$ pip install -e .
$ pip install -r requirements-dev.txt

Next, setup up pre-commit by creating pre-commit git hook

$ pre-commit install

Please, follow augular commit message format for commit message. We have setup python-semantic-release to publish pybo package automatically based on commit messages.

That's all, Enjoy contributing 🎉🎉🎉

License

The Python code is Copyright (C) 2019 Esukhia, provided under Apache 2.

contributors:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybo-0.7.5.tar.gz (160.2 kB view hashes)

Uploaded Source

Built Distribution

pybo-0.7.5-py3-none-any.whl (22.2 kB view hashes)

Uploaded Python 3

Supported by

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