gavinggordon/wordstore

这是一个符合 CRUD 标准的语言数据存储类。

2.0.6 2016-08-09 16:49 UTC

This package is not auto-updated.

Last update: 2024-09-26 00:24:47 UTC


README

Build Status

摘要

这个 PHP 类 ( GGG\WordStore ) 是一个符合 CRUD 标准的语言数据存储类。它提供了创建语言词典的能力。您创建的所有条目都存储在 WordStore 中,可以包含用户自定义的参数,所有这些都可以:搜索和检索;更新;以及,删除。

如何使用 'WordStore'

通过 Composer 安装...

	composer require gavinggordon/wordstore

包含 autoload.php...

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

创建新的实例...

	//
	// new WordStore( 
	// 
	// @param string $dictionary_file *optional* 
	// default value = 'dictionary.json'
	//  
	// );
	//
	// @return object
	// 
	
	$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 the dictionary storage file, if it doesn't already exist

添加单词...

	//
	// WordStore->add(
	//
	//	@param string $part_of_speech *required*
	// possible values =	
	// 'adjective' || 'adverb' || 'article' || 'interjection' ||
	// 'noun' || 'pronoun' || 'personalpronoun' || 
	// 'preposition' || 'punctuation' || 'verb'
	//
	//	@param string $word *required*
	//	possible values = *
	//
	//	@param array $params *required*
	//	possible values = *
	//
	// );
	//
	// @return object | FALSE
	//
	
	$wordstore->add( 'noun', 'vuča', [ 
		'translation' => 'friend',
		'pronounciation' => 'voo-cha' 
	] );

查找单词...

	//
	// WordStore->find(
	//
	//	@param string $value *required*
	//	possible values = *
	//
	//	@param string $part_of_speech *optional*
	// default value = NULL
	// possible values =	
	// 'adjective' || 'adverb' || 'article' || 'interjection' ||
	// 'noun' || 'pronoun' || 'personalpronoun' || 
	// 'preposition' || 'punctuation' || 'verb'
	//
	//	@param string $param *optional*
	// default value = NULL
	//	possible values = *
	//
	// );
	//
	// @return array | FALSE;
	//
	
	$word = $wordstore->find( 'vuča' );
	print_r( $word );
	 
	//
	// Array
	// (
	// 		[translation] => friend
	//		[pronounciation] => voo-cha
	// );
	//

更新单词...

	//
	// WordStore->update(
	//
	//	@param string $newvalue *required*
	//	possible values = *
	//
	//	@param string $oldvalue *required*
	//	possible values = *
	//
	//	@param string $part_of_speech *optional*
	// default value = NULL
	// possible values = 
	// 'adjective' || 'adverb' || 'article' || 'interjection' ||
	// 'noun' || 'pronoun' || 'personalpronoun' || 
	// 'preposition' || 'punctuation' || 'verb'
	//
	//	@param string $param *optional*
	// default value = NULL
	//	possible values = *
	//
	// );
	//
	// @return object | FALSE
	//
	
	$wordstore->update( 'partner', 'vuča', 'noun', 'translation' );
	$word = $wordstore->find( 'buddy' );
	 
	//
	// Array
	// (
	//	  [0] => stdClass Object
	//	       (
	//              [translation] => partner
	//              [pronounciation] => voo-cha
	//        )
	// );
	//

删除单词...

	//
	// WordStore->delete(
	//
	//	@param string $newvalue *required*
	//	possible values = *
	//
	//	@param string $part_of_speech *optional*
	// default value = NULL
	// possible values = 
	// 'adjective' || 'adverb' || 'article' || 'interjection' ||
	// 'noun' || 'pronoun' || 'personalpronoun' || 
	// 'preposition' || 'punctuation' || 'verb'
	//
	// );
	//
	// @return object | FALSE
	//
	
	$wordstore->delete( 'vuča', 'noun' );
	$word = $wordstore->find( 'vuča' );
	 
	//
	// FALSE
	//

更多信息

PHP 创新奖

这个 被提名为 PHP 创新奖,由 PHPClasses.org 提供。如果您认为 这个类 在任何方面都有趣、有用、特别有用或具有创新性,请 投票 支持,以表达对 这个 或任何其他通过我的 GitHub 个人资料PHPClasses.org 个人资料 可以访问的在线 PHP 类的支持。