Coder Social home page Coder Social logo

phonetic-algorithms's Introduction

Build Status Coverage Status Latest Stable Version Total Downloads Latest Unstable Version License

Phonetic-Algorithms

Description

  • "PhoneticGerman"-Class:

A phonetic algorithms for the german language via "Kölner Phonetik": en.wikipedia.org/wiki/Cologne_phonetics

  • "PhoneticEnglish"-Class:

A phonetic algorithms for the english language via "metaphone": en.wikipedia.org/wiki/Metaphone

  • "PhoneticFrench"-Class:

A phonetic algorithms for the french language via "SOUNDEX FR": www.roudoudou.com/phonetic.php

Installation

  1. Install and use composer in your project.
  2. Require this package via composer:
composer require voku/phonetic-algorithms

Usage

You the "phonetic_word"-method if you need a fuzzy-search for single words e.g. last-names or product-names.

use voku\helper\Phonetic;

$words = array(
  'Moelleken',
  'Mölleken',
  'Möleken',
  'Moeleken',
  'Moellecken',
  'Möllecken',
  'Mölecken',
);
$phonetic = new Phonetic('de');
foreach ($words as $word) {
  $phonetic->phonetic_word($string); // '6546'
}

You can use the "phonetic_sentence"-method to process sentences.

use voku\helper\Phonetic;

$string = 'Ein Satz mit vielen Wortern';
$phonetic = new Phonetic('de');
$phonetic->phonetic_sentence($string, (bool) false, (false|int) false); 

// [
//   'Ein' => '06', 
//   'Satz' => '8', 
//   'mit' => '62', 
//   'vielen' => '356', 
//   'Wortern' => '37276'
// ]

You can use the "phonetic_matches"-method to search for words in an array of words.

use voku\helper\Phonetic;

$phonetic = new Phonetic('de');

$tests = array(
    'Moelleken',  // '6546',
    'Mölleken',   // '6546',
    'Möleken',    // '6546',
    'Moeleken',   // '6546',
    'oder',       // '027',
    'was',        // '38',
    'Moellecken', // '6546',
    'Möllecken',  // '6546',
    'Mölecken',   // '6546',
);

$phonetic->phonetic_matches('Moelleken', $tests);
    
// [
//   'Moelleken'  => 'Moelleken',
//   'Mölleken'   => 'Moelleken',
//   'Möleken'    => 'Moelleken',
//   'Moeleken'   => 'Moelleken',
//   'Moellecken' => 'Moelleken',
//   'Möllecken'  => 'Moelleken',
//   'Mölecken'   => 'Moelleken',
// ]

History

See CHANGELOG for the full history of changes.

phonetic-algorithms's People

Contributors

voku avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.