phonetic function in the Factory

The phonetic function returns the phonetic encoding of the strings contained in the column using the Metaphone algorithm. Phonetic may return the primary Metaphone component (component = "Primary" or component = "P") or the secondary component (component = "Secondary" or component = "S"). By default the primary component is returned.


Parameters

phonetic(column, component)

If you are using continuous attributes, check the Flow Execution Parameters.

Parameter

Description

column

The nominal attribute used to evaluate the phonetic encoding. If it is not nominal, it will be casted to nominal upon function’s computation. The column parameter is mandatory.

component

If Primary, P or not specified, the function returns the primary component. If Secondary or S, the secondary component is returned.

The Metaphone algorithm is a phonetic algorithm for indexing words by their English pronunciation. Its features are the as follows:

  1. Drop duplicate adjacent letters, except for C.

  2. If the word begins with 'KN', 'GN', 'PN', 'AE', 'WR', drop the first letter.

  3. Drop 'B' if after 'M' at the end of the word.

  4. 'C' transforms to 'X' if followed by 'IA' or 'H' (unless in latter case, it is part of '-SCH-', in which case it transforms to 'K'). 'C' transforms to 'S' if followed by 'I', 'E', or 'Y'. Otherwise, 'C' transforms to 'K'.

  5. 'D' transforms to 'J' if followed by 'GE', 'GY', or 'GI'. Otherwise, 'D' transforms to 'T'.

  6. Drop 'G' if followed by 'H' and 'H' is not at the end or before a vowel. Drop 'G' if followed by 'N' or 'NED' and is at the end.

  7. 'G' transforms to 'J' if before 'I', 'E', or 'Y', and it is not in 'GG'. Otherwise, 'G' transforms to 'K'.

  8. Drop 'H' if after vowel and not before a vowel.

  9. 'CK' transforms to 'K'.

  10. 'PH' transforms to 'F'.

  11. 'Q' transforms to 'K'.

  12. 'S' transforms to 'X' if followed by 'H', 'IO', or 'IA'.

  13. 'T' transforms to 'X' if followed by 'IA' or 'IO'. 'TH' transforms to '0'. Drop 'T' if followed by 'CH'.

  14. 'V' transforms to 'F'.

  15. 'WH' transforms to 'W' if at the beginning. Drop 'W' if not followed by a vowel.

  16. 'X' transforms to 'S' if at the beginning. Otherwise, 'X' transforms to 'KS'.

  17. Drop 'Y' if not followed by a vowel.

  18. 'Z' transforms to 'S'.

  19. Drop all vowels unless it is the beginning.


Example

The following example uses the Students_performance dataset.

Description

Screenshot

In this example, we want to retrieve the pronunciation of the test preparation course attribute.

Add a new attribute, called phonetic, and type the following formula:

phonetic($"test preparation course")

and the attribute is filled with the primary component, as the component parameter hasn’t been specified.