• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP metaphone函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中metaphone函数的典型用法代码示例。如果您正苦于以下问题:PHP metaphone函数的具体用法?PHP metaphone怎么用?PHP metaphone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了metaphone函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: compare

 function compare($debug = false)
 {
     $first = $this->str1;
     $second = $this->str2;
     $this->levenshtein = levenshtein($first, $second);
     $this->similarity['value'] = $sim = similar_text($first, $second, $perc);
     $this->similarity['percentage'] = $perc;
     if ($debug) {
         echo "{$first} | {$second}<br>";
         echo "leven: " . $this->levenshtein;
         echo '<br>similarity: ' . $sim . ', ' . $perc . '%<br><br>';
     }
     $soundex1 = soundex($first);
     $soundex2 = soundex($second);
     $this->soundex['levenshtein'] = levenshtein($soundex1, $soundex2);
     $this->soundex['similarity'] = $sim = similar_text($soundex1, $soundex2, $perc);
     $this->soundex['percentage'] = $perc;
     if ($debug) {
         echo "Soundex: " . $soundex1 . ", " . $soundex2 . "<BR>";
         echo 'levenshtein: ' . $this->soundex['levenshtein'] . '<br>';
         echo 'similarity: ' . $sim . ', ' . $perc . '%<br><br>';
     }
     $m1 = metaphone($first);
     $m2 = metaphone($second);
     $this->metaphone['levenshtein'] = levenshtein($m1, $m2);
     $this->metaphone['similarity'] = $sim = similar_text($m1, $m2, $perc);
     $this->metaphone['percentage'] = $perc;
     if ($debug) {
         echo "metaphone: " . $m1 . ", " . $m2 . "<br>";
         echo 'levenshtein: ' . $this->metaphone['levenshtein'] . '<br>';
         echo 'similarity: ' . $sim . ', ' . $perc . '%<br>';
         echo '<br>-------------------<br>';
     }
 }
开发者ID:superego546,项目名称:SMSGyan,代码行数:34,代码来源:class.CompareString.php


示例2: similarWord

 /**
  *
  * @param string $word
  * @param array $words
  * @return array
  */
 public static function similarWord($word, array $words)
 {
     $similarity = config('pages.similar.similarity');
     $metaSimilarity = 0;
     $minLevenshtein = 1000;
     $metaMinLevenshtein = 1000;
     $result = [];
     $metaResult = [];
     foreach ($words as $n) {
         $minLevenshtein = min($minLevenshtein, levenshtein($n, $word));
     }
     foreach ($words as $n => $k) {
         if (levenshtein($k, $word) <= $minLevenshtein) {
             if (similar_text($k, $word) >= $similarity) {
                 $result[$n] = $k;
             }
         }
     }
     foreach ($result as $n) {
         $metaMinLevenshtein = min($metaMinLevenshtein, levenshtein(metaphone($n), metaphone($word)));
     }
     foreach ($result as $n) {
         if (levenshtein($n, $word) == $metaMinLevenshtein) {
             $metaSimilarity = max($metaSimilarity, similar_text(metaphone($n), metaphone($word)));
         }
     }
     foreach ($result as $n => $k) {
         if (levenshtein(metaphone($k), metaphone($word)) <= $metaMinLevenshtein) {
             if (similar_text(metaphone($k), metaphone($word)) >= $metaSimilarity) {
                 $metaResult[$n] = $k;
             }
         }
     }
     return $metaResult;
 }
开发者ID:BlueCatTAT,项目名称:kodicms-laravel,代码行数:41,代码来源:Text.php


示例3: search_items

 function search_items()
 {
     $search_string = $this->input->post('keyword');
     $search_string = preg_replace('/[^a-zA-Z0-9_ %\\[\\]\\.\\(\\)%&-]/s', '', $search_string);
     $words = explode(" ", $search_string);
     $data = $this->browse_gallery_model->get_all_search_strings();
     $row = 0;
     $row_array = array();
     $ad_array = array();
     foreach ($data as $text) {
         $text_word = explode("~", $text['Title_Text']);
         $ad_id = $text['ad_id'];
         $count = 0;
         foreach ($text_word as $single) {
             foreach ($words as $keyword) {
                 if (soundex(strtoupper($keyword)) == soundex(strtoupper($single)) || metaphone(strtoupper($keyword)) == metaphone(strtoupper($single))) {
                     $count = $count + 1;
                 }
             }
         }
         if (intval($count) > 0) {
             array_push($row_array, $ad_id);
         }
     }
     if (!empty($row_array)) {
         $data['ads'] = $this->browse_gallery_model->get_gallery_ads_by_adid($row_array);
         $data['top'] = $this->browse_gallery_model->get_top_categories();
         $this->load->view('search_items_view', $data);
     } else {
         $data['ads'] = NULL;
         $data['top'] = $this->browse_gallery_model->get_top_categories();
         $this->load->view('search_items_view', $data);
     }
 }
开发者ID:maheshrathnayaka,项目名称:2014_Sep_13,代码行数:34,代码来源:browse_gallery.php


示例4: testStringPreparation

 public function testStringPreparation()
 {
     $string = new String();
     $testString = "This is my-book title. BY Jesse.";
     $actual = $string->prepare($testString);
     $expected = [metaphone('this'), metaphone('book'), metaphone('title'), metaphone('jesse')];
     $this->assertEquals($actual, $expected);
 }
开发者ID:jesseobrien,项目名称:reach,代码行数:8,代码来源:StringTest.php


示例5: compareMetaphone

function compareMetaphone($v1, $v2)
{
    $v1 = metaphone($v1);
    $v2 = metaphone($v2);
    similar_text($v1, $v2, $p);
    // return similarity percentage
    return $p;
}
开发者ID:bffmm1,项目名称:gmailcommunity,代码行数:8,代码来源:compare.php


示例6: strmp

function strmp($str)
{
    $arr = explode(' ', $str);
    foreach ($arr as $ind => $word) {
        $word = trim($word);
        $arr[$ind] = metaphone($word);
    }
    $str = implode(' ', $arr);
    return $str;
}
开发者ID:jftsang,项目名称:flashcards,代码行数:10,代码来源:strmp.php


示例7: testMultipleFind

 public function testMultipleFind()
 {
     $redis = m::mock('Illuminate\\Redis\\Database');
     $redis->shouldReceive('sinter')->times(2)->andReturn([1], []);
     $string = m::mock('Reach\\String');
     $string->shouldReceive('prepare')->times(2)->andReturn([metaphone('the'), metaphone('story')], [metaphone('the'), metaphone('story')]);
     $string->shouldReceive('stripPunctuation')->times(2)->andReturn('books', 'authors');
     $reach = new Reach($redis, $string);
     $expected = ['books' => [1], 'authors' => []];
     $this->assertEquals($reach->findIn(['books', 'authors'], 'the story'), $expected);
 }
开发者ID:jesseobrien,项目名称:reach,代码行数:11,代码来源:ReachTest.php


示例8: similar_phase

function similar_phase($a, $b)
{
    $a = metaphone($a);
    $b = metaphone($b);
    $na = strlen($a);
    $nb = strlen($b);
    $n = $nb;
    if ($na > $nb) {
        $n = $na;
    }
    return levenshtein($a, $b) * 100.0 / $n;
}
开发者ID:1upon0,项目名称:ui,代码行数:12,代码来源:lib_func.php


示例9: prepare

 /**
  * Prepare a string to have it's pieces inserted into the search index
  *
  * @param string $term
  * @return array
  */
 public function prepare($string)
 {
     $string = strtolower($this->stripPunctuation($string));
     $string = str_replace("-", " ", $string);
     $terms = explode(" ", $string);
     $prepared = [];
     foreach ($terms as &$t) {
         if (!$this->isStopWord($t) and strlen($t) >= 3) {
             $prepared[] = metaphone($t);
         }
     }
     return $prepared;
 }
开发者ID:jesseobrien,项目名称:reach,代码行数:19,代码来源:String.php


示例10: formatRecord

function formatRecord($person, $merge_with = array())
{
    $base_person = array('pidm' => '', 'wpid' => '', 'psu_id' => '', 'username' => '', 'email' => '', 'msc' => '', 'name_first' => '', 'name_first_formatted' => '', 'name_first_metaphone' => '', 'name_last' => '', 'name_last_formatted' => '', 'name_last_metaphone' => '', 'name_middle_formatted' => '', 'name_full' => '', 'phone_of' => '', 'phone_vm' => '', 'emp' => '0', 'stu' => '0', 'stu_account' => '0', 'dept' => '', 'title' => '', 'major' => '', 'has_idcard' => '0');
    $person['office_phone'] = PSU::stripPunct($person['office_phone']);
    $person['phone_number'] = PSU::stripPunct($person['phone_number']);
    if ($merge_with) {
        $merge_with = PSU::params($merge_with, $base_person);
        $person = PSU::params($person, $merge_with);
    } else {
        $person = PSU::params($person, $base_person);
    }
    //end else
    $final = array('pidm' => $person['pidm'], 'wpid' => $person['wp_id'], 'psu_id' => $person['psu_id'], 'username' => !strpos($person['username'], '@') ? trim($person['username']) : substr($person['username'], 0, strpos($person['username'], '@')), 'email' => !strpos($person['email'], '@') ? trim($person['email']) : substr($person['email'], 0, strpos($person['email'], '@')), 'msc' => $person['msc'] ? $person['msc'] : '', 'name_first' => PSU::stripPunct($person['first_name']), 'name_first_formatted' => $person['first_name'], 'name_first_metaphone' => metaphone(PSU::stripPunct($person['first_name'])), 'name_last' => PSU::stripPunct($person['last_name']), 'name_last_formatted' => $person['last_name'], 'name_last_metaphone' => metaphone(PSU::stripPunct($person['last_name'])), 'name_middle_formatted' => $person['middle_name'], 'name_full' => trim(preg_replace('/\\s\\s+/', ' ', $person['first_name'] . ' ' . substr($person['middle_name'], 0, 1) . ' ' . $person['last_name'] . ' ' . $person['spbpers_name_suffix'])), 'phone_of' => $person['office_phone'] ? '(603) ' . substr($person['office_phone'], 0, 3) . '-' . substr($person['office_phone'], 3) : FALSE, 'phone_vm' => $person['phone_number'] ? '(603) ' . substr($person['phone_number'], 0, 3) . '-' . substr($person['phone_number'], 3) : FALSE, 'emp' => $person['emp'] ? 1 : 0, 'stu' => $person['stu'] ? 1 : 0, 'stu_account' => $person['stu_account'] ? 1 : 0, 'dept' => $person['department'] ?: '', 'title' => $person['title'] ?: '', 'major' => $person['major'] ?: '', 'has_idcard' => $person['has_idcard']);
    return $final;
}
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:15,代码来源:phonebook.lib.php


示例11: customize

function customize()
{
    print metaphone("That's just wack");
    $fields = array();
    $fields["heading_1"] = COMP_NAME;
    $fields["heading_2"] = date("d/m/Y");
    $fields["heading_3"] = "Balance Sheet";
    $fields["heading_4"] = "Prepared by: " . USER_NAME;
    foreach ($fields as $var_name => $value) {
        ${$var_name} = $value;
    }
    db_conn("cubit");
    $OUTPUT = "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n\t\t<tr>\n\t\t\t<td align='left'><h3>{$heading_1}</h3></td>\n\t\t\t<td align='right'><h3>{$heading_2}</h3></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='left'><h3>{$heading_3}</h3></td>\n\t\t\t<td align='right'><h3>{$heading_4}</h3></td>\n\t\t</tr>\n\t</table>\n\t<table border=0 cellpadding='" . TMPL_tblCellPadding . "' cellspacing='" . TMPL_tblCellSpacing . "'>\n\t\t<tr>\n\t\t\t<th>";
    return $OUTPUT;
}
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:15,代码来源:bal-sheet.new.php


示例12: decode

 /**
  * Get web wervice polyline parameter being decoded
  * @param $rsp - string 
  * @param string $param - response key
  * @return string - JSON
  */
 protected function decode($rsp, $param = 'routes.overview_polyline.points')
 {
     $needle = metaphone($param);
     // get response
     $obj = json_decode($rsp, true);
     // flatten array into single level array using 'dot' notation
     $obj_dot = array_dot($obj);
     // create empty response
     $response = [];
     // iterate
     foreach ($obj_dot as $key => $val) {
         // Calculate the metaphone key and compare with needle
         $val = strcmp(metaphone($key, strlen($needle)), $needle) === 0 ? PolyUtil::decode($val) : $val;
         array_set($response, $key, $val);
     }
     return json_encode($response, JSON_PRETTY_PRINT);
 }
开发者ID:drickferreira,项目名称:rastreador,代码行数:23,代码来源:Directions.php


示例13: findPhonetically

 public function findPhonetically($productName)
 {
     $productNameMeta = metaphone($productName);
     $map = [];
     $max = SIMILAR_MIN_THRESHOLD;
     $productId = 0;
     $products = Product::scope()->with('default_tax_rate')->get();
     foreach ($products as $product) {
         if (!$product->product_key) {
             continue;
         }
         $map[$product->id] = $product;
         $similar = similar_text($productNameMeta, metaphone($product->product_key), $percent);
         if ($percent > $max) {
             $productId = $product->id;
             $max = $percent;
         }
     }
     return $productId && isset($map[$productId]) ? $map[$productId] : null;
 }
开发者ID:rafaelsisweb,项目名称:invoice-ninja,代码行数:20,代码来源:ProductRepository.php


示例14: getMetaphoneM

function getMetaphoneM($first, $second, $result)
{
    $arFirst = explode(" ", $first);
    $arSecond = explode(" ", $second);
    $m1 = $m2 = "";
    foreach ($arFirst as $val) {
        $m1 .= metaphone($val);
    }
    foreach ($arSecond as $val2) {
        $m2 .= metaphone($val2);
    }
    $metaphone['levenshtein'] = levenshtein($m1, $m2);
    $metaphone['similarity'] = similar_text($m1, $m2, $perc);
    $metaphone['percentage'] = $perc;
    if ($result['levenshtein'] > $metaphone['levenshtein'] && $result['percentage'] <= $metaphone['percentage']) {
        $result["levenshtein"] = $metaphone['levenshtein'];
        $result["percentage"] = $metaphone['percentage'];
        $result["match"] = $second;
    }
    return $result;
}
开发者ID:superego546,项目名称:SMSGyan,代码行数:21,代码来源:mobile_UAE.php


示例15: pleac_Soundex_Matching

function pleac_Soundex_Matching()
{
    #-----------------------------
    $code = soundex($string);
    #-----------------------------
    $phoned_words = metaphone("Schwern");
    #-----------------------------
    // substitution function for getpwent():
    // returns an array of user entries,
    // each entry contains the username and the full name
    function getpwent()
    {
        $pwents = array();
        $handle = fopen("passwd", "r");
        while (!feof($handle)) {
            $line = fgets($handle);
            if (preg_match("/^#/", $line)) {
                continue;
            }
            $cols = explode(":", $line);
            $pwents[$cols[0]] = $cols[4];
        }
        return $pwents;
    }
    print "Lookup user: ";
    $user = rtrim(fgets(STDIN));
    if (empty($user)) {
        exit;
    }
    $name_code = soundex($user);
    $pwents = getpwent();
    foreach ($pwents as $username => $fullname) {
        preg_match("/(\\w+)[^,]*\\b(\\w+)/", $fullname, $matches);
        list(, $firstname, $lastname) = $matches;
        if ($name_code == soundex($username) || $name_code == soundex($lastname) || $name_code == soundex($firstname)) {
            printf("%s: %s %s\n", $username, $firstname, $lastname);
        }
    }
    #-----------------------------
}
开发者ID:Halfnhav4,项目名称:pfff,代码行数:40,代码来源:Soundex_Matching.php


示例16: generate

 /**
  * Generates a string of environment information and
  * takes the hash of that value to use as the env
  * fingerprint.
  *
  * @return string
  */
 public static final function generate()
 {
     if (null !== self::$finHash) {
         return self::$finHash;
     }
     self::$finHash = '';
     self::$sigData = array();
     $serverVariables = array('server_software', 'server_name', 'server_addr', 'server_port', 'document_root');
     foreach ($_SERVER as $k => $v) {
         if (in_array(strtolower($k), $serverVariables)) {
             self::$sigData[] = $v;
         }
     }
     self::$sigData[] = phpversion();
     self::$sigData[] = get_current_user();
     self::$sigData[] = php_uname('s') . php_uname('n') . php_uname('m') . PHP_OS . PHP_SAPI . ICONV_IMPL . ICONV_VERSION;
     self::$sigData[] = sha1_file(__FILE__);
     self::$finHash = implode(self::$sigData);
     self::$finHash = sha1(str_ireplace(' ', '', self::$finHash) . strlen(self::$finHash) . metaphone(self::$finHash));
     self::$finHash = sha1(self::$finHash);
     return self::$finHash;
 }
