The extraction of beautiful sound patterns from Sunthorn Phu’s Poem using machine learning technique and internal rhyme rule

Klon-Suphap (Klon-Pad) is the most popular Poem in Thailand. It has simple and uncomplicated prosody all together with rhythm and sound patterns which create melodiousness. The structure of KlonSuphap External Rhyme Prosody is shown in Fig. 1 [1]. External Rhyme occurs in relation between Wak and another, forward to each other, and Rhyme between chapters in other poems. It rules strict of prosody. A, b, c, and d is rhyme position, link by lines. The best of Klon-Suphap poems are the poems composed by Sunthorn Phu. The masterpiece of Sunthorn Phu is an epic poem named Phra Aphai Mani. Phra Aphai Mani is one of the most famous poems and has distinctive internal rhyme prosody. The internal rhyme prosody for Thai Poetry Klon-Suphap is shown in Fig. 2, for example, in Fig. 3 and Fig. 4, respectively. Fig. 3 and Fig. 4 show the phonetic alphabet of the Poem Phra Aphai Mani that has internal Rhyme, assonance, and alliteration. These components help develop the melodiousness of the Poem.


Introduction
Klon-Suphap (Klon-Pad) is the most popular Poem in Thailand. It has simple and uncomplicated prosody all together with rhythm and sound patterns which create melodiousness. The structure of Klon-Suphap External Rhyme Prosody is shown in Fig. 1 [1]. External Rhyme occurs in relation between Wak and another, forward to each other, and Rhyme between chapters in other poems. It rules strict of prosody. A, b, c, and d is rhyme position, link by lines. The best of Klon-Suphap poems are the poems composed by Sunthorn Phu. The masterpiece of Sunthorn Phu is an epic poem named Phra Aphai Mani. Phra Aphai Mani is one of the most famous poems and has distinctive internal rhyme prosody. The internal rhyme prosody for Thai Poetry Klon-Suphap is shown in Fig. 2, for example, in Fig. 3 and Fig. 4, respectively. Fig. 3 and Fig. 4 show the phonetic alphabet of the Poem Phra Aphai Mani that has internal Rhyme, assonance, and alliteration. These components help develop the melodiousness of the Poem.
To compose a melodious poem, there must be some references based on Sunthorn Phu's prototype. This Sunthorn Phu's style poem has been recognized as one of the most beautiful and popular poems [2] which was composed correctly according to the prosody. However, having only the correct external Rhyme of prosody still doesn't generate melodiousness. Sunthorn Phu performed the Poem more eargasmic by adding internal Rhyme to make the more dazzling Poem. In comparison, the ratio of a Wak with internal Rhyme is much higher than a Wak which doesn't have internal Rhyme in a poem. Therefore, the importance of internal Rhyme shouldn't be overlooked.  Don't run away, Grandpa, grandma Don't need to be sad.

200
International Journal of Advances in Intelligent Informatics ISSN 2442-6571 Vol. 7, No. 2, July 2021, pp. 198-210 Internal Rhyme is not restricted in both assonance and alliteration. It is a rhyme within a Wak. There is a play on words with a particular rhyme sound than normal to produce melodies and beautiful sounds. Internal Rhyme comprises assonance and alliteration. In some positions where assonance cannot be used, alliteration might be better. The popular technique used in internal Rhyme is assonance due to the various word choices. On the other hand, it is more challenging to use alliteration due to the limitation of words. Thus, a poet who writes a poem that includes both assonance and alliteration can be called a gifted poet. In addition to composing poems with rhymes, there is an adaptation of rhyme usages combining with songwriting by composing a song that has rhymes to develop the song's melodiousness. For example, the lyrics from a song called "The run ground whale" (วาฬเกยตื ้ น -GUNGUN) in Thai is "เพราะฉั นนั ้ นเป็ นวาฬที ่ เกยตื ้ นน ้ าตาย ใจสลายแหลกลงไปใต้ ทะเล", the phonetic alphabet is "phr@^4 chan^5 nan^4 pen^1 wa;n^1 thi;^3 k#;j^1 tv;n^3 nam^4 ta;j^1 -caj^1 sa^2 la;j^5 lx;k^2 long^1 paj^1 taj^3 tha^4 le;^1". The song's translated lyrics are "Because I am the run ground whale to die -My heart was broken at the bottom sea". From the example, the underlined words are internal rhymes and the bold words are external rhymes.
The extraction of the melodious sound patterns of poems is a challenge in natural language processing (NLP) because computers require to be developed to understand the prosody structure of the Poem (Klon-Suphap) and the position of the pair of sounds that make it melodious; see the reference in Fig.  2.
The melodiousness of poems could be analyzed in many terms, such as rhythms and syllables used in the Poem, words, and meanings used in the Poem. Many foreign poems (non-Thai language poem) used Heuristics for analyzing rhythms and syllables in Brazilian poems [16] and use rule-based for analyzing syllables in Arabic poems [17]. In Chinese Poem, the Apriori algorithm [19] was used to analyze the links between characters and analyze the association between ancient poetry [20]. In addition, this algorithm was also used to analyze ancient Chinese words by detecting words and finding new words in the ancient Chinese library [21] in conjunction with the use of BiLSTM (Bidirectional Long Short Term Memory) [22] to detect neologism. In Thai Poem, melodiousness depends on prosodies and what makes poems even more melodious is the internal rhymes. Therefore, verses must conform with prosodies [23]. Backus Naur Form (BNF) [24] technique can be used to verify verse validity. This technique verifies the word count and the melodiousness of prosodies but still lacks verification of the melodiousness of internal rhymes.
In the past, there was a similar study of Sunthorn Phu's Poem [15] focusing on Klon Niras, which is similar to Klon-Suphap. That research's main objective was to study the genuine poetry style of Sunthorn Phu by using the manual counting method, which analyzes the various characteristics that appear in the verse of Niras poem but did not identify the melodiousness pattern. This research presents the extraction of beautiful sound patterns from Sunthorn Phu's Poem to reflect the melodious sound of the internal Rhyme that Sunthorn Phu used in his composing. Therefore, nobody has researched this subject before.
This research extracts the melodious sound patterns of Phra Aphai Mani tales that Sunthorn Phu frequently used to compose poems. This study aims to illustrate the melodiousness of the Poem and set up a standard of how to compose a poem melodiously. We found some researcher works for poem domain such as classify the poem [3]- [6], extract features poem [7], poetry generation [8]- [10], evaluation poem [11], translated poetry [12]- [14], poem entity recognition [15], and analysis of the melodiousness of the Poem [16]- [18]. Nobody has researched extracting the melodious sound patterns before. Our analysis of the internal rhyme poetry structure was done by using Apriori Algorithm. The accuracy of the results was evaluated by many experts, including members of the Thai Poetry Institute, the Poetry Society members, the Language and Books Association, and the Vice President of the Thai Contemporary Poets Association. The extraction of the melodious sound patterns from a masterpiece of the role model poet resulted in the model, which can be used to create the automatic tools. The tools can examine and recommend the method for composing the melodious Poem (Klon-Suphap).

Process Overview
This research was divided into two main processes: 1) the preparation process and 2 ) the pattern recognition process. The process overview is shown in Fig. 5.

Fig. 5. Process Overview
This research used a total of 25 episodes (15,796 sentences) of Sunthorn Phu's fable poem named "Phra Aphai Mani" as the data set. The data was compiled from the Vajirayana digital library.

Data Preparation
This article used the data set (15,796 sentences) segmented into syllables by Syllable Segmentation API [25]. Then, Syllable segmentation transforms the syllable to Phoneme transformation by Phoneme Transformation API [26] to get the consonant, vowel, and tone. The output from the Syllable Segmentation API, URL is http://orathai-api.herokuapp.com/orathai/sentence, and example is URL http://orathai-api.herokuapp.com/orathai/เจ้ าพราหมณ์ ยิ ้ มพริ ้ มพรายธิ บายบอก are shown in Fig. 6. The Syllable Segmentation API on Table 1 shows that the parameter sentence with its desctiption and example input. Syllable Segmentation API will return syllable (payang), phoneme (phonemes), and word. We were checking the syllable before the syllable into phoneme transformation. The syllable checking is shown in Fig. 7.

Klon-Suphap Pattern Recognition
This part explains the procedure, which is the Apriori algorithm for this paper. The data set was divided into four groups because Wak has different specifications, including 1) Poem Wak No. 1 4 3,949 sentences. The input was structured as a 2-dimensional array. The data within the array consisted of the row data, Wak, the column data, which was the position of the syllable and vowel, converted into the phonetic alphabet. A syllable is a sound uttered at one time, whether that sound has meaning or not. Syllable elements consist of onset, Rhyme, and tone. The structure of the syllable is shown in Fig. 9. A vowel is a sound followed by a consonant, while the vowel's position in the structure of the syllable is shown in Fig. 10. Thai syllable structure can be divided into four types: CV, CCV, CVC, and CCVC. The conversion of vowels into the phonetic alphabet was the process of comparing the sounds to understand the pronunciation of the Thai language. The 44 consonant symbols in the Thai alphabet produce 21 initial consonant sounds and 8 final consonant sounds [27]. There are 24 vowel symbols and 32 vowel phonemes in the Thai language [28]. After phoneme transformation, we used the vowel converted into the phonetic alphabet. The input example, including the syllable position and the vowel that converted into the phonetic alphabet, is shown in Fig. 11.  Fig. 12 shows the finding algorithm of the popular assonance patterns. Each data group was put into the Apriori algorithm [25] to find the most frequently found items in the database. Firstly, the set of 1-itemsets would be detected by interpreting the database to count each item's frequency. Then the counting would identify which item met the minimum support. Only the items which counted more than or equal to the minimum support were selected for the next iteration, whereas the others were pruned. For example, the Apriori algorithm setting the minimum support = 50% and the minimum confidence = 80% is shown in Table 2. The frequent 1-itemsets (L 1 ) from the given data was founded based on the candidate 1-itemsets (C 1 ), then the support count of each 1-itemsets of C 1 would be compared with the minimum support specifying the qualified 1-itemsets, called frequent 1-itemsets (L 1 ). All those procedures are shown in Fig. 13. From the example, the set minimum support = 50% (50/100)*4 = 2 transactions. Thus, the itemsets qualified for the support criteria must have a greater than or equal to 2. After that, the frequent 2-itemsets (L 2 ) would be found based on the candidate 2-itemsets (C 2 ). C 2 would be created from the itemsets from L 1 in Fig. 13. Then both were joined together, as shown in Fig. 14   The percentages after the relationship rules were minimum support and minimum confidence, which could be calculated from support (A→ B) = P(A∪B) and confidence (A→B) = P(B|A) = P(A∪B)/P(A). Since the minimum confidence set = 80%, the rule was that each Wak in the Poem had the third syllable sound as vowel a; the fourth syllable sound as vowel a; which occur together in 75% of all transactions. Furthermore, If the third syllable sounded as vowel a; the fourth syllable sounded as vowel a; or if the fourth syllable sounded as vowel a; the third syllable sounded as a; by 100%. From dividing the data into four groups, the research can show the number of relationships patterns in Table 3. The outcome relationship model was cleaned by removing the duplicated vowel pairs in conjunction with the use of internal rhyme prosody to get the vowel pattern of each Wak. The sample of the repeating vowel pairs is shown in Fig. 15, and the number of patterns of the filtered data groups is shown in Table  4.  In Fig. 15, the vowel syllable No. 3 (a;) and syllable No. 4 (a;), and the vowel syllable No. 4 (a;) and syllable No. 3 (a;) were repeating two pairs of vowels which alternate positions syllable, but had the same meaning. Therefore, one pair had to be removed to reduce the redundancy of the relationship model. After filtering the data, a total of 25 popular pattern vowels of assonance were obtained and divided into 13 short vowels, 10 long vowels, 1 short-long vowel, and 1 long-short vowel-as shown in Table 5.   Fig. 2, a similar number of popular assonance patterns could be found.

Results and Discussion
Sound format extraction, the most common of the popular pattern vowel in Wak No. 1 was ; Wak No. 2 was the pair of vowel − ; Wak No. 3 was ; and Wak No. 4 was the pair of vowels − ;. Showing the most common popular pattern in each Wak in Table 6. From Table 6, The syllable pairs of the popular vowel pattern can be seen in Table 7. a; a-a;   Table 7, the syllable pairs of the popular pattern vowel found in each Wak are described as in Fig. 16.

Wak No. 3 popular vowel rhyme a; is 6 patterns 1) syllables rhyme is 3 and 4
2) syllables rhyme is 5 and 7 3) syllables rhyme is 6 and 8 4) syllables rhyme is 5 and 6 5) syllables rhyme is 2 and 3 6) syllables rhyme is 6 and 7 Wak No. 2 popular vowel rhyme a-a; is 6 patterns 1) syllables rhyme is 4 and 6 2) syllables rhyme is 5 and 6 3) syllables rhyme is 7 and 9 4) syllables rhyme is 7 and 8 5) syllables rhyme is 6 and 8 6) syllables rhyme is 5 and 7 Wak No. 4 popular vowel rhyme a-a; is 6 patterns 1) syllables rhyme is 4 and 6 2) syllables rhyme is 5 and 6 3) syllables rhyme is 7 and 8 4) syllables rhyme is 6 and 8 5) syllables rhyme is 2 and 3 6) syllables rhyme is 6 and 7 The examples of verse Wak that have a pair of popular vowel patterns of each Wak are shown in Table 8. The examples of Wak No. 2 and Wak No. 4, respectively. The vowel rhyme a-a; in the fourth and sixth syllable rhyme is one word. Many vowels were found as a-a; due to the use of words in the story. Phra Aphai Mani is a cloak and sword drama in which the words such as "กษั ตรา", which translated into English as "The King", and "พระบิ ดา" which is translated into English as "The father" are words generated from the combination of a and a;. Those words do not currently use in the modern Poem. Therefore, the second popular vowel pattern in Wak No. 2 and Wak No. 4 were found a vowel a; and aj shown in Table 9.   Table 9 could produce the syllable pairs of the popular vowel pattern that can be seen in Table 10. The syllable pairs of the popular pattern vowel found in each Wak are described as in Fig. 17.

Wak No. 2 popular vowels rhyme ; is 4 patterns
1) syllables rhyme is 5 and 7 2) syllables rhyme is 6 and 8 3) syllables rhyme is 6 and 7 4) syllables rhyme is 5 and 6 Wak No. 2 popular vowel rhyme is 4 patterns 1) syllables rhyme is 5 and 7 2) syllables rhyme is 5 and 6 3) syllables rhyme is 6 and 8 4) syllables rhyme is 6 and 7 Wak No. 4 popular vowel rhyme ; is 5 patterns 1) syllables rhyme is 5 and 7 2) syllables rhyme is 6 and 8 3) syllables rhyme is 3 and 5 4) syllables rhyme is 5 and 6 5) syllables rhyme is 6 and 7 Wak No. 4 popular vowel rhyme is 5 patterns 1) syllables rhyme is 5 and 7 2) syllables rhyme is 6 and 8 3) syllables rhyme is 5 and 6 4) syllables rhyme is 6 and 7 5) syllables rhyme is 2 and 3  The examples of verse Wak that have a pair of popular vowel patterns of each Wak are shown in Table 11. The questionnaire for experts to assess their opinions on the melodiousness of the rhyme patterns extracted from the story of Phra Aphai Mani was developed. The opinions of 3 experts evaluated an example of 18 Bots totals of 54 Bots. There were 216 Waks, divided into two pattern formats: 1) melodious 144 waks and 2) inferior melodious 72 waks.
Melodious pattern No. 1 is a verse in the bots where the pattern extraction tool found all assonances and found a total of 25 vowel rhymes. See at Table 3. The Assessment of melodiousness by experts compared with the system. In which the Poem has the melodious pattern No. 1 was a melodious poem. All three experts agreed. Second, Melodious pattern No. 2 is a verse in the bots where the pattern extraction tool found all assonances, but some waks may not have the sound that matched the melodious pattern No. 1. The Assessment of melodiousness by experts compared with the system. In which the Poem has the melodious pattern No. 2 was a melodious poem. All three experts agreed.
In addition, The inferior melodious pattern is a verse in the bots where the pattern extraction tool found some waks that did not have a vowel. The Assessment of melodiousness by experts compared with the system. In which the Poem has the inferior melodious pattern was a poem that was not melodious. Two experts agreed, and one expert disagreed. From the Assessment of melodiousness by experts compared with the system and the examination of the melodiousness efficiency of the Poem which was extracted by the tool, There were 144 Waks used in the examination. The results of the melodiousness are shown in Table 12. The consistency score from 3 experts shown is 95.30%

Conclusion
This research presents the extraction of the beautiful sound patterns from Sunthorn Phu's poem "Phra Aphai Mani" which he frequently used to compose other poems. From the evaluation of the popular vowel pattern and the Assessment of melodiousness by experts, the experts agreed that the melodious pattern No. 1 is melodious. This research illustrates that the melodiousness of a poem depends not only on assonance but also on alliteration. A poem that has both assonance and alliteration will be more even melodious. The extraction of the melodious sound patterns focuses only on assonance, without considering alliteration, an important element for melodiousness evaluation. Therefore, the development of tools to investigate alliteration will help improve the efficiency of the melodiousness pattern extraction.