To explain whatmapsound()does, let’s devise some terminology, illus-
trated by thex→hexample earlier. We’ll callxthesource value, withh,s,
and so on being themapped values.
Here are the formal parameters:
- df: A data frame consisting of the pronunciation data of two fangyan
- fromcolandtocol: Names indfof the source and mapped columns
- sourceval: The source value to be mapped, such asxin the preceding
example
Here is the head of a typical two-fangyan data frame,canman8, that would
be used fordf:
> head(canman8)
Ch char Can Man Can cons Can sound Can tone Man cons Man sound Man tone
1 一 yat1 yi1 y at 1 y i 1
2 丁 ding1 ding1 d ing 1 d ing 1
3 七 chat1 qi1 ch at 1 q i 1
4 丈jeung6 zhang4 j eung 6 zh ang 4
5 上seung5 shang3 s eung 5 sh ang 3
6 下 ha5 xia4 h a5xia4
The function returns a list consisting of two components:
- counts: A vector of integers, indexed by the mapped values, showing the
counts of those values. The elements of the vector are named according
to the mapped values. - images: A list of character vectors. Again, the indices of the list are the
mapped values, and each vector consists of all the characters that corre-
spond to the given mapped value.
To make this concrete, let’s try it out:
> m2cx <- mapsound(canman8,"Man cons","Can cons","x")
> m2cx$counts
chfghjkkwnsy
152187124218121
We see thatxmaps toch15 times, tof2 times, and so on. Note that we
could have calledsort()tom2cx$countsto view the mapped images in order,
from most to least frequent.
The Mandarin-speaking learner of Cantonese can then see that if he
wishes to know the Cantonese pronunciation of a word whose Mandarin
romanized form begins withx, the Cantonese almost certainly begins with
hors. Little aids like this should help the learning process quite a bit.
To try to discern more patterns, the learner may wish to determine in
which charactersxmaps toch, for example. We know from the result of the
preceding example that there are six such characters. Which ones are they?
116 Chapter 5