Ladsgroup has uploaded a new change for review. https://gerrit.wikimedia.org/r/324728
Change subject: Lemmata to Lemmas ...................................................................... Lemmata to Lemmas Change-Id: Ifd5a552ebda233d6bfcd096595b25cfdaaaa8149 --- M src/Content/LexemeContent.php M src/DataModel/Lexeme.php M src/DataModel/Providers/LemmataProvider.php M src/DataModel/Serialization/LexemeDeserializer.php M src/DataModel/Serialization/LexemeSerializer.php M src/DataModel/Services/Diff/LexemeDiff.php M src/DataModel/Services/Diff/LexemeDiffer.php M src/DataModel/Services/Diff/LexemePatcher.php M src/Specials/SpecialNewLexeme.php M src/View/LexemeView.php M tests/phpunit/composer/DataModel/LexemeTest.php M tests/phpunit/composer/DataModel/Serialization/LexemeDeserializerTest.php 12 files changed, 74 insertions(+), 74 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseLexeme refs/changes/28/324728/1 diff --git a/src/Content/LexemeContent.php b/src/Content/LexemeContent.php index 43bf8e4..c3eaa79 100644 --- a/src/Content/LexemeContent.php +++ b/src/Content/LexemeContent.php @@ -74,8 +74,8 @@ public function isStub() { return !$this->isRedirect() && !$this->getEntity()->isEmpty() - && ( is_null( $this->getEntity()->getLemmata() ) - || !$this->getEntity()->getLemmata()->isEmpty() ) + && ( is_null( $this->getEntity()->getLemmas() ) + || !$this->getEntity()->getLemmas()->isEmpty() ) && $this->getEntity()->getStatements()->isEmpty(); } diff --git a/src/DataModel/Lexeme.php b/src/DataModel/Lexeme.php index f4f4a32..773dd85 100644 --- a/src/DataModel/Lexeme.php +++ b/src/DataModel/Lexeme.php @@ -12,13 +12,13 @@ use Wikibase\DataModel\Term\FingerprintProvider; use Wikibase\DataModel\Term\LabelsProvider; use Wikibase\DataModel\Term\TermList; -use Wikibase\Lexeme\DataModel\Providers\LemmataProvider; +use Wikibase\Lexeme\DataModel\Providers\LemmasProvider; /** * @license GPL-2.0+ */ class Lexeme implements EntityDocument, StatementListProvider, FingerprintProvider, - LabelsProvider, DescriptionsProvider, LemmataProvider { + LabelsProvider, DescriptionsProvider, LemmasProvider { const ENTITY_TYPE = 'lexeme'; @@ -40,21 +40,21 @@ /** * @var TermList|null */ - private $lemmata; + private $lemmas; /** * @param LexemeId|null $id - * @param TermList|null $lemmata + * @param TermList|null $lemmas * @param StatementList|null $statements */ public function __construct( LexemeId $id = null, - TermList $lemmata = null, + TermList $lemmas = null, StatementList $statements = null ) { // TODO: add lemma, language and lexical category $this->id = $id; - $this->lemmata = $lemmata; + $this->lemmas = $lemmas; $this->statements = $statements ?: new StatementList(); // TODO: Remove this once Wikibase can work without fingerprint $this->fingerprint = new Fingerprint(); @@ -135,8 +135,8 @@ */ public function isEmpty() { // TODO: should also check other attributes once implemented - return ( is_null( $this->lemmata ) - || $this->lemmata->isEmpty() ) + return ( is_null( $this->lemmas ) + || $this->lemmas->isEmpty() ) && $this->statements->isEmpty(); } @@ -157,11 +157,11 @@ return false; } - $sameLemmata = ( $this->lemmata === $target->getLemmata() || ( - $this->lemmata !== null - && $this->lemmata->equals( $target->getLemmata() ) ) + $sameLemmas = ( $this->lemmas === $target->getLemmas() || ( + $this->lemmas !== null + && $this->lemmas->equals( $target->getLemmas() ) ) ); - return $sameLemmata + return $sameLemmas && $this->statements->equals( $target->statements ); } @@ -185,15 +185,15 @@ /** * @return TermList */ - public function getLemmata() { - return $this->lemmata; + public function getLemmas() { + return $this->lemmas; } /** - * @param TermList $lemmata + * @param TermList $lemmas */ - public function setLemmata( TermList $lemmata ) { - $this->lemmata = $lemmata; + public function setLemmas( TermList $lemmas ) { + $this->lemmas = $lemmas; } } diff --git a/src/DataModel/Providers/LemmataProvider.php b/src/DataModel/Providers/LemmataProvider.php index df2b02e..f2a8bd1 100644 --- a/src/DataModel/Providers/LemmataProvider.php +++ b/src/DataModel/Providers/LemmataProvider.php @@ -5,19 +5,19 @@ use Wikibase\DataModel\Term\TermList; /** - * Common interface for classes that contain a TermList, representing lemmata. + * Common interface for classes that contain a TermList, representing lemmas. * This is guaranteed to return the original, mutable object by reference. * * @license GPL-2.0+ * @author Amir Sarabadani <ladsgr...@gmail.com> */ -interface LemmataProvider { +interface LemmasProvider { /** * This is guaranteed to return the original, mutable object by reference. * * @return TermList */ - public function getLemmata(); + public function getLemmas(); } diff --git a/src/DataModel/Serialization/LexemeDeserializer.php b/src/DataModel/Serialization/LexemeDeserializer.php index fdf9e23..82bd2ef 100644 --- a/src/DataModel/Serialization/LexemeDeserializer.php +++ b/src/DataModel/Serialization/LexemeDeserializer.php @@ -51,7 +51,7 @@ return new Lexeme( $this->deserializeId( $serialization ), - $this->deserializeLemmata( $serialization ), + $this->deserializeLemmas( $serialization ), $this->deserializeStatements( $serialization ) ); } @@ -87,9 +87,9 @@ * * @return TermList|null */ - private function deserializeLemmata( array $serialization ) { - if ( array_key_exists( 'lemmata', $serialization ) ) { - return $this->termListDeserializer->deserialize( $serialization['lemmata'] ); + private function deserializeLemmas( array $serialization ) { + if ( array_key_exists( 'lemmas', $serialization ) ) { + return $this->termListDeserializer->deserialize( $serialization['lemmas'] ); } return null; diff --git a/src/DataModel/Serialization/LexemeSerializer.php b/src/DataModel/Serialization/LexemeSerializer.php index f1cbed8..818d22d 100644 --- a/src/DataModel/Serialization/LexemeSerializer.php +++ b/src/DataModel/Serialization/LexemeSerializer.php @@ -80,9 +80,9 @@ $serialization['id'] = $id->getSerialization(); } - if ( $lexeme->getLemmata() !== null ) { - $serialization['lemmata'] = $this->termListSerializer->serialize( - $lexeme->getLemmata() + if ( $lexeme->getLemmas() !== null ) { + $serialization['lemmas'] = $this->termListSerializer->serialize( + $lexeme->getLemmas() ); } diff --git a/src/DataModel/Services/Diff/LexemeDiff.php b/src/DataModel/Services/Diff/LexemeDiff.php index 453ff19..492ad84 100644 --- a/src/DataModel/Services/Diff/LexemeDiff.php +++ b/src/DataModel/Services/Diff/LexemeDiff.php @@ -20,7 +20,7 @@ * @param DiffOp[] $operations */ public function __construct( array $operations = [] ) { - $this->fixSubstructureDiff( $operations, 'lemmata' ); + $this->fixSubstructureDiff( $operations, 'lemmas' ); $this->fixSubstructureDiff( $operations, 'claim' ); parent::__construct( $operations, true ); @@ -31,8 +31,8 @@ * * @return Diff */ - public function getLemmataDiff() { - return isset( $this['lemmata'] ) ? $this['lemmata'] : new Diff( [], true ); + public function getLemmasDiff() { + return isset( $this['lemmas'] ) ? $this['lemmas'] : new Diff( [], true ); } /** @@ -41,7 +41,7 @@ * @return bool */ public function isEmpty() { - return $this->getLemmataDiff()->isEmpty() + return $this->getLemmasDiff()->isEmpty() && $this->getClaimsDiff()->isEmpty(); } diff --git a/src/DataModel/Services/Diff/LexemeDiffer.php b/src/DataModel/Services/Diff/LexemeDiffer.php index f0fefda..52a7e51 100644 --- a/src/DataModel/Services/Diff/LexemeDiffer.php +++ b/src/DataModel/Services/Diff/LexemeDiffer.php @@ -87,10 +87,10 @@ */ private function toDiffArray( Lexeme $lexeme ) { $array = []; - $lemmata = $lexeme->getLemmata(); + $lemmas = $lexeme->getLemmas(); - if ( !is_null( $lemmata ) ) { - $array['lemmata'] = $lemmata->toTextArray(); + if ( !is_null( $lemmas ) ) { + $array['lemmas'] = $lemmas->toTextArray(); } return $array; diff --git a/src/DataModel/Services/Diff/LexemePatcher.php b/src/DataModel/Services/Diff/LexemePatcher.php index 63a9c96..866a706 100644 --- a/src/DataModel/Services/Diff/LexemePatcher.php +++ b/src/DataModel/Services/Diff/LexemePatcher.php @@ -53,10 +53,10 @@ /** @var Lexeme $entity */ /** @var LexemeDiff $patch */ - $lemmata = !is_null( $entity->getLemmata() ) ? $entity->getLemmata() : new TermList(); + $lemmas = !is_null( $entity->getLemmas() ) ? $entity->getLemmas() : new TermList(); $this->termListPatcher->patchTermList( - $lemmata, - $patch->getLemmataDiff() + $lemmas, + $patch->getLemmasDiff() ); /** @var Lexeme $entity */ diff --git a/src/Specials/SpecialNewLexeme.php b/src/Specials/SpecialNewLexeme.php index 876ecfc..13c8ae1 100644 --- a/src/Specials/SpecialNewLexeme.php +++ b/src/Specials/SpecialNewLexeme.php @@ -204,8 +204,8 @@ return $status; } - $lemmata = new TermList( [ new Term( $languageCode, $this->lemma ) ] ); - $entity->setLemmata( $lemmata ); + $lemmas = new TermList( [ new Term( $languageCode, $this->lemma ) ] ); + $entity->setLemmas( $lemmas ); return $status; } diff --git a/src/View/LexemeView.php b/src/View/LexemeView.php index e4570d9..f83c4fc 100644 --- a/src/View/LexemeView.php +++ b/src/View/LexemeView.php @@ -121,7 +121,7 @@ $this->getLocalizedMessage( 'parentheses', [ $id ] ) ); - $label = $this->getMainTerm( $entity->getLemmata() ); + $label = $this->getMainTerm( $entity->getLemmas() ); if ( $label !== null ) { $labelHtml = $this->htmlTermRenderer->renderTerm( $label ); $isEmpty = false; @@ -143,17 +143,17 @@ } /** - * @param TermList|null $lemmata + * @param TermList|null $lemmas * @return Term|null */ - private function getMainTerm( $lemmata ) { + private function getMainTerm( $lemmas ) { - if ( is_null( $lemmata ) || $lemmata->isEmpty() ) { + if ( is_null( $lemmas ) || $lemmas->isEmpty() ) { return null; } // Return the first term, until we build a proper UI - foreach ( $lemmata->getIterator() as $term ) { + foreach ( $lemmas->getIterator() as $term ) { return $term; } diff --git a/tests/phpunit/composer/DataModel/LexemeTest.php b/tests/phpunit/composer/DataModel/LexemeTest.php index 6b74f38..6b73360 100644 --- a/tests/phpunit/composer/DataModel/LexemeTest.php +++ b/tests/phpunit/composer/DataModel/LexemeTest.php @@ -28,12 +28,12 @@ $id = new LexemeId( 'L1' ); $statements = new StatementList(); $lemma = new Term( 'fa', 'Karaj' ); - $lemmata = new TermList( [ $lemma ] ); - $lexeme = new Lexeme( $id, $lemmata, $statements ); + $lemmas = new TermList( [ $lemma ] ); + $lexeme = new Lexeme( $id, $lemmas, $statements ); $this->assertSame( $id, $lexeme->getId() ); $this->assertSame( $statements, $lexeme->getStatements() ); - $this->assertSame( $lemmata, $lexeme->getLemmata() ); + $this->assertSame( $lemmas, $lexeme->getLemmas() ); } public function testEmptyConstructor() { @@ -41,7 +41,7 @@ $this->assertNull( $lexeme->getId() ); $this->assertEquals( new StatementList(), $lexeme->getStatements() ); - $this->assertNull( $lexeme->getLemmata() ); + $this->assertNull( $lexeme->getLemmas() ); } public function testGetEntityType() { @@ -103,16 +103,16 @@ $this->assertFalse( $lexeme->isEmpty() ); } - public function testIsNotEmptyWithLemmata() { - $lemmata = new TermList( [ new Term( 'zh', 'Beijing' ) ] ); - $lexeme = new Lexeme( new LexemeId( 'l1' ), $lemmata ); + public function testIsNotEmptyWithLemmas() { + $lemmas = new TermList( [ new Term( 'zh', 'Beijing' ) ] ); + $lexeme = new Lexeme( new LexemeId( 'l1' ), $lemmas ); $this->assertFalse( $lexeme->isEmpty() ); } - public function testIsNotEmptyWithLemmataAndStatement() { - $lemmata = new TermList( [ new Term( 'zh', 'Beijing' ) ] ); - $lexeme = new Lexeme( new LexemeId( 'l1' ), $lemmata ); + public function testIsNotEmptyWithLemmasAndStatement() { + $lemmas = new TermList( [ new Term( 'zh', 'Beijing' ) ] ); + $lexeme = new Lexeme( new LexemeId( 'l1' ), $lemmas ); $lexeme->getStatements()->addNewStatement( new PropertyNoValueSnak( 42 ) ); $this->assertFalse( $lexeme->isEmpty() ); @@ -159,11 +159,11 @@ $this->assertTrue( $a->equals( $b ) ); } - public function testEqualLemmata() { + public function testEqualLemmas() { $lexeme = new Lexeme(); - $lemmata = new TermList( [ new Term( 'es', 'Barcelona' ) ] ); - $lexeme->setLemmata( $lemmata ); - $this->assertFalse( $lexeme->getLemmata()->equals( null ) ); + $lemmas = new TermList( [ new Term( 'es', 'Barcelona' ) ] ); + $lexeme->setLemmas( $lemmas ); + $this->assertFalse( $lexeme->getLemmas()->equals( null ) ); } public function differentLexemesProvider() { @@ -173,8 +173,8 @@ $withStatement2 = new Lexeme(); $withStatement2->getStatements()->addNewStatement( new PropertyNoValueSnak( 24 ) ); - $lemmata1 = new TermList( [ new Term( 'fa', 'Shiraz' ) ] ); - $lemmata2 = new TermList( [ new Term( 'fa', 'Tehran' ) ] ); + $lemmas1 = new TermList( [ new Term( 'fa', 'Shiraz' ) ] ); + $lemmas2 = new TermList( [ new Term( 'fa', 'Tehran' ) ] ); return [ 'null' => [ new Lexeme(), @@ -188,9 +188,9 @@ $withStatement1, $withStatement2 ], - 'different lemmata' => [ - new Lexeme( new LexemeId( 'l1' ), $lemmata1 ), - new Lexeme( new LexemeId( 'l1' ), $lemmata2 ), + 'different lemmas' => [ + new Lexeme( new LexemeId( 'l1' ), $lemmas1 ), + new Lexeme( new LexemeId( 'l1' ), $lemmas2 ), ] ]; } @@ -215,8 +215,8 @@ } public function testCopyWithContentEquals() { - $lemmata = new TermList( [ new Term( 'de', 'Cologne' ) ] ); - $lexeme = new Lexeme( new LexemeId( 'L1' ), $lemmata ); + $lemmas = new TermList( [ new Term( 'de', 'Cologne' ) ] ); + $lexeme = new Lexeme( new LexemeId( 'L1' ), $lemmas ); $lexeme->getStatements()->addNewStatement( new PropertyNoValueSnak( 42 ) ); $this->assertEquals( $lexeme, $lexeme->copy() ); @@ -265,14 +265,14 @@ $this->assertSame( $fingerprint, $lexeme->getFingerprint() ); } - public function testSetLemmata() { + public function testSetLemmas() { $id = new LexemeId( 'L1' ); - $lemmata = new TermList( [ new Term( 'fa', 'Karaj' ) ] ); + $lemmas = new TermList( [ new Term( 'fa', 'Karaj' ) ] ); $lexeme = new Lexeme( $id ); - $lexeme->setLemmata( $lemmata ); + $lexeme->setLemmas( $lemmas ); - $this->assertSame( $lemmata, $lexeme->getLemmata() ); + $this->assertSame( $lemmas, $lexeme->getLemmas() ); } } diff --git a/tests/phpunit/composer/DataModel/Serialization/LexemeDeserializerTest.php b/tests/phpunit/composer/DataModel/Serialization/LexemeDeserializerTest.php index 1a7c303..9c22bb0 100644 --- a/tests/phpunit/composer/DataModel/Serialization/LexemeDeserializerTest.php +++ b/tests/phpunit/composer/DataModel/Serialization/LexemeDeserializerTest.php @@ -113,13 +113,13 @@ ]; $lexeme = new Lexeme( new LexemeId( 'l2' ) ); - $lexeme->setLemmata( new TermList( [ new Term( 'el', 'Hey' ) ] ) ); + $lexeme->setLemmas( new TermList( [ new Term( 'el', 'Hey' ) ] ) ); - $serializations['with content and lemmata'] = [ + $serializations['with content and lemmas'] = [ [ 'type' => 'lexeme', 'id' => 'L2', - 'lemmata' => [ 'el' => 'Hey' ], + 'lemmas' => [ 'el' => 'Hey' ], ], $lexeme ]; -- To view, visit https://gerrit.wikimedia.org/r/324728 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifd5a552ebda233d6bfcd096595b25cfdaaaa8149 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikibaseLexeme Gerrit-Branch: master Gerrit-Owner: Ladsgroup <ladsgr...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits