Skip to content

Conversation

wannaphong
Copy link
Member

@wannaphong wannaphong commented Nov 5, 2021

Add pythainlp.transliterate.puan #620

ภาพ

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

Add pythainlp.transliterate.puan #620
@pep8speaks
Copy link

pep8speaks commented Nov 5, 2021

Hello @wannaphong! 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 2021-11-05 18:31:07 UTC

@wannaphong wannaphong linked an issue Nov 5, 2021 that may be closed by this pull request
@coveralls
Copy link

coveralls commented Nov 5, 2021

Coverage Status

Coverage increased (+0.02%) to 97.707% when pulling ca4c28d on add-spoonerism into 40af25d on dev.

"""
Thai Spoonerism
This function covent Thai word to Thai spoonerism word.
Copy link
Contributor

Choose a reason for hiding this comment

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

This function converts?

Thai Spoonerism
This function covent Thai word to Thai spoonerism word.
This function only supports words with 2 to 3 syllables.
Copy link
Contributor

Choose a reason for hiding this comment

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

It only supports words with 2 to 3 syllables.

This function covent Thai word to Thai spoonerism word.
This function only supports words with 2 to 3 syllables.
:param str word: Thai word to be spoonerism
Copy link
Contributor

Choose a reason for hiding this comment

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

Thai word to be (spoonerized). This should be V3. spoonerism sounds like a noun to me.

puan("นาริน", False)
# output: 'นินรา'
"""
_word = pronunciate(word, engine="w2p")
Copy link
Contributor

Choose a reason for hiding this comment

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

is it a convention that we start variable names with _?

self.assertEqual(puan("นาริน", False), "นินรา")
self.assertEqual(puan("สวัสดี"), "สะ-หี-ดวัด")
self.assertEqual(puan("สวัสดี", False), "สะหีดวัด")
self.assertEqual(puan("สวัสดีครับ"), "สวัสดีครับ")
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good if we have bad input cases (syllable length < 2 or > 3).
We might even raise an exception for this case.

def test_puan(self):
self.assertEqual(puan("นาริน"), "นิน-รา")
self.assertEqual(puan("นาริน", False), "นินรา")
self.assertEqual(puan("สวัสดี"), "สะ-หี-ดวัด")
Copy link
Contributor

Choose a reason for hiding this comment

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

If politeness is a concern, we might change this input to something else.

Copy link
Member Author

Choose a reason for hiding this comment

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

I fixed. Sorry, I don't check it.

@wannaphong wannaphong requested a review from p16i November 5, 2021 17:27
@wannaphong
Copy link
Member Author

wannaphong commented Nov 5, 2021

@heytitle I fixed with all your comment. Sorry, for my mistake.

@wannaphong
Copy link
Member Author

from

elif "ห" in j and "หฺ" not in i:

ภาพ
I wote wrong rule. I fix it by check char number.

ภาพ

Now
ภาพ

@p16i
Copy link
Contributor

p16i commented Nov 6, 2021

@wannaphong thanks for the fix. The code looks good to me.

Other than that, I would suggest you briefly write pseudo code on how the algorithm works. This might be helpful later when one comes to improve the algorithm. I think you can just edit the description of this PR content.

@p16i p16i merged commit d7a3e52 into dev Nov 6, 2021
@bact bact deleted the add-spoonerism branch November 8, 2021 21:29
@wannaphong wannaphong modified the milestones: 2.3, 3.0 Dec 27, 2021
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.

[feature] spoonerism (คำผวน) function
4 participants