php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #60314 Metaphone returns fewer phonemes than defined
Submitted: 2011-11-16 20:52 UTC Modified: 2020-11-03 22:50 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: gravisoft at gmail dot com Assigned: cmb (profile)
Status: Closed Package: Strings related
PHP Version: 5.3.8 OS: Windows XP SP3
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gravisoft at gmail dot com
New email:
PHP Version: OS:

 

 [2011-11-16 20:52 UTC] gravisoft at gmail dot com
Description:
------------
Under certain conditions, the metaphone function returns fewer phonemes than the $phonemes parameter specifies.  This is an edge-case occurrence when dealing with an X near the end of the specified phoneme count.

For the test script, the following phoneme transformations take place:
A -> A
X -> KS
C -> K

Test script:
---------------
<?php

var_dump('axccc', 2);  // Should produce AKS
var_dump('axccc', 3);  // Should produce AKSK as "X->KS" is one phoneme
var_dump('axccc', 0);  // Should produce AKSKKK

?>

Expected result:
----------------
string(3) "AKS"
string(4) "AKSK"
string(6) "AKSKKK"

Actual result:
--------------
string(3) "AKS"
string(3) "AKS"
string(6) "AKSKKK"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-11-17 21:58 UTC] felipe@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

It works following the Text-Metaphone CPAN package, it stop decoding when reach the limit of phonems, but when decoding the last char it can pass the limit suplied, because this metaphone('AX', 2) == metaphone('AXC', 3).
 [2011-11-17 21:58 UTC] felipe@php.net
-Status: Open +Status: Bogus -Package: Unknown/Other Function +Package: Strings related
 [2011-11-17 22:39 UTC] gravisoft at gmail dot com
This doesn't have anything to do with it "going over" the phoneme limit parameter, it's about it translating too few phonemes.

If you're defining (X -> KS) as one phoneme, then metpahone('axc', 3) == 'AKS' is incorrect because it only translated (A -> A) and (X -> KS) which is two phonemes.  Translating three phonemes - (A->A), (X->KS), (C->K) -  should have yielded 'AKSK'.

If you're defining each K and S from (X -> KS) as a phoneme, then metaphone('axc', 2) == 'AKS' is incorrect as per bug #60123 (going over restricted number of phoneme characters).  If that isn't a bug, then the documentation should be modified to note it as such.

Regardless, something is amiss here.
 [2011-11-17 23:13 UTC] felipe@php.net
Yes, in fact it isn't a phonemes limit nor an strict string limit. Because it doesn't does wrapping in this case when it yields more than 1 char in the end.

You're right, the documentation must be updated accordially. :)
 [2011-11-17 23:13 UTC] felipe@php.net
-Status: Bogus +Status: Open -Package: Strings related +Package: Documentation problem
 [2017-01-28 11:36 UTC] cmb@php.net
-Type: Bug +Type: Documentation Problem -Package: Documentation problem +Package: Strings related
 [2020-11-03 22:50 UTC] cmb@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: cmb
 [2020-11-04 10:10 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=ef05457faa8045529ef7d0ec97309667838feb44
Log: Fix #60314: Metaphone returns fewer phonemes than defined
 [2020-11-04 10:10 UTC] phpdocbot@php.net
-Status: Verified +Status: Closed
 [2020-11-04 17:50 UTC] phpdocbot@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=4a27129567d5ab04daf7418fdd263c68d989b248
Log: Fix #60314: Metaphone returns fewer phonemes than defined
 [2020-12-30 11:58 UTC] nikic@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=35635e2b3e2f58fabe4243888a0f4f83fa84c6d6
Log: Fix #60314: Metaphone returns fewer phonemes than defined
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC