The word chain game is a word game in which players come up with words whose first character is the same as the previous word's last character. The purpose of this project is to explore the Korean version of the word chain game, creating visualizations of possible games. Using this, I am seeking to find which words are best for continuing a game for as long as possible.
Introduction
Introduction
Probably every Korean kid grows up playing 끝말잇기, the Korean version of the word chain game. It's almost the same as any other version of the game: starting with any word, then connecting words whose first letter is the same as the previous word's last letter, until no more words come to mind. Word choice is typically limited to nouns, most times allowing proper nouns only for places. The biggest difference from a word chain game in a different language is 두음법칙, the initial sound rule, which ends up becoming every kid's excuse for matching words that shouldn't match, even using the initial sound rule. It alters the spelling of Chinese loan/Sino-Korean words beginning with either the consonants "ㄹ" or "ㄴ" with certain vowels, we allow for connections to apply to such characters, introducing another step to the matching rules. In practice, use of the initial sound rule isn't typically very strict with which consonant-vowel combinations can be connected in a game-- however, this project will implement the initial sound rule as intended, according to an explanation posted on NAVER Post (잇찌, 2021).
Important to implementation of the initial sound rule later on: Hangul, the Korean alphabet, was created in 1443 CE by King Sejong the Great to improve national literacy by providing an alternative to Hanja, Chinese characters that were then used to write Korean. Modern Hangul consists of 14 basic consonant characters and 10 basic vowel characters, which can be used to form 5 tense consonant characters (two of the same basic consonant characters as one consonant sound), 11 complex consonant characters (two different basic consonant characters as one consonant sound), and 11 complex vowel characters (two different basic vowel characters as one vowel sound). These are then used to form syllabic blocks, consisting of:
1
.초성, choseong: an initial consonant (either a basic consonant character or a tense consonant character)
2
.중성, jungseong: a vowel (any of the 21 vowel characters)
3
.종성, jongseong: an ending consonant — this can be omitted (a basic consonant character, a complex consonant character, or certain tense consonant characters)
This project starts off initially similar to and is inspired by an example in Stephen Wolfram's post titled "Contents Games and Puzzles as Multicomputational Systems" that uses multiway systems to explore a word chain game using US state abbreviations (Wolfram, 2022). Because this game is largely played on long car trips to entertain young kids and deter them from falling out the window, I've made two decisions. One is to use a dataset with mostly vocabulary that a younger child or someone still learning Korean would know, and the other is to find which words are best to keep a game going.
Creating and visualizing a game
Creating and visualizing a game
Creating a word list
Creating a word list
The data I used was from the National Institute of Korean Language, 국립국어원. It is a .csv file of 5,965 vocabulary words for the purpose of learning Korean, published in May 2003. Each data point has five attributes:
4
1
.순위, the frequency ranking of the word in "현대 국어 사용 빈도 조사," a 2002 report on the usage frequency of Korean words in Contemporary Korean.
2
.단어, the actual word, with a number appended to the end if the word has multiple definitions.
3
.품사, a character that stands for what is the word's part of speech.
4
.풀이, an example to indicate the meaning of the word, whether that be the word in its original language or an example phrase/sentence.
5
.등급, the level/grade of the word (level 1 = A, level 2 = B, level 3 = C).
The raw imported data, formatted into a dataset:
rawData=CloudGet[CloudObject["https://www.wolframcloud.com/obj/367df55f-14ce-412b-b3e3-5c34c92d2610"]];Dataset[rawData[[;;20]]]
Creating a list of just words whose part of speech is listed as noun, sorting by frequency ranking, cleaning up the words to remove any duplicate indicators, then deleting duplicates within the list:
In[]:=
kwNouns=Drop[rawData,1]//SortBy[Part[2]]//Select[#[[3]]==="명"&]//Transpose//Table[StringDelete[#[[2]][[n]],StringPartition["0123456789",1]],{n,1,Length[#[[1]]]}]&//DeleteDuplicates;
A random sample of 25 from the noun list, to check:
RandomSample[kwNouns,25]
Out[]=
소질,안방,경제학,예식장,의도,표시,부모,터미널,들,몸,낚시꾼,화제,온종일,애,장미,사회,시댁,피곤,등,소망,술,우주,간판,토요일,첫날
Matching rules
Matching rules
Because of the initial sound rule, I need to know whether the choseong and jungseong of a syllabic block can connect with the same of another block, as well as if the jongseong is the same. Since I don't want to manually write an association of the 476 different possibilities, I'm going to split the syllabic block into its three component characters. This code was adapted from a blog post about doing this in Python3 (Sophie__, 2017).
Splitting a Korean syllable block character into its component characters:
In[]:=
splitCharacter[character_String]:=Module[choseongList="ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ",jungseongList="ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ",jongseongList=" ","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ",charCode=ToCharacterCode[character][[1]]-44032,choseong,jungseong,jongseong,choseong=Floor[charCode/588];jungseong=Floor[(charCode-choseong*588)/28];jongseong=Floor[charCode-choseong*588-jungseong*28];{choseongList[[choseong+1]],jungseongList[[jungseong+1]],jongseongList[[jongseong+1]]}]
Determining true/false if two words can match in the order of input under the Korean game rules.
In[]:=
twoSoundRules=<|"ㄹㅣ"->"ㅇ","ㅣ","ㄹㅑ"->"ㅇ","ㅑ","ㄹㅕ"->"ㅇ","ㅕ","ㄹㅛ"->"ㅇ","ㅛ","ㄹㅠ"->"ㅇ","ㅠ","ㄴㅣ"->"ㅇ","ㅣ","ㄴㅑ"->"ㅇ","ㅑ","ㄴㅕ"->"ㅇ","ㅕ","ㄴㅛ"->"ㅇ","ㅛ","ㄴㅠ"->"ㅇ","ㅠ","ㄹㅏ"->"ㄴ","ㅏ","ㄹㅓ"->"ㄴ","ㅓ","ㄹㅗ"->"ㄴ","ㅗ","ㄹㅜ"->"ㄴ","ㅜ","ㄹㅐ"->"ㄴ","ㅐ","ㄹㅔ"->"ㄴ","ㅔ","ㄹㅚ"->"ㄴ","ㅚ"|>;
In[]:=
matchRules[wfirst_String,wsecond_String]:=Module[{splitfirst=splitCharacter[StringPart[wfirst,-1]],splitsecond=splitCharacter[StringPart[wsecond,1]]},Which[wfirst===wsecond,False,splitfirst===splitsecond,True,Lookup[twoSoundRules,StringJoin[Take[splitfirst,2]],"NotARule"]===Take[splitsecond,2]&&splitfirst[[3]]===splitsecond[[3]],True,True,False]]
Functions to visualize possible games
Functions to visualize possible games
There are a couple different ways to visualize a game of word chain, but most important would be a graph that shows the different ways words can possibly connect to one another, and a multiway graph showing the possible paths a game can take from a word that doesn't revisit words used previously.
Creating a relation graph of all possible connections between any two words in a given list and removing all vertices that have no connections to any other words:
In[]:=
createRelation[wordList_List,matchingRules_]:=Module[{rawRelation=RelationGraph[matchingRules[#1,#2]&,wordList],removedVertices={}},If[(IncidenceList[rawRelation,#]//Length)===0,AppendTo[removedVertices,#]]&/@VertexList[rawRelation];{VertexDelete[rawRelation,removedVertices],removedVertices}]
Graphing the possibilities found in createRelation, showing how words in a list can connect to one another when only considering one another:
In[]:=
createVis1[relation_Graph,arrowSize_:Automatic,vertexSize_:Automatic]:=Graphrelation,
In[]:=
createMultiwayDeletions[relation_Graph,root_,depth_Integer]:=[relation,root,VertexDelete,depth]
Graphing the multiway deletions graph found in createMultiwayDeletions, showing all possible paths a game can take (with createVis3 being the same as createVis2, just with the GraphLayout option designated as LayeredDigraphEmbedding):
In[]:=
createVis2[multiway_Graph,arrowSize_Symbol:Automatic,vertexSize_Symbol:Automatic]:=Graphmultiway,createVis3[multiway_Graph,arrowSize_Symbol:Automatic,vertexSize_Symbol:Automatic]:=Graphmultiway,
An example
An example
Here's an example using the 100 most common nouns within the dataset.
Creating a relation of the 100 most common nouns, then displaying it:
testWords=Take[kwNouns,100];testRelationGraph=createRelation[testWords,matchRules][[1]];createVis1[testRelationGraph,Small,Automatic]
Out[]=
Creating multiway deletions graphs starting from all vertices in the previously generated relation graph and traversing until the end of a game (no more words to connect to), then displaying said multiway graphs in two graph layouts:
Game analysis
Game analysis
Possible path lengths
Possible path lengths
I want to know how the path length distribution looks using the example above with 100 words. The way I've chosen to do this is to take all the words in the multiway graph that connect to nothing else when they are the starting vertex, then checking all paths generated at each step of the multiway graph to see if it contains one of these words. This does produce an edge case: if a path ends on a word that is not one of these, it won't be counted as a full game path. This can happen if all possible options for a word to connect to have been used further up in the path. It is possible to work around this, but the way I tried took much longer than reasonable, and this is an uncommon scenario to begin with, so I'll leave the method as is.
Finding all words that will definitively end the game path, then find all paths that contain one of these to find paths where the game ends:
Display a histogram of the length of the paths found above:
Generalizing the above example into a function:
Unfortunately, this takes a while on any list of over 200 words and the time taken gets exponentially worse as the list length increases, so creating a multiway deletions graph of the whole noun list is unrealistic — finding all the game paths is even more so. Using less words is the only possible option besides improving the efficiency of the functions above.
The code using the function allGameEndPaths (so the two following input blocks) takes quite a while to run, the first taking about eight to ten minutes and the second depending on the random sample of words, so I don't recommend running it.
Creating a histogram of the length of all game paths created by using the 225 most common nouns within the dataset:
Creating two histograms from the length of all game paths created by five different random samples of 200 nouns from the dataset, one histogram displaying the values overlapped and the other the values stacked:
Syllable frequency and attractiveness
Syllable frequency and attractiveness
I'd like to see how popular each syllable is in four different areas: as a character anywhere in the word, as the first character of a word, as the last character of a word, and as either the first or last character of a word.
Creating an association of syllables used within the dataset and the frequency they have for the values listed above, then displaying a few of the most popular ones in a bar chart:
In order to keep a word chain going for as long as possible, it's best to use a word whose last syllable is both popular and has a roughly equal amount of words in which the used syllable is the first and last syllable. For example, a syllable like "장," although very common, has very few words in which it is the first syllable compared to how many words in which it is the last. Using this idea, I'll calculate a syllable's "attractiveness" — the numbers and operations I'm using are just gut instinct, so this isn't going to be necessarily accurate.
Sorting the syllable blocks present in the noun list by their "attractiveness," with a higher number indicating that using words in which they are the last character will keep a game going for as long as possible:
Now, calculating a word's attractiveness. I'm calculating this using the geometric means of the first and last syllables of the word.
Using character attractiveness found above, find the attractiveness of each word in the dataset, with a higher "WordAttractiveness" indicating a better capacity of continuing a game:
Conclusion and next steps
Conclusion and next steps
Through this project, I've learned a lot about the Wolfram language and working with connected graphs. Although this project has very few substantial real world applications, I hope some Korean kid searching the internet for the best ways to win in games of 끝말잇기 against their parents will find it useful.
As for future steps, I'd like to do a few things, including implementing more vocabulary lists (such as for place names or for specialized fields of study), improving the efficiency with which the multiway graphs are created and paths are found, and do further research on the histograms I've found — it's interesting that words taken by popularity very quickly form a normal distribution, while random samples of words don't level out as quickly. Additionally, I'd like to see if my analysis of which words are best to continue a game can be expanded by taking into account the words that can be connected to that word instead of just the calculated "character attractiveness" of the word's first and last syllables.
Acknowledgements
Acknowledgements
I would like to thank my mentor CJ Applebaum for continued support and guidance throughout the project. Additionally, I'd like to acknowledge my dad as well as the rest of my family, who listened to my ranting about the initial sound rule and Korean character encoding and helped find and translate many of the Korean resources I used.
References
References
끝말잇기. Namuwiki. (2011, February 16). https://namu.wiki/w/끝말잇기
두음법칙. Namuwiki. (2011, January 29). https://namu.wiki/w/두음법칙
두음법칙 뜻과 예시 설명. NAVER 포스트. (2021, June 21). https://post.naver.com/viewer/postView.nhn?volumeNo=31806242
Sophie__. (2017, December 28). [NLP] 한글 유니코드 자소 분리(초/중/종성 분리) with Python3. rachelee.org. https://rachelsdotcom.tistory.com/79
Wolfram, S. (2022, June 8). Games and Puzzles as Multicomputational Systems. Stephen Wolfram Writings RSS. https://writings.stephenwolfram.com/2022/06/games-and-puzzles-as-multicomputational-systems
CITE THIS NOTEBOOK
CITE THIS NOTEBOOK
Exploring the Korean word chain game
by H Park
Wolfram Community, STAFF PICKS, July 13, 2023
https://community.wolfram.com/groups/-/m/t/2963006
by H Park
Wolfram Community, STAFF PICKS, July 13, 2023
https://community.wolfram.com/groups/-/m/t/2963006