Conversation
| 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); |
There was a problem hiding this comment.
ใช้ RegEx ในกรณีนี้ ผมเห็นว่าเกินความจำเป็นนะครับ เราต้องการแค่เช็คตัวอักษรตัวที่ 4 เท่านั้นเอง
There was a problem hiding this comment.
เดี๋ยวเปลี่ยนเป็น start with หรือ เช็คตำแหน่งที่ 4 แทนครับ
| "อ." | ||
| }; | ||
|
|
||
| private static string[] vowels = new string[] { |
There was a problem hiding this comment.
ขอถกเรื่อง solution ใน issue นี้ก่อนนะครับ แนวทางตีโจทย์และหาทางออก เท่าที่คุยและคิดกัน เหมือนจะมี 2 อย่างครับ คือ ดูว่าตัวอักษรตัวที่ 4 เป็น สระ กับอีกอย่างคือ ยังมีชื่อที่ตัวอักษรตัวที่ 4 ไม่ใช่สระด้วย เช่น คุณณา แต่มันอาจจะมีน้อย จนเราอาจจะใช้วิธี list ชื่อคน"พิเศษ" เหล่านี้แบบ hard-code ไปเลย
คิดเห็นยังไงครับ? : )
There was a problem hiding this comment.
list พิเศษก็เหมาะสมครับ แค่อาจจะต้องคอยมาปรับปรุงอยู่เป็นระยะๆ
There was a problem hiding this comment.
ถ้าอย่างนั้น เราน่าจะมี 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 [] { "คุณวุฒิ", "คุณสมบัติ" };
No description provided.