Hiong3-eng5 has uploaded a new change for review. https://gerrit.wikimedia.org/r/67582
Change subject: API: Corrections on SynonymTranslation Class ...................................................................... API: Corrections on SynonymTranslation Class - removed non required php on required_once - outputs - added preparatory param part - merge unless there are corrections. Thanks. Change-Id: I0c2b431c093e852b91e1542109d23244655369be --- M includes/api/owSyntrans.php 1 file changed, 31 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikiLexicalData refs/changes/82/67582/1 diff --git a/includes/api/owSyntrans.php b/includes/api/owSyntrans.php index 93a5950..de5ab30 100644 --- a/includes/api/owSyntrans.php +++ b/includes/api/owSyntrans.php @@ -3,23 +3,25 @@ /** O m e g a W i k i A P I ' s S y n t r a n s c l a s s * * PARAMETERS - * @param req'd int dm + * @param req'd int dm 'the defined meaning id' * * HISTORY * - 2013-06-04: Add basic structure - * @param req'd int dm + * @param req'd int dm 'the defined meaning id' * - 2013-06-04: Creation date ~he * * TODO * - Integrate with Define Class * - Transfer getSynonymAndTranslation function to WikiDataAPI when ready. + * - Add parameter + * @param opt'l str part + * 'return only synonyms or translations (syn or trans)' * * QUESTION * - none */ require_once( 'extensions/WikiLexicalData/OmegaWiki/WikiDataAPI.php' ); -require_once( 'extensions/WikiLexicalData/OmegaWiki/OmegaWikiRecordSets.php' ); class SynonymTranslation extends ApiBase { @@ -49,8 +51,27 @@ } // Optional parameter + $part = 'all'; + if ( isset( $params['part'] ) ) { + $part = $params['part']; + } + + // error if $params['part'] is empty + if ( $part == '' ) { + $this->dieUsage( 'parameter dm for adding syntrans is empty', 'param dm is empty' ); + } // get syntrans + // When returning synonyms only + if ( $part == 'syn') { + return; + } + + // When returning translations only + if ( $part == 'trans') { + return; + } + // When only dm is given $syntrans = $this->synTrans( $syntrans['dm'] ); @@ -65,7 +86,7 @@ // Description public function getDescription() { - return 'Get the definition of a defined meaning.' ; + return 'Get a list of synonyms and translations from of a defined meaning.' ; } // Parameters. @@ -75,13 +96,17 @@ ApiBase::PARAM_TYPE => 'integer', ApiBase::PARAM_REQUIRED => true ), + 'part' => array ( + ApiBase::PARAM_TYPE => 'string', + ), ); } // Describe the parameter public function getParamDescription() { return array( - 'dm' => 'The defined meaning id to be defined', + 'dm' => 'The defined meaning id to be used to get synonyms and translations', + 'part' => 'set whether output are synonyms or translations. requires param langid', ); } @@ -99,7 +124,7 @@ * Returns an array of syntrans via defined meaning id * Returns null if empty */ - private function synTrans ( $definedMeaningId ) { + function synTrans ( $definedMeaningId, $options = array() ) { $stList = getSynonymAndTranslation( $definedMeaningId ); $ctr = 1; -- To view, visit https://gerrit.wikimedia.org/r/67582 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0c2b431c093e852b91e1542109d23244655369be Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikiLexicalData Gerrit-Branch: master Gerrit-Owner: Hiong3-eng5 <hiong3.e...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits