Giter Site home page Giter Site logo

thuraaung1601 / mmcrfseg Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 1.0 626 KB

mmCRFseg: Word Segmentation for Myanmar Language using Conditional Random Fields

License: MIT License

Jupyter Notebook 85.02% Python 14.98%
crfsuite myanmar-nlp myanmar-tools myanmar-word-segmentation word-segmentation

mmcrfseg's Introduction

mmCRFseg: Myanmar Word Segmentation using Conditional Random Fields

Word Segmentation for Myanmar Language using Conditional Random Fields with character tagging - 1 for beginning of sentences and 0 for others.

ဪ ၊ အခန်း နံပါတ် ၃၀၅ မှာ တည်း လို့ ရ ပါ တယ် ။ အေးအေးဆေးဆေး ရှိ ပါ တယ် ။
[('ဪ', 0), ('၊', 1), ('အ', 1), ('ခ', 0), ('န', 0), ('်', 0), ('း', 0), ('န', 1), ('ံ', 0), ('ပ', 0), ('ါ', 0), ('တ', 0), ('်', 0), ('၃', 1), ('၀', 0), ('၅', 0), ('မ', 1), ('ှ', 0), ('ာ', 0), ('တ', 1), ('ည', 0), ('်', 0), ('း', 0), ('လ', 1), ('ိ', 0), ('ု', 0), ('့', 0), ('ရ', 1), ('ပ', 1), ('ါ', 0), ('တ', 1), ('ယ', 0), ('်', 0), ('။', 1), ('အ', 1), ('ေ', 0), ('း', 0), ('အ', 0), ('ေ', 0), ('း', 0), ('ဆ', 0), ('ေ', 0), ('း', 0), ('ဆ', 0), ('ေ', 0), ('း', 0), ('ရ', 1), ('ှ', 0), ('ိ', 0), ('ပ', 1), ('ါ', 0), ('တ', 1), ('ယ', 0), ('်', 0), ('။', 1)]
Scores
Precision 0.959
Recall 0.953
Accuracy 0.980

It was trained and tested on myPOS corpus version 3.0[1] and additional data collected from the internet and other Open resources. Win Pa Pa et.al [2] also studied the CRF approach but in this tool, we used different feature sets for better segmentation results.

Other useful text segmentation tools for Myanmar Langauge

  • myWord[3]: syllable, word, sub_word and phrase segmenter for Burmese

    • Regex-based for Syllable
    • Dictionary-based for Word
    • Unsupervised learning based for Phrase
  • Myan-word-breaker[4]: Statistical approach based word segmentation

  • pyidaungsu[5]: Python text processing library for Myanmar language

Download repo

git clone https://github.com/ThuraAung1601/mm-Word-Seg

Install requirement

pip install -r python-crfsuite

How to run

တစ်ဖိုင်လုံး Segmentation လုပ်ချင်တဲ့ ဖိုင် ရှိရင် ဒီလို အသုံးပြုပါ။

python ./seg.py -i test.txt -o out.txt
$ python seg.py --help
usage: seg.py [-h] [-i INPUT] [-o OUTPUT]

Word Segmentation for Burmese language using CRF model

optional arguments:
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        input file
  -o OUTPUT, --output OUTPUT
                        output file

တခြား Program ​တွေထဲ ထည့်သုံးချင်ရင် ဒီလို ​ခေါ် သုံးလို့ ရပါတယ်။

from seg import segment_word
sentence = "ဒီနေ့ကမ္ဘာ့စံချိန်သစ်တင်ခဲ့တယ်။"
segment_word(sentence)

Output: "ဒီ နေ့ ကမ္ဘာ့ စံချိန် သစ်တင် ခဲ့ တယ် ။"

from seg import segment_word
sentence = "မိုးရွာထားလို့အခန်းထဲမှာစိုထိုင်းထိုင်းဖြစ်နေတယ်"
segment_word(sentence)

Output: "မိုးရွာ ထား လို့ အခန်း ထဲ မှာ စိုထိုင်း ထိုင်း ဖြစ် နေ တယ်"

from seg import segment_word
sentences = "မောက်ချိုက်အရသာလေးက ပေါ့တဲ့ဘက်သွားတော့ အငန်မစားတဲ့သူဆို အတော်ပဲ ဆိုင်ကတမင် အငန်မစားတဲ့သူတွေအဆင်ပြေအောင်လျော့ထားပုံရတယ်"
segment_word(sentences)

Output: 'မောက်ချိုက် အရသာလေး က ပေါ့ တဲ့ ဘက် သွား တော့ အငန် မ စား တဲ့ သူ ဆို အတော် ပဲ ဆိုင် ကတမင် အငန် မ စား တဲ့ သူ တွေ အဆင်ပြေ အောင် လျော့ ထား ပုံ ရ တယ်'

from seg import segment_word
sentences = "ကိုရိုနာဗိုင်းရပ်စ် ဆိုတာ လူနဲ့ တခြားတိရစ္ဆာန်တွေကို ကူးစက်တတ်တဲ့ ဗိုင်းရပ်စ် တစ်မျိုး ဖြစ်ပါတယ် အကြမ်းအားဖြင့် လူသားတွေအကြားမှာ ကူးစက်ပြန့်ပွားပြီး ချောင်းဆိုးတာ ကိုယ်ပူတာနဲ့ နှာရည်ယိုတာတွေလို သာမန် အဖျားရောဂါနဲ့ ဆင်တူတဲ့ လက္ခဏာတွေကို ဖြစ်စေပါတယ်"
segment_word(sentences)

Output: ကိုရိုနာ ဗိုင်းရပ်စ် ဆို တာ လူ နဲ့ တခြား တိရစ္ဆာန် တွေ ကို ကူးစက် တတ် တဲ့ ဗိုင်းရပ်စ် တစ် မျိုး ဖြစ် ပါတယ် အကြမ်း အားဖြင့် လူသား တွေ အကြား မှာ ကူးစက် ပြန့်ပွား ပြီး ချောင်းဆိုးတာ ကိုယ်ပူတာ နဲ့ နှာရည် ယို တာ တွေ လို သာမန် အဖျား ရောဂါ နဲ့ ဆင်တူ တဲ့ လက္ခဏာ တွေ ကို ဖြစ် စေ ပါတယ်

References

[1] Ye Kyaw Thu, "myPOS (Myanmar Part-of-Speech) Corpus for Myanmar NLP Research and Developments", GitHub Link: https://github.com/ye-kyaw-thu/myPOS

[2] Win Pa Pa, Ye Kyaw Thu, Andrew M. Finch and Eiichiro Sumita. “Word Boundary Identification for Myanmar Text Using Conditional Random Fields.” ICGEC (2015).

[3] myWord: Syllable, Word, and Phrase Segmenter for Burmese, Ye Kyaw Thu, Sept 2021, GitHub Link: https://github.com/ye-kyaw-thu/myWord

[4] Myan-word-breaker: Nay Lin Aung, Github, Link: https://github.com/stevenay/myan-word-breaker

[5] pyidaungsu: Kaung Htet San, Github, Link: https://github.com/kaunghtetsan275/pyidaungsu

Citation

myCRFSeg: Word Segmentation Tool for Myanmar Language using Binary Tagging based Conditional Random Fields, Thura Aung, July 2022, GitHub Link: https://github.com/ThuraAung1601/mmCRFseg  

mmcrfseg's People

Contributors

thuraaung1601 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

yamoneko

mmcrfseg's Issues

Installation and running problems

Installation gives an error:

C:\tst\mm-Word-Seg>pip install -r python-crfsuite
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'python-crfsuite'

But still seemed to be installed:

pip install python-crfsuite
Requirement already satisfied: python-crfsuite in c:\users\johnt\appdata\local\programs\python\python310\lib\site-packages (0.9.9)

Running gives error:

C:\tst\mm-Word-Seg>python ./seg.py -i input.txt -o output.txt
Traceback (most recent call last):
File "C:\tst\mm-Word-Seg\seg.py", line 19, in
tagger.open('./mm-word-300.crfsuite')
File "pycrfsuite/_pycrfsuite.pyx", line 571, in pycrfsuite._pycrfsuite.Tagger.open
File "pycrfsuite/_pycrfsuite.pyx", line 733, in pycrfsuite._pycrfsuite.Tagger._check_model
FileNotFoundError: [Errno 2] No such file or directory: './mm-word-300.crfsuite'

Copying model\mm-word-segmentation-300.crfsuite to .\mm-word-300.crfsuite got rid of the error, but the output is not segmented.

Input:

ເຈົ້າມັກເຮັດຫຍັງເວລາຫວ່າງ?
ເຈົ້າເຮັດຫຍັງເວລາຫວ່າງ?
ໃນເວລາຫວ່າງຂ້ອຍມັກຟັງເພງ
ເຈົ້າມັກເຮັດຫຍັງ?

Output:

ເຈົ້າມັກເຮັດຫຍັງເວລາຫວ່າງ?
ເຈົ້າເຮັດຫຍັງເວລາຫວ່າງ?
ໃນເວລາຫວ່າງຂ້ອຍມັກຟັງເພງ
ເຈົ້າມັກເຮັດຫຍັງ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.