florence / dictionary
An urban dictionary agnostic of common slangs and their meanings
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^7.2
- phpunit/phpunit: 8.5
This package is auto-updated.
Last update: 2023-07-10 04:19:00 UTC
README
Checkpoint One
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)
Classes
-
Data: The main dictionary, a static associative array that contains urban words
-
Dictionary: CRUD implementations and Ranking System Implementation.
-
WordExistsException: Returns the associated exception message
-
WordNotFoundException: Returns the associated exception message
Installation
Require via composer like so:
composer require florence/dictionary
Usage
$dictionary = Data::$data;
$dictionary = new Dictionary($dictionary);
Add Slang
$dictionary->addSlang($slang, $description, $sentence);
Retrieve Slang
$dictionary->findOne($slang);
$dictionary->findAll();
Update Slang
$dictionary->updateSlang($slang, $description, $sentence);
Delete Slang
$dictionary->deleteOne($slang);
$dictionary->deleteAll();
Implement Ranking
The ranking system is implemented using the rankWords()
method.
You can now traverse through the Data array to get your desired output like so:
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:
[“Tight” => 3, “Prosper” => 2, “Yes” => 1, “Have” => 1, “you” => 1, “finished” => 1, “the” => 1, “curriculum?” => 1]