开发者ID:Invision70,项目名称:php-bitpay-client,代码行数:29,代码来源:Fingerprint.php


示例17: get_matches

function get_matches($rq)
{
    global $magnatune;
    $tracks = @$magnatune[metaphone($rq->artist)][metaphone($rq->track)];
    if (!$tracks) {
        return array();
    }
    $ret = array();
    foreach ($tracks as $t) {
        $pi = new stdclass();
        $pi->artist = $t['artist'];
        $pi->track = $t['track'];
        $pi->album = $t['album'];
        $pi->source = "Magnatune.com";
        //      $pi->size   = 0;
        $pi->bitrate = 128;
        $pi->duration = (int) $t['duration'];
        $pi->url = $t['url'];
        $pi->score = (double) 1.0;
        $ret[] = $pi;
    }
    return $ret;
}
开发者ID:eandbsoftware,项目名称:playdar,代码行数:23,代码来源:magnatune-resolver.php


示例18: getPossibleMethodName

 /**
  * Tries to find the most similar name
  *
  * @param string $methodName
  * @return string|boolean
  */
 public function getPossibleMethodName($methodName)
 {
     $methodNameLower = strtolower($methodName);
     foreach ($this->methods as $name => $method) {
         if (metaphone($methodNameLower) == metaphone($name)) {
             return $method->getName();
         }
     }
     $extendsClassDefinition = $this->extendsClassDefinition;
     if ($extendsClassDefinition) {
         return $extendsClassDefinition->getPossibleMethodName($methodName);
     }
     return false;
 }
开发者ID:zhao5908,项目名称:zephir,代码行数:20,代码来源:ClassDefinition.php


示例19: pfind_interpret

