Skip to content

Commit

Permalink
[+]: update "*_phonetic_sentence"-method
Browse files Browse the repository at this point in the history
... use the processed word as key, in the returned array result.
  • Loading branch information
voku committed Mar 27, 2017
1 parent 4bcbd76 commit 800af98
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 28 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

## [1.0.0] - 2017-03-24
## [1.0.0] - 2017-03-27
### Changed
- init

10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@ You can use the "*_phonetic_sentence"-method to process sentences.
use voku\helper\PhoneticAlgorithms;

$string = 'Ein Satz mit vielen Wortern';
PhoneticAlgorithms::german_phonetic_sentence($string); // array('06', '8', '62', '356', '37276')
PhoneticAlgorithms::german_phonetic_sentence($string);

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

## History
Expand Down
4 changes: 2 additions & 2 deletions src/voku/helper/PhoneticAlgorithms.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static function english_phonetic_sentence($sentence)
$code = self::english_phonetic_word($word);

if ($code !== '') {
$return[] = $code;
$return[$word] = $code;
}
}

Expand Down Expand Up @@ -64,7 +64,7 @@ public static function german_phonetic_sentence($sentence)
$code = self::german_phonetic_word($word);

if ($code !== '') {
$return[] = $code;
$return[$word] = $code;
}
}

Expand Down
29 changes: 17 additions & 12 deletions tests/EnglishPhoneticAlgorithmsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,24 @@ public function testEmptyWordReturnsEmptyIndex()
public function testEnglishPhoneticSentence()
{
$testArray = array(
'Müller Lüdenscheidt' => array('MLR', 'LTNSXTT'),
'Müller-Lüdenscheidt' => array('MLRLTNSXTT'),
'Müller Lüdenscheidt' => array('Müller' => 'MLR', 'Lüdenscheidt' => 'LTNSXTT'),
'Müller-Lüdenscheidt' => array('Müller-Lüdenscheidt' => 'MLRLTNSXTT'),
"\n \t" => array(),
"test \xc2\x88" => array('TST'),
'Sind wir Düssel dorf' => array('SNT', 'WR', 'TSL', 'TRF'),
'Sind wir Düssel dorf ?' => array('SNT', 'WR', 'TSL', 'TRF'),
'Sind wir Düssel dorf?' => array('SNT', 'WR', 'TSL', 'TRF'),
'Sind wir Düssel-dorf' => array('SNT', 'WR', 'TSLTRF'),
'Ã ¤' => array('A'),
'test' => array('TST'),
'text' => array('TKST'),
'Ein Satz mit vielen Wortern' => array('EN', 'STS', 'MT', 'FLN', 'WRTRN'),
'中 文 空 白' => array('SHNK', 'WN', 'KNK', 'B'),
"test \xc2\x88" => array('test' => 'TST'),
'Sind wir Düssel dorf' => array('Sind' => 'SNT', 'wir' => 'WR', 'Düssel' => 'TSL', 'dorf' => 'TRF'),
'Sind wir Düssel dorf ?' => array('Sind' => 'SNT', 'wir' => 'WR', 'Düssel' => 'TSL', 'dorf' => 'TRF'),
'Sind wir Düssel dorf?' => array('Sind' => 'SNT', 'wir' => 'WR', 'Düssel' => 'TSL', 'dorf' => 'TRF'),
'Sind wir Düssel-dorf' => array('Sind' => 'SNT', 'wir' => 'WR', 'Düssel-dorf' => 'TSLTRF'),
'Ã ¤' => array('Ã' => 'A'),
'test' => array('test' => 'TST'),
'text' => array('text' => 'TKST'),
'Ein Satz mit vielen Wortern' => array('Ein' => 'EN',
'Satz' => 'STS',
'mit' => 'MT',
'vielen' => 'FLN',
'Wortern' => 'WRTRN',
),
'中 文 空 白' => array('' => 'SHNK', '' => 'WN', '' => 'KNK', '' => 'B'),

);

Expand Down
29 changes: 17 additions & 12 deletions tests/GermanPhoneticAlgorithmsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,19 +390,24 @@ public function testEmptyWordReturnsEmptyIndex()
public function testGermanPhoneticSentence()
{
$testArray = array(
'Müller Lüdenscheidt' => array('657', '52682'),
'Müller-Lüdenscheidt' => array('65752682'),
'Müller Lüdenscheidt' => array('Müller' => '657', 'Lüdenscheidt' => '52682'),
'Müller-Lüdenscheidt' => array('Müller-Lüdenscheidt' => '65752682'),
"\n \t" => array(),
"test \xc2\x88" => array('282'),
'Sind wir Düssel dorf' => array('862', '37', '285', '273'),
'Sind wir Düssel dorf ?' => array('862', '37', '285', '273'),
'Sind wir Düssel dorf?' => array('862', '37', '285', '273'),
'Sind wir Düssel-dorf' => array('862', '37', '285273'),
'Ã ¤' => array('0'),
'test' => array('282'),
'text' => array('2482'),
'Ein Satz mit vielen Wortern' => array('06', '8', '62', '356', '37276'),
'中 文 空 白' => array('064', '06', '064', '0'),
"test \xc2\x88" => array('test' => '282'),
'Sind wir Düssel dorf' => array('Sind' => '862', 'wir' => '37', 'Düssel' => '285', 'dorf' => '273'),
'Sind wir Düssel dorf ?' => array('Sind' => '862', 'wir' => '37', 'Düssel' => '285', 'dorf' => '273'),
'Sind wir Düssel dorf?' => array('Sind' => '862', 'wir' => '37', 'Düssel' => '285', 'dorf' => '273'),
'Sind wir Düssel-dorf' => array('Sind' => '862', 'wir' => '37', 'Düssel-dorf' => '285273'),
'Ã ¤' => array('Ã' => '0'),
'test' => array('test' => '282'),
'text' => array('text' => '2482'),
'Ein Satz mit vielen Wortern' => array('Ein' => '06',
'Satz' => '8',
'mit' => '62',
'vielen' => '356',
'Wortern' => '37276',
),
'中 文 空 白' => array('' => '064', '' => '06', '' => '064', '' => '0'),

);

Expand Down

0 comments on commit 800af98

Please sign in to comment.