Skip to content

fix Kunakorn case#2

Open
dinobenz wants to merge 1 commit intogreatfriends:masterfrom
dinobenz:master
Open

fix Kunakorn case#2
dinobenz wants to merge 1 commit intogreatfriends:masterfrom
dinobenz:master

Conversation

@dinobenz
Copy link
Copy Markdown

No description provided.

return string.Join(" ", parts);
if (parts[0].StartsWith(khun)) {
Regex regex = new Regex(Regex.Escape(khun));
string nextToKhun = regex.Replace(parts[0], string.Empty, 1);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ใช้ RegEx ในกรณีนี้ ผมเห็นว่าเกินความจำเป็นนะครับ เราต้องการแค่เช็คตัวอักษรตัวที่ 4 เท่านั้นเอง

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

เดี๋ยวเปลี่ยนเป็น start with หรือ เช็คตำแหน่งที่ 4 แทนครับ

"อ."
};

private static string[] vowels = new string[] {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ขอถกเรื่อง solution ใน issue นี้ก่อนนะครับ แนวทางตีโจทย์และหาทางออก เท่าที่คุยและคิดกัน เหมือนจะมี 2 อย่างครับ คือ ดูว่าตัวอักษรตัวที่ 4 เป็น สระ กับอีกอย่างคือ ยังมีชื่อที่ตัวอักษรตัวที่ 4 ไม่ใช่สระด้วย เช่น คุณณา แต่มันอาจจะมีน้อย จนเราอาจจะใช้วิธี list ชื่อคน"พิเศษ" เหล่านี้แบบ hard-code ไปเลย

คิดเห็นยังไงครับ? : )

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

list พิเศษก็เหมาะสมครับ แค่อาจจะต้องคอยมาปรับปรุงอยู่เป็นระยะๆ

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ถ้าอย่างนั้น เราน่าจะมี test cases ได้ประมาณนี้

// names that in the list
"คุณวุฒิ".AsKhun() => "คุณคุณวุฒิ"
"คุณคุณวุฒิ".AsKhun() => "คุณคุณวุฒิ"

// names that not in the list (can check with vowels)
"คุณากร".AsKhun() => "คุณคุณากร"
"คุณคุณากร".AsKhun() => "คุณคุณากร"

// names that not in the list (cannot check with vowels)
"คุณศรี".AsKhun() => "คุณศรี"
"คุณคุณศรี".AsKhun() => "คุณคุณศรี"

// the list
string[] specialNames = new string [] { "คุณวุฒิ", "คุณสมบัติ" };

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.

3 participants