function pfind_interpret($entries, $mode, &$waypoints, $path, $node_types)
{
    global $wpdb;
    $result = array();
    $result['error'] = 200;
    //start optimistically
    $result['error_str'] = 'no errors';
    $waypoints = array();
    if (clb_count($entries) <= 0) {
        $result['error'] = 400;
        $result['error_str'] = 'no locations received to parse';
        return $result;
    }
    //if only one entry we expect a a "to" separating origin and dest
    if (count($entries) == 1) {
        $entries = preg_split('/\\s+to\\s+/i', trim(reset($entries)), -1, PREG_SPLIT_NO_EMPTY);
    }
    if (clb_count($entries) == 1) {
        $result['error'] = 400;
        $result['error_str'] = 'only one location';
        return $result;
    }
    if (is_file($path)) {
        $path = dirname($path);
    }
    $path = clb_dir($path) . 'metaphones.txt';
    //like spelling city
    $index = FALSE;
    if (is_file($path)) {
        $data = file_get_contents($path);
        //, FILE_BINARY);
        $index = clb_blob_dec($data);
    }
    $pickone = array();
    foreach ($entries as $loc) {
        $loc = strtolower($loc);
        $sel = FALSE;
        $select = 'SELECT ' . RF_NODES_SELECT . ' FROM ' . RF_NODES_FROM . ' ';
        //'SELECT pnum, ptype, title, more, lat, lng FROM places ';
        $where = ' WHERE ';
        //the list of ptypes that will be used to limit the names search
        $ptypes = $node_types;
        //if more than one mode check if the user has added clarifying name to the name eg "oxford rail"
        if (count($ptypes) > 1) {
            foreach ($ptypes as $type) {
                if (clb_contains($loc, $type)) {
                    //allow the user to force a mode, by adding the code to the name
                    $ptypes = array($type);
                    //replace all other modes
                    $loc = trim(preg_replace('/\\s*\\b' . preg_quote($type) . '\\b\\s*/i', ' ', $loc));
                    //remove the signal from the name
                }
            }
        }
        //get rid of quotes and escapes
        $loc = trim(str_replace(array('\\', '"'), ' ', $loc));
        if (preg_match('/^\\s*(-?[\\.\\d]+)\\s*,\\s*(-?[\\.\\d]+)\\s*$/', $loc, $m)) {
            //waypoint given as lat/lng pair
            //limit search by node types
            if (clb_count($ptypes)) {
                $where .= ' ' . RF_NODES_TYPE . ' IN ' . clb_join($ptypes, TRUE) . ' AND ';
            }
            list($junk, $lat, $lng) = $m;
            for ($dist = 200; $dist <= 500; $dist += 100) {
                $sel = $wpdb->get_results($select . $where . within_rect($lat, $lng, $dist), ARRAY_A);
                $sel = clb_rekey($sel, RF_NODES_KEY);
                if (clb_count($sel) > 1) {
                    break;
                }
            }
            if (clb_count($sel) <= 0) {
                $result = array('error' => 602, 'error_str' => 'no tranpost node could be found near coordinates ' . $lat . ', ' . $lng);
                return $result;
            }
        } else {
            if (preg_match('/^node:\\s*(\\w+)\\s*$/', $loc, $m)) {
                //waypoint specified by pnum
                $sel = $wpdb->get_results($select . ' WHERE ' . RF_NODES_KEY . '=' . clb_escape($m[1]), ARRAY_A);
                $sel = clb_rekey($sel, RF_NODES_KEY);
            } else {
                if (in_array('rail', $ptypes) && preg_match('/^\\s*(\\w{3})\\s*$/', $loc, $m)) {
                    //rail station three letter code
                    $sel = $wpdb->get_results($select . ' WHERE ' . RF_NODES_TYPE . '="rail" AND (extref=' . clb_escape($m[1]) . ' OR ' . RF_NODES_NAME . '=' . clb_escape($m[1]) . ')', ARRAY_A);
                    $sel = clb_rekey($sel, RF_NODES_KEY);
                } else {
                    /*
                    	the primary key of the sound index structrue is the metaphone.  Inside that are ptypes using that saound.
                    	within each ptype there is a list of specific pnums using that sound in the name.
                    	on each first word, get all pnums for that sound and type, on subsequent words intesect with pnums
                    	so that we end up with pnums which have all sounds.
                    	$index[$sound][ptype][] => pnum
                    */
                    $sel = FALSE;
                    $name = pfind_unify_names($loc);
                    if (is_array($index)) {
                        $intersection = FALSE;
                        $words = preg_split('/\\W+/', $name, -1, PREG_SPLIT_NO_EMPTY);
                        foreach ($words as $w) {
                            if ($w == '&') {
                                $w = 'and';
//.........这里部分代码省略.........
开发者ID:davidkeen,项目名称:railservice,代码行数:101,代码来源:pfind_lib.php


示例20: weightedPhoneticSimilarity

 /**
  * Compares string1 with string2 using php's string phonetics functions.
  *  This function takes into account how the strings "sound" when they are
  *  pronounced, and it considers phrases with similar initial phonetics
  *  to be of greater similarity than those without similar initial phonetics
  *
  * Currently (2011-07-29) this function normalizes to the english
  *  pronunciation patterns of words; other patterns, like spanish, are
  *  not supported.
  *
  * This function is similar to phoneticSimilarity() except that it uses
  *  the weighted similarity functionality from weightedSimilarity() to
  *  correlate phrases with similar beginnings.
  *
  * Note that this function, like weightedSimilarity() defaults to  
  *  unidirectional mode, meaning that the order of the string arguments 
  *  matters. Keep in mind that a short string compared against a long 
  *  string can yield a 100% match, and will disregard the tail of the 
  *  longer string.
  *
  * @param string $string1
  *  The base string we are comparing against.
  * @param string $string2
  *  The test string that we wish to verify.
  * @param int $gradient
  *  See weightedSimilarity()
  * @return The percentage of phonetic correlation between the two strings.
  *  (ie: complete phonetic match = 100, complete phonetic mis-match = 0)
  * @author David Hazel
  **/
 public function weightedPhoneticSimilarity($string1, $string2, $gradient = 0)
 {
     // check for bidirection
     if (!empty($this->biDirectional)) {
         // set string1 to be the longest string of the two
         if (strlen($string1) < strlen($string2)) {
             $tmp = $string1;
             $string1 = $string2;
             $string2 = $tmp;
             unset($tmp);
         }
     }
     // generate the metaphone code for each string
     $metaphone1 = metaphone($string1);
     $metaphone2 = metaphone($string2);
     // calculate and return the normalized similarity between the codes
     return $this->weightedSimilarity($metaphone1, $metaphone2, $gradient);
 }
开发者ID:Vci,项目名称:Libs,代码行数:48,代码来源:Comparator.php



注:本文中的metaphone函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP metarefresh函数代码示例发布时间:2022-05-15
下一篇:
PHP metadata_exists函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap