diff --git a/example.ipynb b/example.ipynb new file mode 100644 index 0000000..62065f6 --- /dev/null +++ b/example.ipynb @@ -0,0 +1,97 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 19, + "id": "initial_id", + "metadata": { + "collapsed": true, + "ExecuteTime": { + "end_time": "2023-12-02T20:00:59.059610Z", + "start_time": "2023-12-02T20:00:58.497512Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Engine: MM\n", + "['ၵူၺ်းၵႃႈ', 'ဢၼ်', 'ပိုၼ်ၽၢဝ်ႇ', 'ဝႃႈ', 'AA', 'ပဵၼ်', 'ၸုမ်းၵေႃႇၵၢၼ်ႁၢႆႉ', 'ဢၼ်', 'ဝႃႈ', 'ၼၼ်ႉ', 'ပဵၼ်', 'လူင်ပွင်ၸိုင်ႈ', 'ၵူၼ်းမိူင်း', 'ၵေႃႉ', 'ပိုၼ်ၽၢဝ်ႇ', 'မႃး', '။', 'ၶေႃႈ', 'ပိုၼ်ၽၢဝ်ႇ', 'ဢၼ်', 'လူင်ပွင်ၸိုင်ႈ', 'ၵူၼ်းမိူင်း', 'ဢွၵ်ႇမႃး', 'ဝႆႉ', 'ၼၼ်ႉ', 'မိူဝ်ႈလဵဝ်', 'ယူႇ', 'တီႈ', 'ၶွင်ႊ', 'သီႊ', 'သိုၵ်း', 'မၢၼ်ႈ', 'ဢၼ်', 'တဵၵ်း', 'သိမ်း', 'ဢဝ်', 'ဢႃႇၼႃႇ', 'ဢၼ်', 'ဢမ်ႇၸႂ်ႈ', 'ၸုမ်း', 'ပဵၼ်', 'တၢင်း', 'ၵၢၼ်', 'ၶိုၼ်းဝႃႈ', 'ယိုတ်းသိမ်း', 'ပႅတ်ႈ', 'ၶေႃႈ', 'ပိုၼ်ၽၢဝ်ႇ', 'ဢၼ်ၼၼ်ႉ', 'ၼႆ', 'ႁဝ်းၶႃႈ', 'မႃး', 'ယိၼ်း', 'ၼႆႉ', 'မၼ်း', 'ပိူင်ႈ', 'ႁွႆႈ', 'ၵၼ်', 'ဝႆႉ', 'ဢိတ်းၼိုင်ႈ', 'ယဝ်ႉ', '။']\n", + "\n", + "\n", + "Engine: NewMM\n", + "['ၵူၺ်းၵႃႈ', 'ဢၼ်', 'ပိုၼ်ၽၢဝ်ႇ', 'ဝႃႈ', 'AA', 'ပဵၼ်', 'ၸုမ်းၵေႃႇၵၢၼ်ႁၢႆႉ', 'ဢၼ်', 'ဝႃႈ', 'ၼၼ်ႉ', 'ပဵၼ်', 'လူင်ပွင်ၸိုင်ႈ', 'ၵူၼ်းမိူင်း', 'ၵေႃႉ', 'ပိုၼ်ၽၢဝ်ႇ', 'မႃး', '။', 'ၶေႃႈ', 'ပိုၼ်ၽၢဝ်ႇ', 'ဢၼ်', 'လူင်ပွင်ၸိုင်ႈ', 'ၵူၼ်းမိူင်း', 'ဢွၵ်ႇမႃး', 'ဝႆႉ', 'ၼၼ်ႉ', 'မိူဝ်ႈလဵဝ်', 'ယူႇ', 'တီႈ', 'ၶွင်ႊ', 'သီႊ', 'သိုၵ်း', 'မၢၼ်ႈ', 'ဢၼ်', 'တဵၵ်း', 'သိမ်း', 'ဢဝ်', 'ဢႃႇၼႃႇ', 'ဢၼ်', 'ဢမ်ႇၸႂ်ႈ', 'ၸုမ်း', 'ပဵၼ်', 'တၢင်း', 'ၵၢၼ်', 'ၶိုၼ်းဝႃႈ', 'ယိုတ်းသိမ်း', 'ပႅတ်ႈ', 'ၶေႃႈ', 'ပိုၼ်ၽၢဝ်ႇ', 'ဢၼ်ၼၼ်ႉ', 'ၼႆ', 'ႁဝ်းၶႃႈ', 'မႃး', 'ယိၼ်း', 'ၼႆႉ', 'မၼ်း', 'ပိူင်ႈ', 'ႁွႆႈ', 'ၵၼ်', 'ဝႆႉ', 'ဢိတ်းၼိုင်ႈ', 'ယဝ်ႉ', '။']\n", + "0.5606639385223389\n" + ] + } + ], + "source": [ + "import time\n", + "from shannlp import word_tokenize\n", + "\n", + "# to measure time\n", + "start = time.time()\n", + "\n", + "# # Example usage\n", + "input_text = \"ၵူၺ်းၵႃႈ ဢၼ်ပိုၼ်ၽၢဝ်ႇဝႃႈ AA ပဵၼ်ၸုမ်းၵေႃႇၵၢၼ်ႁၢႆႉ ဢၼ်ဝႃႈၼၼ်ႉပဵၼ်လူင်ပွင်ၸိုင်ႈၵူၼ်းမိူင်းၵေႃႉပိုၼ်ၽၢဝ်ႇမႃး။ ၶေႃႈပိုၼ်ၽၢဝ်ႇဢၼ်လူင်ပွင်ၸိုင်ႈၵူၼ်းမိူင်းဢွၵ်ႇမႃးဝႆႉၼၼ်ႉ မိူဝ်ႈလဵဝ် ယူႇတီႈၶွင်ႊသီႊသိုၵ်းမၢၼ်ႈ ဢၼ်တဵၵ်းသိမ်း ဢဝ်ဢႃႇၼႃႇ ဢၼ်ဢမ်ႇၸႂ်ႈၸုမ်းပဵၼ်တၢင်းၵၢၼ် ၶိုၼ်းဝႃႈ ယိုတ်းသိမ်းပႅတ်ႈၶေႃႈပိုၼ်ၽၢဝ်ႇဢၼ်ၼၼ်ႉၼႆ ႁဝ်းၶႃႈ မႃး ယိၼ်းၼႆႉ မၼ်းပိူင်ႈႁွႆႈ ၵၼ်ဝႆႉဢိတ်းၼိုင်ႈယဝ်ႉ။\"\n", + "\n", + "print(\"Engine: MM\")\n", + "print(word_tokenize(input_text, keep_whitespace=False))\n", + "print(\"\\n\")\n", + "print(\"Engine: NewMM\")\n", + "print(word_tokenize(input_text, engine=\"newmm\", keep_whitespace=False))\n", + "\n", + "end = time.time()\n", + "print(end - start)" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['กระทรวง', 'ทรัพยากรธรรมชาติ', 'และ', 'กระทรวง', 'แรงงาน']\n" + ] + } + ], + "source": [ + "from pythainlp import word_tokenize\n", + "\n", + "print(word_tokenize(\"กระทรวง\", keep_whitespace=False))" + ], + "metadata": { + "collapsed": false, + "ExecuteTime": { + "end_time": "2023-12-02T20:06:27.995752Z", + "start_time": "2023-12-02T20:06:27.989797Z" + } + }, + "id": "d65239516e536fc4" + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}