-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
293 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from ...language import BaseDefaults, Language | ||
from .lex_attrs import LEX_ATTRS | ||
from .stop_words import STOP_WORDS | ||
|
||
|
||
class TibetanDefaults(BaseDefaults): | ||
lex_attr_getters = LEX_ATTRS | ||
stop_words = STOP_WORDS | ||
|
||
|
||
class Tibetan(Language): | ||
lang = "bo" | ||
Defaults = TibetanDefaults | ||
|
||
|
||
__all__ = ["Tibetan"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
Example sentences to test spaCy and its language models. | ||
>>> from spacy.lang.bo.examples import sentences | ||
>>> docs = nlp.pipe(sentences) | ||
""" | ||
|
||
|
||
sentences = [ | ||
"དོན་དུ་རྒྱ་མཚོ་བླ་མ་ཞེས་བྱ་ཞིང༌།", | ||
"ཏཱ་ལའི་ཞེས་པ་ནི་སོག་སྐད་ཡིན་པ་དེ་བོད་སྐད་དུ་རྒྱ་མཚོའི་དོན་དུ་འཇུག", | ||
"སོག་པོ་ཨལ་ཐན་རྒྱལ་པོས་རྒྱལ་དབང་བསོད་ནམས་རྒྱ་མཚོར་ཆེ་བསྟོད་ཀྱི་མཚན་གསོལ་བ་ཞིག་ཡིན་ཞིང༌།", | ||
"རྗེས་སུ་རྒྱལ་བ་དགེ་འདུན་གྲུབ་དང༌། དགེ་འདུན་རྒྱ་མཚོ་སོ་སོར་ཡང་ཏཱ་ལའི་བླ་མའི་སྐུ་ཕྲེང་དང་པོ་དང༌།", | ||
"གཉིས་པའི་མཚན་དེ་གསོལ་ཞིང༌།༸རྒྱལ་དབང་སྐུ་ཕྲེང་ལྔ་པས་དགའ་ལྡན་ཕོ་བྲང་གི་སྲིད་དབང་བཙུགས་པ་ནས་ཏཱ་ལའི་བླ་མ་ནི་བོད་ཀྱི་ཆོས་སྲིད་གཉིས་ཀྱི་དབུ་ཁྲིད་དུ་གྱུར་ཞིང་།", | ||
"ད་ལྟའི་བར་ཏཱ་ལའི་བླ་མ་སྐུ་ཕྲེང་བཅུ་བཞི་བྱོན་ཡོད།", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from ...attrs import LIKE_NUM | ||
|
||
# reference 1: https://en.wikipedia.org/wiki/Tibetan_numerals | ||
|
||
_num_words = [ | ||
"ཀླད་ཀོར་", | ||
"གཅིག་", "གཉིས་", "གསུམ་", "བཞི་", "ལྔ་", "དྲུག་", "བདུན་", "བརྒྱད་", "དགུ་", "བཅུ་", | ||
"བཅུ་གཅིག་", "བཅུ་གཉིས་", "བཅུ་གསུམ་", "བཅུ་བཞི་", "བཅུ་ལྔ་", "བཅུ་དྲུག་", "བཅུ་བདུན་", "བཅུ་པརྒྱད", "བཅུ་དགུ་", "ཉི་ཤུ་", | ||
"སུམ་ཅུ", "བཞི་བཅུ", "ལྔ་བཅུ", "དྲུག་ཅུ", "བདུན་ཅུ", "བརྒྱད་ཅུ", "དགུ་བཅུ", "བརྒྱ་", | ||
"སྟོང་", "ཁྲི་", "ས་ཡ་", " བྱེ་བ་", "དུང་ཕྱུར་", "ཐེར་འབུམ་", "ཐེར་འབུམ་ཆེན་པོ་", "ཁྲག་ཁྲིག་", "ཁྲག་ཁྲིག་ཆེན་པོ་", | ||
] | ||
|
||
|
||
def like_num(text): | ||
""" | ||
Check if text resembles a number | ||
""" | ||
if text.startswith(("+", "-", "±", "~")): | ||
text = text[1:] | ||
text = text.replace(",", "").replace(".", "") | ||
if text.isdigit(): | ||
return True | ||
if text.count("/") == 1: | ||
num, denom = text.split("/") | ||
if num.isdigit() and denom.isdigit(): | ||
return True | ||
if text in _num_words: | ||
return True | ||
return False | ||
|
||
|
||
LEX_ATTRS = {LIKE_NUM: like_num} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,198 @@ | ||
# Source: https://zenodo.org/records/10148636 | ||
|
||
STOP_WORDS = set( | ||
""" | ||
འི་ | ||
། | ||
དུ་ | ||
གིས་ | ||
སོགས་ | ||
ཏེ | ||
གི་ | ||
རྣམས་ | ||
ནི | ||
ཀུན་ | ||
ཡི་ | ||
འདི | ||
ཀྱི་ | ||
སྙེད་ | ||
པས་ | ||
གཞན་ | ||
ཀྱིས་ | ||
ཡི | ||
ལ | ||
ནི་ | ||
དང་ | ||
སོགས | ||
ཅིང་ | ||
ར | ||
དུ | ||
མི་ | ||
སུ་ | ||
བཅས་ | ||
ཡོངས་ | ||
ལས | ||
ཙམ་ | ||
གྱིས་ | ||
དེ་ | ||
ཡང་ | ||
མཐའ་དག་ | ||
ཏུ་ | ||
ཉིད་ | ||
ས | ||
ཏེ་ | ||
གྱི་ | ||
སྤྱི | ||
དེ | ||
ཀ་ | ||
ཡིན་ | ||
ཞིང་ | ||
འདི་ | ||
རུང་ | ||
རང་ | ||
ཞིག་ | ||
སྟེ | ||
སྟེ་ | ||
ན་རེ | ||
ངམ | ||
ཤིང་ | ||
དག་ | ||
ཏོ | ||
རེ་ | ||
འང་ | ||
ཀྱང་ | ||
ལགས་པ | ||
ཚུ | ||
དོ | ||
ཡིན་པ | ||
རེ | ||
ན་རེ་ | ||
ཨེ་ | ||
ཚང་མ | ||
ཐམས་ཅད་ | ||
དམ་ | ||
འོ་ | ||
ཅིག་ | ||
གྱིན་ | ||
ཡིན | ||
ན | ||
ཁོ་ན་ | ||
འམ་ | ||
ཀྱིན་ | ||
ལོ | ||
ཀྱིས | ||
བས་ | ||
ལགས་ | ||
ཤིག | ||
གིས | ||
ཀི་ | ||
སྣ་ཚོགས་ | ||
རྣམས | ||
སྙེད་པ | ||
ཡིས་ | ||
གྱི | ||
གི | ||
བམ་ | ||
ཤིག་ | ||
རེ་རེ་ | ||
ནམ | ||
མིན་ | ||
ནམ་ | ||
ངམ་ | ||
རུ་ | ||
འགའ་ | ||
ཀུན | ||
ཤས་ | ||
ཏུ | ||
ཡིས | ||
གིན་ | ||
གམ་ | ||
འོ | ||
ཡིན་པ་ | ||
མིན | ||
ལགས | ||
གྱིས | ||
ཅང་ | ||
འགའ | ||
སམ་ | ||
ཞིག | ||
འང | ||
ལས་ཆེ་ | ||
འཕྲལ་ | ||
བར་ | ||
རུ | ||
དང | ||
ཡ | ||
འག | ||
སམ | ||
ཀ | ||
ཅུང་ཟད་ | ||
ཅིག | ||
ཉིད | ||
དུ་མ | ||
མ | ||
ཡིན་བ | ||
འམ | ||
མམ | ||
དམ | ||
དག | ||
ཁོ་ན | ||
ཀྱི | ||
ལམ | ||
ཕྱི་ | ||
ནང་ | ||
ཙམ | ||
ནོ་ | ||
སོ་ | ||
རམ་ | ||
བོ་ | ||
ཨང་ | ||
ཕྱི | ||
ཏོ་ | ||
ཚོ | ||
ལ་ལ་ | ||
ཚོ་ | ||
ཅིང | ||
མ་གི་ | ||
གེ | ||
གོ | ||
ཡིན་ལུགས་ | ||
རོ་ | ||
བོ | ||
ལགས་པ་ | ||
པས | ||
རབ་ | ||
འི | ||
རམ | ||
བས | ||
གཞན | ||
སྙེད་པ་ | ||
འབའ་ | ||
མཾ་ | ||
པོ | ||
ག་ | ||
ག | ||
གམ | ||
སྤྱི་ | ||
བམ | ||
མོ་ | ||
ཙམ་པ་ | ||
ཤ་སྟག་ | ||
མམ་ | ||
རེ་རེ | ||
སྙེད | ||
ཏམ་ | ||
ངོ | ||
གྲང་ | ||
ཏ་རེ | ||
ཏམ | ||
ཁ་ | ||
ངེ་ | ||
ཅོག་ | ||
རིལ་ | ||
ཉུང་ཤས་ | ||
གིང་ | ||
ཚ་ | ||
ཀྱང | ||
""".split() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"text,match", | ||
[ | ||
("10", True), | ||
("1", True), | ||
("999.0", True), | ||
("གཅིག་", True), | ||
("གཉིས་", True), | ||
("ཀླད་ཀོར་", True), | ||
("བཅུ་གཅིག་", True), | ||
("ཁྱི་", False), | ||
(",", False), | ||
], | ||
) | ||
def test_lex_attrs_like_number(bo_tokenizer, text, match): | ||
tokens = bo_tokenizer(text) | ||
assert len(tokens) == 1 | ||
assert tokens[0].like_num == match |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters