Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precompile frequently-used pattern/regexes (PAT_ENG, PAT_TCC, PAT_TWOCHARS) #124

Merged
merged 5 commits into from
Oct 12, 2018

Conversation

bact
Copy link
Member

@bact bact commented Oct 12, 2018

คอมไพล์ regular expression ที่ใช้บ่อยๆ ไว้ล่วงหน้า ไม่ต้องคอมไพล์ทุกครั้ง

(ตรงที่เป็น code formatting จัดย่อหน้า จะข้ามไปเลยก็ได้ครับ ตัว black มันจัดให้อัตโนมัติ)

@coveralls
Copy link

Coverage Status

Coverage increased (+20.9%) to 74.336% when pulling aa80273 on bact:dev into aaf027a on PyThaiNLP:dev.

@coveralls
Copy link

coveralls commented Oct 12, 2018

Coverage Status

Coverage decreased (-0.2%) to 53.28% when pulling de13dc1 on bact:dev into aaf027a on PyThaiNLP:dev.

Now newmm.py will call tcc_gen() [previously named tcc1()] from tcc.py.

Note: that this may change the tokenization behaviour a little bit, as TCC pattern in tcc.py and newmm.py has three-line differences.

I stick with tcc.py's version, which has these three additional lines:
----
ๆ
ฯลฯ
ฯ
----
@bact
Copy link
Member Author

bact commented Oct 12, 2018

ลบโค้ด TCC ที่ซ้ำใน tcc.py และ newmm.py ให้ใช้โค้ดร่วมกัน

แต่พฤติกรรมของ newmm อาจจะเปลี่ยนเล็กน้อย เนื่องจาก patter/regex ใน tcc.py มีบรรทัดเพิ่มมาอีก 3 บรรทัด เมื่อเทียบกับ newmm.py โดยบรรทัดที่เพิ่มขึ้นมาใน tcc.py คือ:

ฯลฯ

เปลี่ยนชื่อ tcc1() เป็น tcc_gen() เพื่อความชัดเจนขึ้นว่าฟังก์ชันทำอะไร (gen = generator)

@wannaphong
Copy link
Member

เอา ๆ,ฯ, ฯลฯ ออกได้ไหมครับ

@bact
Copy link
Member Author

bact commented Oct 12, 2018

ได้เลยครับ

@wannaphong
Copy link
Member

รวมเรียบร้อยแล้ว ขอบคุณครับ

@wannaphong wannaphong merged commit 1bfe60a into PyThaiNLP:dev Oct 12, 2018
@wannaphong wannaphong mentioned this pull request Nov 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants