reference/strings/functions/metaphone.xml
e095023e408c8cb6378ae16bb6870343a3946919
...
...
@@ -1,6 +1,6 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.metaphone">
3
+
<refentry xml:id="function.metaphone" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
5
5
<refname>metaphone</refname>
6
6
<refpurpose>Calculate the metaphone key of a string</refpurpose>
...
...
@@ -10,11 +10,11 @@
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
12
<type>string</type><methodname>metaphone</methodname>
13
-
<methodparam><type>string</type><parameter>str</parameter></methodparam>
14
-
<methodparam choice="opt"><type>int</type><parameter>phonemes</parameter><initializer>0</initializer></methodparam>
13
+
<methodparam><type>string</type><parameter>string</parameter></methodparam>
14
+
<methodparam choice="opt"><type>int</type><parameter>max_phonemes</parameter><initializer>0</initializer></methodparam>
15
15
</methodsynopsis>
16
16
<para>
17
-
Calculates the metaphone key of <parameter>str</parameter>.
17
+
Calculates the metaphone key of <parameter>string</parameter>.
18
18
</para>
19
19
<para>
20
20
Similar to <function>soundex</function> metaphone creates the same key for
...
...
@@ -24,7 +24,7 @@
24
24
</para>
25
25
<para>
26
26
Metaphone was developed by Lawrence Philips
27
-
&lt;lphilips at verity dot com>. It is described in ["Practical
27
+
&lt;lphilips at verity dot com&gt;. It is described in ["Practical
28
28
Algorithms for Programmers", Binstock &amp; Rex, Addison Wesley,
29
29
1995].
30
30
</para>
...
...
@@ -35,7 +35,7 @@
35
35
<para>
36
36
<variablelist>
37
37
<varlistentry>
38
-
<term><parameter>str</parameter></term>
38
+
<term><parameter>string</parameter></term>
39
39
<listitem>
40
40
<para>
41
41
The input string.
...
...
@@ -43,11 +43,13 @@
43
43
</listitem>
44
44
</varlistentry>
45
45
<varlistentry>
46
-
<term><parameter>phonemes</parameter></term>
46
+
<term><parameter>max_phonemes</parameter></term>
47
47
<listitem>
48
48
<para>
49
49
This parameter restricts the returned metaphone key to
50
-
<parameter>phonemes</parameter> characters in length.
50
+
<parameter>max_phonemes</parameter> <emphasis>characters</emphasis> in length.
51
+
However, the resulting phonemes are always transcribed completely, so the
52
+
resulting string length may be slightly longer than <parameter>max_phonemes</parameter>.
51
53
The default value of <literal>0</literal> means no restriction.
52
54
</para>
53
55
</listitem>
...
...
@@ -59,10 +61,32 @@
59
61
<refsect1 role="returnvalues">
60
62
&reftitle.returnvalues;
61
63
<para>
62
-
Returns the metaphone key as a string, &return.falseforfailure;.
64
+
Returns the metaphone key as a string.
63
65
</para>
64
66
</refsect1>
65
67

68
+
<refsect1 role="changelog">
69
+
&reftitle.changelog;
70
+
<informaltable>
71
+
<tgroup cols="2">
72
+
<thead>
73
+
<row>
74
+
<entry>&Version;</entry>
75
+
<entry>&Description;</entry>
76
+
</row>
77
+
</thead>
78
+
<tbody>
79
+
<row>
80
+
<entry>8.0.0</entry>
81
+
<entry>
82
+
The function returned &false; on failure.
83
+
</entry>
84
+
</row>
85
+
</tbody>
86
+
</tgroup>
87
+
</informaltable>
88
+
</refsect1>
89
+

66
90
<refsect1 role="examples"><!-- {{{ -->
67
91
&reftitle.examples;
68
92
<para>
...
...
@@ -76,7 +100,7 @@ var_dump(metaphone('programmer'));
76
100
?>
77
101
]]>
78
102
</programlisting>
79
-
&example.outputs.similar;
103
+
&example.outputs;
80
104
<screen>
81
105
<![CDATA[
82
106
string(7) "PRKRMNK"
...
...
@@ -87,7 +111,7 @@ string(6) "PRKRMR"
87
111
</para>
88
112
<para>
89
113
<example xml:id="metaphone.example.phonemes"><!-- {{{ -->
90
-
<title>Using the <parameter>phonemes</parameter> parameter</title>
114
+
<title>Using the <parameter>max_phonemes</parameter> parameter</title>
91
115
<programlisting role="php">
92
116
<![CDATA[
93
117
<?php
...
...
@@ -96,7 +120,7 @@ var_dump(metaphone('programmer', 5));
96
120
?>
97
121
]]>
98
122
</programlisting>
99
-
&example.outputs.similar;
123
+
&example.outputs;
100
124
<screen>
101
125
<![CDATA[
102
126
string(5) "PRKRM"
...
...
@@ -105,10 +129,33 @@ string(5) "PRKRM"
105
129
</screen>
106
130
</example><!-- }}} -->
107
131
</para>
132
+
<para>
133
+
<example xml:id="metaphone.example.phonemes-overlong">
134
+
<title>Using the <parameter>max_phonemes</parameter> parameter</title>
135
+
<simpara>
136
+
In this example, <function>metaphone</function> is advised to produce a string
137
+
of five characters, but that would require to split the final phoneme
138
+
(<literal>'x'</literal> is supposed to be transcribed to <literal>'KS'</literal>),
139
+
so the function returns a string with six characters.
140
+
</simpara>
141
+
<programlisting role="php">
142
+
<![CDATA[
143
+
<?php
144
+
var_dump(metaphone('Asterix', 5));
145
+
?>
146
+
]]>
147
+
</programlisting>
148
+
&example.outputs;
149
+
<screen>
150
+
<![CDATA[
151
+
string(6) "ASTRKS"
152
+
]]>
153
+
</screen>
154
+
</example>
155
+
</para>
108
156
</refsect1><!-- }}} -->
109
157

110
158
</refentry>
111
-

112
159
<!-- Keep this comment at the end of the file
113
160
Local variables:
114
161
mode: sgml
115
162