demola / urbandictionary
A package that helps in managing urban words (slang)
Requires
- php: >=5.5.9
- satooshi/php-coveralls: ^1.0
Requires (Dev)
- phpunit/phpunit: ^4.8.22
This package is not auto-updated.
Last update: 2025-01-24 20:20:36 UTC
README
The Urban dictionary is the collation of urban words. It is a package that stores meaning and usage of words in a multi associative array. The package allows for addition, editing, updating and retrieving of words in the dictionary.
Design
Classes
-
UrbanWords: Contains an array where urban words are stored.
-
DictionaryEngine: Contain methods that add new word, retrieve the whole dictionary, retrieve word, update existing word, and delete word in the urban dictionary.
-
RankWord: Contain methods that rank words based on the number of times they occurred in the sentence.
Installation
To install this package, PHP 5.5+ and composer are required. After these requirements have been met, type the following code
$ composer require demola/urbandictionary
Usage
The dictionary contains urban words with their meaning and usage
-
Create a dictionaryManager instance
$dictionaryManager = new DictionaryEngine();
-
Add urban words to the dictionary
$dictionaryManager->add('word', 'description', 'sampleSentence'); // This returns true
-
Retrieve a word from the dictionary
$data = $dictionaryManager->retrieve('word');
-
Retrieve the whole dictionary
$data = $dictionaryManager->retrieveAll();
-
Update a word, its meaning and its sample sentence
$data = $dictionaryManager->update('word', newDescription', 'newSampleSentence');
-
Delete a word in the urban dictionary
$dictionaryManager->delete('word'); // This returns true
-
Rank words in a sentence
-
create a wordOccurence instance
$wordOccurence = new RankWord; $ranking = $wordOccurence->rankWord($word));
-
Testing
Run the following command in the urban-dictionary directory:
~ phpunit
Change log
Please check out CHANGELOG file for information on what has changed recently.
Contributing
Please check out CONTRIBUTING file for detailed contribution guidelines.
Security
If you discover any issue, kindly contact ademola.raimi@andela.com
Credits
Urban Dictionary is maintained by Raimi Ademola.
License
UrbanDictionary is released under the MIT Licence. See the bundled LICENSE file for more details.