dev-master
9999999-devAn urban dictionary agnostic of common slangs and their meanings
MIT
The Requires
- php >=5.6.4
- phpunit/phpunit ~5.0
by andela-fokosun
An urban dictionary agnostic of common slangs and their meanings
This package was built mainly for academic purposes. It can be described ad an agnostic package that conforms with thephpleague.com specifications and uses the Test Driven Development process (PHPUnit), (*2)
Data: The main dictionary, a static associative array that contains urban words, (*3)
Dictionary: CRUD implementations and Ranking System Implementation., (*4)
WordExistsException: Returns the associated exception message, (*5)
WordNotFoundException: Returns the associated exception message, (*6)
Require via composer like so:, (*7)
composer require florence/dictionary
$dictionary = Data::$data; $dictionary = new Dictionary($dictionary);
$dictionary->addSlang($slang, $description, $sentence);
$dictionary->findOne($slang); $dictionary->findAll();
$dictionary->updateSlang($slang, $description, $sentence);
$dictionary->deleteOne($slang); $dictionary->deleteAll();
The ranking system is implemented using the rankWords()
method., (*8)
You can now traverse through the Data array to get your desired output like so:, (*9)
foreach(Data::$data as $row => $innerArray) { $res = $innerArray['Sample-sentence']; $getRank = $ranker->rankAndSort($res); $output = ''; foreach($getRank as $key => $value) { $output .= "$key => $value".', '; } $output = rtrim("[".$output,','."]")."<br>"; // print the final output echo $output; echo "<br>"; }
Sample Output:, (*10)
[âTightâ => 3, âProsperâ => 2, âYesâ => 1, âHaveâ => 1, âyouâ => 1, âfinishedâ => 1, âtheâ => 1, âcurriculum?â => 1]
An urban dictionary agnostic of common slangs and their meanings
MIT