{
"info": {
"author": "Wirote Aroonmanakun",
"author_email": "awirote@chula.ac.th",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Programming Language :: Python :: 3.4",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Text Processing :: Linguistic"
],
"description": "Thai Language Toolkit Project version 1.4.1\n============================================\n\nTLTK is a Python package for Thai language processing: syllable, word, discouse unit segmentation, pos tagging, named entity recognition, grapheme2phoneme, ipa transcription, romanization, etc. TLTK requires Python 3.4 or higher.\nThe project is a part of open source software developed at Chulalongkorn University.\nSince version 1.2.2 pacakge license is changed to New BSD License (BSD-3-Clause)\n\nInput : must be utf8 Thai texts.\n\nUpdates:\n--------\nVersion 1.4 updated for gensim 4.0, Users can load a Thai corpus using Corpus(), then create a model using W2V_train(), D2V_train(); or load existing model from W2V_load(Model_File). TNC pretained w2v model is TNCc5model2.bin. Model of EDU segmentation is recompiled to work with new library. \n\nVersion 1.3.8 add spell_variants to gennerate all variation forms of the same pronunciation.\n\nVersion 1.3.6 remove \"matplotlib\" dependency, fix error on \"\u0e43\u0e04\u0e23\"\n\nMore compound words are added in the dictionary. Version 1.1.3-1.1.5 have many entries that are not a word and contain a few errors. Those entries are removed in later versions.\n\nNER tagger model was updated by using more NE data from AiforThai project. \n\ntltk.nlp : basic tools for Thai language processing.\n------------------------------------------------------\n\n>>tltk.nlp.chunk(Text) : chunk parsing. The output includes markups for word segments (|), elementary discourse units (), pos tags (/POS),and named entities (/PUNCT|\u0e44\u0e14\u0e49/AUX|\u0e19\u0e33/VERB|\u0e1b\u0e49\u0e32\u0e22\u0e1b\u0e23\u0e30\u0e01\u0e32\u0e28/NOUN|\u0e40\u0e15\u0e37\u0e2d\u0e19/VERB|\u0e1b\u0e25\u0e34\u0e07/NOUN|\u0e44\u0e1b/VERB|\u0e1b\u0e31\u0e01/VERB|\u0e15\u0e32\u0e21/ADP|\u0e41\u0e2b\u0e25\u0e48\u0e07\u0e19\u0e49\u0e33/NOUN|\u0e43\u0e19/ADP|/PUNCT|\u0e08\u0e31\u0e07\u0e2b\u0e27\u0e31\u0e14/NOUN|\u0e2d\u0e48\u0e32\u0e07\u0e17\u0e2d\u0e07/PROPN|/PUNCT|\u0e2d\u0e32\u0e22\u0e38/NOUN|65/NUM|/PUNCT|\u0e1b\u0e35/NOUN|\u0e16\u0e39\u0e01/AUX|\u0e1b\u0e25\u0e34\u0e07/VERB|\u0e01\u0e31\u0e14/VERB|\u0e41\u0e25\u0e49\u0e27/ADV|\u0e44\u0e21\u0e48\u0e44\u0e14\u0e49/AUX|\u0e44\u0e1b/VERB|\u0e1e\u0e1a/VERB|\u0e41\u0e1e\u0e17\u0e22\u0e4c/NOUN|'\n\n>>tltk.nlp.ner_tag(Text) : The output includes markups for named entities (', 'PUNCT')])\n\n=> [('\u0e2a\u0e33\u0e19\u0e31\u0e01\u0e07\u0e32\u0e19', 'NOUN', 'B-O'), ('\u0e40\u0e02\u0e15', 'NOUN', 'I-O'), ('\u0e08\u0e15\u0e38\u0e08\u0e31\u0e01\u0e23', 'PROPN', 'I-O'), ('\u0e0a\u0e35\u0e49\u0e41\u0e08\u0e07', 'VERB', 'O'), ('\u0e27\u0e48\u0e32', 'SCONJ', 'O'), ('', 'PUNCT', 'O')]\nNamed entity recognition is based on crf model adapted from http://sklearn-crfsuite.readthedocs.io/en/latest/tutorial.html Model is trainned with a corpus containing 170,000 named entities. B-O, I-O are tags for organizations; B-P, I-P are tags for persons; and B-L, I-L are tags for locations.\n\n>>tltk.nlp.pos_tag(Text,WordSegmentOption) : word segmentation and POS tagging (using nltk.tag.perceptron), e.g. tltk.nlp.pos_tag('\u0e42\u0e1b\u0e23\u0e41\u0e01\u0e23\u0e21\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e43\u0e2a\u0e48\u0e41\u0e17\u0e47\u0e01\u0e2b\u0e21\u0e27\u0e14\u0e04\u0e33\u0e20\u0e32\u0e29\u0e32\u0e44\u0e17\u0e22 \u0e27\u0e31\u0e19\u0e19\u0e35\u0e49\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19\u0e44\u0e14\u0e49\u0e1a\u0e49\u0e32\u0e07\u0e41\u0e25\u0e49\u0e27') or \n\n=> [[('\u0e42\u0e1b\u0e23\u0e41\u0e01\u0e23\u0e21', 'NOUN'), ('\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a', 'ADP'), ('\u0e43\u0e2a\u0e48', 'VERB'), ('\u0e41\u0e17\u0e47\u0e01', 'NOUN'), ('\u0e2b\u0e21\u0e27\u0e14\u0e04\u0e33', 'NOUN'), ('\u0e20\u0e32\u0e29\u0e32\u0e44\u0e17\u0e22', 'PROPN'), ('', 'PUNCT')], [('\u0e27\u0e31\u0e19\u0e19\u0e35\u0e49', 'NOUN'), ('\u0e43\u0e0a\u0e49\u0e07\u0e32\u0e19', 'VERB'), ('\u0e44\u0e14\u0e49', 'ADV'), ('\u0e1a\u0e49\u0e32\u0e07', 'ADV'), ('\u0e41\u0e25\u0e49\u0e27', 'ADV'), ('', 'PUNCT')]]\n\nBy default word_segment(Text,\"colloc\") will be used, but if option = \"mm\", word_segment(Text,\"mm\") will be used; POS tag set is based on Universal POS tags.. http://universaldependencies.org/u/pos/index.html\nnltk.tag.perceptron model is used for POS tagging. It is trainned with POS-tagged subcorpus in TNC (148,000 words)\n\n\n>>tltk.nlp.pos_tag_wordlist(WordLst) : Same as \"tltk.nlp.pos_tag\", but the input is a word list, [w1,w2,...]\n\n>>tltk.nlp.segment(Text) : segment a paragraph into elementary discourse units (edu) marked with and segment words in each edu e.g. tltk.nlp.segment(\"\u0e41\u0e15\u0e48\u0e2d\u0e32\u0e08\u0e40\u0e1e\u0e23\u0e32\u0e30\u0e19\u0e01\u0e01\u0e34\u0e19\u0e1b\u0e25\u0e35\u0e2d\u0e01\u0e40\u0e2b\u0e25\u0e37\u0e2d\u0e07\u0e40\u0e1b\u0e47\u0e19\u0e1e\u0e48\u0e2d\u0e41\u0e21\u0e48\u0e21\u0e37\u0e2d\u0e43\u0e2b\u0e21\u0e48\u2005\u0e23\u0e31\u0e07\u0e17\u0e35\u0e48\u0e17\u0e33\u0e08\u0e36\u0e07\u0e44\u0e21\u0e48\u0e04\u0e48\u0e2d\u0e22\u0e41\u0e02\u0e47\u0e07\u0e41\u0e23\u0e07 \u0e27\u0e31\u0e19\u0e2b\u0e19\u0e36\u0e48\u0e07\u0e23\u0e31\u0e07\u0e01\u0e47\u0e09\u0e35\u0e01\u0e40\u0e01\u0e37\u0e2d\u0e1a\u0e02\u0e32\u0e14\u0e40\u0e1b\u0e47\u0e19\u0e2a\u0e2d\u0e07\u0e17\u0e48\u0e2d\u0e19\u0e2b\u0e49\u0e2d\u0e22\u0e15\u0e48\u0e2d\u0e07\u0e41\u0e15\u0e48\u0e07 \u0e1c\u0e21\u0e1e\u0e22\u0e32\u0e22\u0e32\u0e21\u0e2b\u0e32\u0e2d\u0e38\u0e1b\u0e01\u0e23\u0e13\u0e4c\u0e21\u0e32\u0e22\u0e36\u0e14\u0e23\u0e31\u0e07\u0e01\u0e25\u0e31\u0e1a\u0e04\u0e37\u0e19\u0e23\u0e39\u0e1b\u0e17\u0e23\u0e07\u0e40\u0e14\u0e34\u0e21 \u0e02\u0e13\u0e30\u0e17\u0e35\u0e48\u0e41\u0e21\u0e48\u0e19\u0e01\u0e01\u0e34\u0e19\u0e1b\u0e25\u0e35\u0e2d\u0e01\u0e40\u0e2b\u0e25\u0e37\u0e2d\u0e07\u0e2a\u0e48\u0e07\u0e40\u0e2a\u0e35\u0e22\u0e07\u0e42\u0e27\u0e22\u0e27\u0e32\u0e22\u0e2d\u0e22\u0e39\u0e48\u0e43\u0e01\u0e25\u0e49 \u0e46 \u0e41\u0e15\u0e48\u0e2a\u0e38\u0e14\u0e17\u0e49\u0e32\u0e22\u0e44\u0e21\u0e48\u0e2a\u0e33\u0e40\u0e23\u0e47\u0e08\u2005\u0e2a\u0e2d\u0e07\u0e2a\u0e32\u0e21\u0e27\u0e31\u0e19\u0e15\u0e48\u0e2d\u0e21\u0e32\u0e23\u0e31\u0e07\u0e17\u0e35\u0e48\u0e0a\u0e48\u0e27\u0e22\u0e0b\u0e48\u0e2d\u0e21\u0e01\u0e47\u0e1e\u0e31\u0e07\u0e44\u0e1b \u0e44\u0e21\u0e48\u0e40\u0e2b\u0e47\u0e19\u0e41\u0e21\u0e48\u0e19\u0e01\u0e1a\u0e34\u0e19\u0e01\u0e25\u0e31\u0e1a\u0e21\u0e32\u0e2d\u0e35\u0e01\u0e40\u0e25\u0e22\") \n\n=> '\u0e41\u0e15\u0e48|\u0e2d\u0e32\u0e08|\u0e40\u0e1e\u0e23\u0e32\u0e30|\u0e19\u0e01\u0e01\u0e34\u0e19\u0e1b\u0e25\u0e35\u0e2d\u0e01\u0e40\u0e2b\u0e25\u0e37\u0e2d\u0e07|\u0e40\u0e1b\u0e47\u0e19|\u0e1e\u0e48\u0e2d\u0e41\u0e21\u0e48|\u0e21\u0e37\u0e2d\u0e43\u0e2b\u0e21\u0e48||\u0e23\u0e31\u0e07|\u0e17\u0e35\u0e48|\u0e17\u0e33|\u0e08\u0e36\u0e07|\u0e44\u0e21\u0e48|\u0e04\u0e48\u0e2d\u0e22|\u0e41\u0e02\u0e47\u0e07\u0e41\u0e23\u0e07\u0e27\u0e31\u0e19|\u0e2b\u0e19\u0e36\u0e48\u0e07|\u0e23\u0e31\u0e07|\u0e01\u0e47|\u0e09\u0e35\u0e01|\u0e40\u0e01\u0e37\u0e2d\u0e1a|\u0e02\u0e32\u0e14|\u0e40\u0e1b\u0e47\u0e19|\u0e2a\u0e2d\u0e07|\u0e17\u0e48\u0e2d\u0e19|\u0e2b\u0e49\u0e2d\u0e22|\u0e15\u0e48\u0e2d\u0e07\u0e41\u0e15\u0e48\u0e07\u0e1c\u0e21|\u0e1e\u0e22\u0e32\u0e22\u0e32\u0e21|\u0e2b\u0e32|\u0e2d\u0e38\u0e1b\u0e01\u0e23\u0e13\u0e4c|\u0e21\u0e32|\u0e22\u0e36\u0e14|\u0e23\u0e31\u0e07|\u0e01\u0e25\u0e31\u0e1a\u0e04\u0e37\u0e19|\u0e23\u0e39\u0e1b\u0e17\u0e23\u0e07|\u0e40\u0e14\u0e34\u0e21\u0e02\u0e13\u0e30|\u0e17\u0e35\u0e48|\u0e41\u0e21\u0e48|\u0e19\u0e01\u0e01\u0e34\u0e19\u0e1b\u0e25\u0e35\u0e2d\u0e01\u0e40\u0e2b\u0e25\u0e37\u0e2d\u0e07|\u0e2a\u0e48\u0e07\u0e40\u0e2a\u0e35\u0e22\u0e07|\u0e42\u0e27\u0e22\u0e27\u0e32\u0e22|\u0e2d\u0e22\u0e39\u0e48|\u0e43\u0e01\u0e25\u0e49|\u0e46\u0e41\u0e15\u0e48|\u0e2a\u0e38\u0e14\u0e17\u0e49\u0e32\u0e22|\u0e44\u0e21\u0e48|\u0e2a\u0e33\u0e40\u0e23\u0e47\u0e08||\u0e2a\u0e2d\u0e07|\u0e2a\u0e32\u0e21|\u0e27\u0e31\u0e19|\u0e15\u0e48\u0e2d|\u0e21\u0e32|\u0e23\u0e31\u0e07|\u0e17\u0e35\u0e48|\u0e0a\u0e48\u0e27\u0e22|\u0e0b\u0e48\u0e2d\u0e21|\u0e01\u0e47|\u0e1e\u0e31\u0e07|\u0e44\u0e1b\u0e44\u0e21\u0e48|\u0e40\u0e2b\u0e47\u0e19|\u0e41\u0e21\u0e48|\u0e19\u0e01|\u0e1a\u0e34\u0e19|\u0e01\u0e25\u0e31\u0e1a|\u0e21\u0e32|\u0e2d\u0e35\u0e01|\u0e40\u0e25\u0e22' edu segmentation is based on syllable input using RandomForestClassifier model, which is trained on an edu-segmented corpus (approx. 7,000 edus) created and used in Nalinee\u2019s thesis \n\n>>tltk.nlp.word_segment(Text,method='mm|ngram|colloc') : word segmentation using either maximum matching or ngram or maximum collocation approach. 'colloc' is used by default. Please note that the first run of ngram method would take a long time because TNC.3g will be loaded for ngram calculation. e.g. \n\ntltk.nlp.word_segment('\u0e1c\u0e39\u0e49\u0e2a\u0e37\u0e48\u0e2d\u0e02\u0e48\u0e32\u0e27\u0e23\u0e32\u0e22\u0e07\u0e32\u0e19\u0e27\u0e48\u0e32\u0e19\u0e32\u0e22\u0e01\u0e23\u0e31\u0e10\u0e21\u0e19\u0e15\u0e23\u0e35\u0e44\u0e21\u0e48\u0e21\u0e32\u0e17\u0e33\u0e07\u0e32\u0e19\u0e17\u0e35\u0e48\u0e17\u0e33\u0e40\u0e19\u0e35\u0e22\u0e1a\u0e23\u0e31\u0e10\u0e1a\u0e32\u0e25')\n=> '\u0e1c\u0e39\u0e49\u0e2a\u0e37\u0e48\u0e2d\u0e02\u0e48\u0e32\u0e27|\u0e23\u0e32\u0e22\u0e07\u0e32\u0e19|\u0e27\u0e48\u0e32|\u0e19\u0e32\u0e22\u0e01\u0e23\u0e31\u0e10\u0e21\u0e19\u0e15\u0e23\u0e35|\u0e44\u0e21\u0e48|\u0e21\u0e32|\u0e17\u0e33\u0e07\u0e32\u0e19|\u0e17\u0e35\u0e48|\u0e17\u0e33\u0e40\u0e19\u0e35\u0e22\u0e1a\u0e23\u0e31\u0e10\u0e1a\u0e32\u0e25|'\n\n>>tltk.nlp.syl_segment(Text) : syllable segmentation using 3gram statistics e.g. tltk.nlp.syl_segment('\u0e42\u0e1b\u0e23\u0e41\u0e01\u0e23\u0e21\u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a\u0e1b\u0e23\u0e30\u0e21\u0e27\u0e25\u0e1c\u0e25\u0e20\u0e32\u0e29\u0e32\u0e44\u0e17\u0e22') \n\n=> '\u0e42\u0e1b\u0e23~\u0e41\u0e01\u0e23\u0e21~\u0e2a\u0e33~\u0e2b\u0e23\u0e31\u0e1a~\u0e1b\u0e23\u0e30~\u0e21\u0e27\u0e25~\u0e1c\u0e25~\u0e20\u0e32~\u0e29\u0e32~\u0e44\u0e17\u0e22'\n\n>>tltk.nlp.word_segment_nbest(Text, N) : return the best N segmentations based on the assumption of minimum word approach. e.g. tltk.nlp.word_segment_nbest('\u0e04\u0e19\u0e02\u0e31\u0e1a\u0e23\u0e16\u0e1b\u0e23\u0e30\u0e08\u0e33\u0e17\u0e32\u0e07\u0e1b\u0e23\u0e31\u0e1a\u0e2d\u0e32\u0e01\u0e32\u0e28\"',10) \n\n=> [['\u0e04\u0e19\u0e02\u0e31\u0e1a|\u0e23\u0e16\u0e1b\u0e23\u0e30\u0e08\u0e33\u0e17\u0e32\u0e07|\u0e1b\u0e23\u0e31\u0e1a\u0e2d\u0e32\u0e01\u0e32\u0e28', '\u0e04\u0e19\u0e02\u0e31\u0e1a\u0e23\u0e16|\u0e1b\u0e23\u0e30\u0e08\u0e33\u0e17\u0e32\u0e07|\u0e1b\u0e23\u0e31\u0e1a\u0e2d\u0e32\u0e01\u0e32\u0e28', '\u0e04\u0e19|\u0e02\u0e31\u0e1a|\u0e23\u0e16\u0e1b\u0e23\u0e30\u0e08\u0e33\u0e17\u0e32\u0e07|\u0e1b\u0e23\u0e31\u0e1a\u0e2d\u0e32\u0e01\u0e32\u0e28', '\u0e04\u0e19|\u0e02\u0e31\u0e1a\u0e23\u0e16|\u0e1b\u0e23\u0e30\u0e08\u0e33\u0e17\u0e32\u0e07|\u0e1b\u0e23\u0e31\u0e1a\u0e2d\u0e32\u0e01\u0e32\u0e28', '\u0e04\u0e19\u0e02\u0e31\u0e1a|\u0e23\u0e16|\u0e1b\u0e23\u0e30\u0e08\u0e33\u0e17\u0e32\u0e07|\u0e1b\u0e23\u0e31\u0e1a\u0e2d\u0e32\u0e01\u0e32\u0e28', '\u0e04\u0e19\u0e02\u0e31\u0e1a\u0e23\u0e16|\u0e1b\u0e23\u0e30\u0e08\u0e33|\u0e17\u0e32\u0e07|\u0e1b\u0e23\u0e31\u0e1a\u0e2d\u0e32\u0e01\u0e32\u0e28', '\u0e04\u0e19\u0e02\u0e31\u0e1a|\u0e23\u0e16\u0e1b\u0e23\u0e30\u0e08\u0e33\u0e17\u0e32\u0e07|\u0e1b\u0e23\u0e31\u0e1a|\u0e2d\u0e32\u0e01\u0e32\u0e28', '\u0e04\u0e19\u0e02\u0e31\u0e1a\u0e23\u0e16|\u0e1b\u0e23\u0e30\u0e08\u0e33\u0e17\u0e32\u0e07|\u0e1b\u0e23\u0e31\u0e1a|\u0e2d\u0e32\u0e01\u0e32\u0e28', '\u0e04\u0e19|\u0e02\u0e31\u0e1a|\u0e23\u0e16|\u0e1b\u0e23\u0e30\u0e08\u0e33\u0e17\u0e32\u0e07|\u0e1b\u0e23\u0e31\u0e1a\u0e2d\u0e32\u0e01\u0e32\u0e28', '\u0e04\u0e19\u0e02\u0e31\u0e1a|\u0e23|\u0e16|\u0e1b\u0e23\u0e30\u0e08\u0e33\u0e17\u0e32\u0e07|\u0e1b\u0e23\u0e31\u0e1a\u0e2d\u0e32\u0e01\u0e32\u0e28']]\n\n>>tltk.nlp.g2p(Text) : return Word segments and pronunciations\ne.g. tltk.nlp.g2p(\"\u0e2a\u0e16\u0e32\u0e1a\u0e31\u0e19\u0e2d\u0e38\u0e14\u0e21\u0e28\u0e36\u0e01\u0e29\u0e32\u0e44\u0e21\u0e48\u0e2a\u0e32\u0e21\u0e32\u0e23\u0e16\u0e01\u0e49\u0e32\u0e27\u0e43\u0e2b\u0e49\u0e17\u0e31\u0e19\u0e01\u0e32\u0e23\u0e40\u0e1b\u0e25\u0e35\u0e48\u0e22\u0e19\u0e41\u0e1b\u0e25\u0e07\u0e02\u0e2d\u0e07\u0e15\u0e25\u0e32\u0e14\u0e41\u0e23\u0e07\u0e07\u0e32\u0e19\") \n\n=> \"\u0e2a\u0e16\u0e32~\u0e1a\u0e31\u0e19~\u0e2d\u0e38~\u0e14\u0e21~\u0e28\u0e36\u0e01~\u0e29\u0e32|\u0e44\u0e21\u0e48|\u0e2a\u0e32~\u0e21\u0e32\u0e23\u0e16|\u0e01\u0e49\u0e32\u0e27|\u0e43\u0e2b\u0e49|\u0e17\u0e31\u0e19|\u0e01\u0e32\u0e23|\u0e40\u0e1b\u0e25\u0e35\u0e48\u0e22\u0e19~\u0e41\u0e1b\u0e25\u0e07|\u0e02\u0e2d\u0e07|\u0e15\u0e25\u0e32\u0e14~\u0e41\u0e23\u0e07~\u0e07\u0e32\u0e19