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

Add preprocess function to split whitespace before romanize #924

Merged
merged 2 commits into from
Oct 7, 2024

Conversation

pavaris-pm
Copy link
Contributor

What does this PR changes

@wannaphong According to issue #922 there is room of improvement in transliterate function, where splitting whitespace yield much better performance. What do you think about it ? actually, we can improve this performance by adding tokenization module into the game so that the text can be splitted more logically too. Anyway, please let me know what do you think krub.

from pythainlp.transliterate import romanize

A = "สวัสดี ครับ"
B = "คุณ ชื่อ อะไร ครับ"
A_B = "สวัสดี ครับ คุณ ชื่อ อะไร ครับ"
print(romanize(A, engine="thai2rom"))
print(romanize(B, engine="thai2rom"))
print(romanize(A_B, engine="thai2rom"))
for z in A_B.split(' '):
    roman = romanize(z, engine="thai2rom")
    print(roman, ' ', end="")

# output: 
# sawatdi khrap
# khun chue arai khrap
# sawatdi khrap khun chuen chuen chuen chuen chuen chuen chuen chuen chuen chuen chuen chuen chuen chu
# sawatdi  khrap  khun  chue  arai  khrap 

Now, i've fixed it, and got a preprocessing of the input text during the function execution

from pythainlp.transliterate import romanize
A_B = "สวัสดี ครับ คุณ ชื่อ อะไร ครับ"
print(romanize(A_B, engine="thai2rom"))
# output: sawatdikhrapkhunchuearaikhrap

ps. just want to know that did PyThaiNLP joined Hacktoberfest 2024 thsi year ? please let me know

Your checklist for this pull request

🚨Please review the guidelines for contributing to this repository.

  • Passed code styles and structures
  • Passed code linting checks and unit test

@pep8speaks
Copy link

pep8speaks commented Oct 6, 2024

Hello @pavaris-pm! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-10-06 14:55:57 UTC

Copy link

sonarcloud bot commented Oct 6, 2024

@wannaphong
Copy link
Member

Thank you! PyThaiNLP is already join Hacktoberfest 2024 thsi year!

@wannaphong wannaphong self-requested a review October 7, 2024 18:29
Copy link
Member

@wannaphong wannaphong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@wannaphong wannaphong added the hacktoberfest-accepted hacktoberfest accepted pull requests. label Oct 7, 2024
@wannaphong wannaphong added this to the 5.1 milestone Oct 7, 2024
@wannaphong wannaphong merged commit 3fea2f7 into PyThaiNLP:dev Oct 7, 2024
8 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted hacktoberfest accepted pull requests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants