demola/urbandictionary

A package that helps in managing urban words (slang)

dev-master / 1.0.x-dev 2016-04-02 10:52 UTC

This package is not auto-updated.

Last update: 2024-05-03 16:41:03 UTC


README

Coverage Status Scrutinizer Code Quality Build Status

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.