PHP Classes
elePHPant
Icontem

WordStore: Add, update and find words from a dictionary

Recommend this page to a friend!
  Info   View files Documentation   View files View files (9)   DownloadInstall with Composer Download .zip   Reputation   Support forum (3)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2016-12-29 (1 month ago) RSS 2.0 feedNot enough user ratingsTotal: 163 This week: 1All time: 8,153 This week: 804Up
Version License PHP version Categories
wordstore 1.1.1MIT/X Consortium ...5PHP 5, Files and Folders, Text proces...
Description Author

This class implements a dictionary that can be stored in a JSON file using pure PHP.

It can add, update or find not only the correct spelling of words but also the types of each word: nouns, verbs, prepositions, adjectives, articles, personal pronouns, adverbs, interjections, and punctuation.

The dictionary is stored in a JSON file.

Innovation Award
PHP Programming Innovation award nominee
May 2016
Number 11


Prize: One downloadable copy of CodeLobster Professional
Dictionaries are useful to verify the spelling of words used in text sentences.

This class implements a dictionary that can be stored using pure PHP in a JSON file.

It includes not only the correct spelling of words but also the types of each word: nouns, verbs, prepositions, adjectives, articles, personal pronouns, adverbs, interjections, and punctuation.

This way it the dictionary can also be used not only to verify the spelling but also the grammar of text sentences.

Manuel Lemos
  Performance   Level  
Name: Gavin Gordon Markowski <contact>
Classes: 10 packages by
Country: Canada Canada
Innovation award
Innovation award
Nominee: 4x

Details

WordStore v1.1.1

Build Status

Synopsis

This class (GGG\WordStore) allows one to create a language dictionary, by adding words and their translations, both of which can be searched for and retrieved after adding, in addition to custom parameters.

How to use 'WordStore'

Install via Composer...

	composer require gavinggordon/wordstore

Include autoload.php...

	include_once( __DIR__ . '/vendor/autoload.php' );

Create new instance...

	//
	// new WordStore( 
	// 
	// @var string $dictionary_file optional 
	// default value = 'dictionary.json'
	//  
	// );
	//
	// returns $self;
	// 
	
	$json_dictionary_file = __DIR__ . '/myDictionary.json';
	// optionally, override the default name to be used for the .json
	// dictionary file, where all the related word data will be stored
	
	$wordstore = new GGG\WordStore( $json_dictionary_file );
	// creates dictionary file, if it doesn't already exist

Adding a word...

	//
	// WordStore->add(
	//
	//	@var string $part_of_speech required
	// possible values =	
	// 'adjective' || 'adverb' || 'article' || 'interjection' ||
	// 'noun' || 'pronoun' || 'personalpronoun' || 
	// 'preposition' || 'punctuation' || 'verb'
	//
	//	@var string $word required
	//	possible values = *
	//
	//	@var array $params required
	//	possible values = *
	//
	// );
	//
	// returns $self;
	//
	
	$wordstore->add( 'noun', 'friend', ['translation'=>'vu&#269;a','gender'=>'conditional'] );

Finding a word...

	//
	// WordStore->find(
	//
	//	@var string $value required
	//	possible values = *
	//
	//	@var string $part_of_speech optional
	// default value = NULL
	// possible values =	
	// 'adjective' || 'adverb' || 'article' || 'interjection' ||
	// 'noun' || 'pronoun' || 'personalpronoun' || 
	// 'preposition' || 'punctuation' || 'verb'
	//
	//	@var string $param optional
	// default value = 'word'
	//	possible values = *
	//
	// );
	//
	// returns $found Array || FALSE;
	//
	
	$word = $wordstore->find( 'friend' );
	print_r( $word );
	 
	//
	// Array
	// (
	//	  [0] => stdClass Object
	//	       (
	//              [word] => friend
	//              [translation] => vu&#269;a
	//              [gender] => conditional
	//        )
	// );
	//

Updating a word...

	//
	// WordStore->update(
	//
	//	@var string $newvalue required
	//	possible values = *
	//
	//	@var string $oldvalue required
	//	possible values = *
	//
	//	@var string $part_of_speech optional
	// default value = NULL
	// possible values = 
	// 'adjective' || 'adverb' || 'article' || 'interjection' ||
	// 'noun' || 'pronoun' || 'personalpronoun' || 
	// 'preposition' || 'punctuation' || 'verb'
	//
	//	@var string $param optional
	// default value = 'word'
	//	possible values = *
	//
	// );
	//
	// returns $self;
	//
	
	$wordstore->update( 'buddy', 'friend' );
	$word = $wordstore->find( 'buddy' );
	 
	//
	// Array
	// (
	//	  [0] => stdClass Object
	//	       (
	//              [word] => buddy
	//              [translation] => vu&#269;a
	//              [gender] => conditional
	//        )
	// );
	//
  Files folder image Files  
File Role Description
Files folder imagesrc (1 file)
Files folder imagetests (1 file)
Plain text file .scrutinizer.yml Data scrutinizer
Plain text file .travis.yml Data travis.ci
Plain text file composer.json Data composer file
Plain text file LICENSE.txt Doc. Documentation
Plain text file phpunit.xml Data phpunit
Plain text file READ-ME.md Doc. Info about using WordStore
Plain text file README.md Doc. info and examples

  Files folder image Files  /  src  
File Role Description
  Plain text file WordStore.php Class main class file

  Files folder image Files  /  tests  
File Role Description
  Plain text file WordStoreTest.php Test phpunit test file

 Version Control Unique User Downloads Download Rankings  
 88%
Total:163
This week:1
All time:8,153
This week:804Up