php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #29552 Callback function for levenshtein
Submitted: 2004-08-06 18:09 UTC Modified: 2014-12-30 10:41 UTC
Votes:2
Avg. Score:2.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: philip at cornado dot com Assigned:
Status: No Feedback Package: Strings related
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
50 - 20 = ?
Subscribe to this entry?

 
 [2004-08-06 18:09 UTC] philip at cornado dot com
Description:
------------
The levenshtein() documentation goes into great detail on a third yet to be implemented parameter for a levenshtein callback function.  Below are those docs which will soon be removed from the php manual until this feature is actually implemented:



The third variant (which is not implemented yet) will be the most general and adaptive, but also the slowest alternative. It will call a user-supplied function that will determine the cost for every possible operation.

The user-supplied function will be called with the following arguments:

    * operation to apply: 'I', 'R' or 'D'
    * actual character in string 1
    * actual character in string 2
    * position in string 1
    * position in string 2
    * remaining characters in string 1
    * remaining characters in string 2 

The user-supplied function has to return a positive integer describing the cost for this particular operation, but it may decide to use only some of the supplied arguments.

The user-supplied function approach offers the possibility to take into account the relevance of and/or difference between certain symbols (characters) or even the context those symbols appear in to determine the cost of insert, replace and delete operations, but at the cost of losing all optimizations done regarding cpu register utilization and cache misses that have been worked into the other two variants.


Attempting to use it gives us:

php_error_docref(NULL TSRMLS_CC, E_WARNING, "The general Levenshtein support is not there yet");

And a return value of -1.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-04-21 20:27 UTC] levim@php.net
-Summary: callback function for levenshtein +Summary: Callback function for levenshtein -Status: Open +Status: Feedback -Package: Feature/Change Request +Package: Strings related
 [2014-04-21 20:27 UTC] levim@php.net
Is this something you are still interested in seeing? A quick look at the docs indicates that it hasn't been added.
 [2014-12-30 10:41 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 11 17:01:27 2024 UTC