WMDE-leszek has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/384539 )
Change subject: Restore dummy demo data
......................................................................
Restore dummy demo data
This is basically restoring stuff removed in
Idd8b20fcca349a06f0fb18d92cf2608b113b163e.
Bug: T178045
Change-Id: I28e18a1c07135a2c85906d7ad2d09f460e0059c6
---
M src/Content/LexemeContent.php
M src/DataModel/Lexeme.php
A src/DemoData/AskOut1Populator.php
A src/DemoData/AskOut2Populator.php
A src/DemoData/AskOut3Populator.php
A src/DemoData/HardLexemePopulator.php
A src/DemoData/Id.php
A src/DemoData/LeiterLexemePopulator.php
8 files changed, 438 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseLexeme
refs/changes/39/384539/1
diff --git a/src/Content/LexemeContent.php b/src/Content/LexemeContent.php
index 2f4649a..c26708e 100644
--- a/src/Content/LexemeContent.php
+++ b/src/Content/LexemeContent.php
@@ -38,7 +38,24 @@
);
}
- $this->lexemeHolder = $lexemeHolder;
+ /** @var Lexeme $lexeme */
+ $lexeme = $this->lexemeHolder->getEntity( Lexeme::class );
+
+ // TODO: This is a test dummy that must be removed later
+ $id = $lexeme->getId()->getSerialization();
+ if ( $id === DemoData\Id::L_HARD ) {
+ ( new DemoData\HardLexemePopulator() )->populate(
$lexeme );
+ } elseif ( $id === DemoData\Id::L_LEITER ) {
+ ( new DemoData\LeiterLexemePopulator() )->populate(
$lexeme );
+ } elseif ( $id === DemoData\Id::L_ASK_1 ) {
+ ( new DemoData\AskOut1Populator() )->populate( $lexeme
);
+ } elseif ( $id === DemoData\Id::L_ASK_2 ) {
+ ( new DemoData\AskOut2Populator() )->populate( $lexeme
);
+ } elseif ( $id === DemoData\Id::L_ASK_OUT ) {
+ ( new DemoData\AskOut3Populator() )->populate( $lexeme
);
+ }
+
+ return $lexeme;
}
/**
diff --git a/src/DataModel/Lexeme.php b/src/DataModel/Lexeme.php
index 37c54af..f575f53 100644
--- a/src/DataModel/Lexeme.php
+++ b/src/DataModel/Lexeme.php
@@ -259,6 +259,14 @@
}
/**
+ * @param Form[] $forms
+ * @deprecated Temporary method, for demo. Just don't use.
+ */
+ public function setForms( array $forms ) {
+ $this->forms = new FormSet( $forms );
+ }
+
+ /**
* @return Sense[]
*/
public function getSenses() {
@@ -266,6 +274,14 @@
}
/**
+ * @param Sense[] $senses
+ * @deprecated Only for demonstration purposes. Do not use otherwise!
+ */
+ public function setSenses( array $senses ) {
+ $this->senses = $senses;
+ }
+
+ /**
* @return bool False if a non-optional field was never initialized,
true otherwise.
*/
public function isSufficientlyInitialized() {
diff --git a/src/DemoData/AskOut1Populator.php
b/src/DemoData/AskOut1Populator.php
new file mode 100644
index 0000000..e0944c1
--- /dev/null
+++ b/src/DemoData/AskOut1Populator.php
@@ -0,0 +1,26 @@
+<?php
+
+namespace Wikibase\Lexeme\DemoData;
+
+use Wikibase\Lexeme\DataModel\Lexeme;
+use Wikibase\Lexeme\Tests\DataModel\NewSense;
+
+class AskOut1Populator {
+
+ public function populate( Lexeme $lexeme ) {
+ $defaultSense = $this->buildDefaultSense();
+
+ $lexeme->setForms( [] );
+ $lexeme->setSenses( [ $defaultSense ] );
+ }
+
+ /**
+ * @return \Wikibase\Lexeme\DataModel\Sense
+ */
+ private function buildDefaultSense() {
+ return NewSense::havingId( 'S5' )
+ ->withGloss( 'en', '’To ask somebody out’: To request a
romantic date' )
+ ->build();
+ }
+
+}
diff --git a/src/DemoData/AskOut2Populator.php
b/src/DemoData/AskOut2Populator.php
new file mode 100644
index 0000000..f10315a
--- /dev/null
+++ b/src/DemoData/AskOut2Populator.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Wikibase\Lexeme\DemoData;
+
+use Wikibase\Lexeme\DataModel\Lexeme;
+use Wikibase\Lexeme\Tests\DataModel\NewSense;
+use Wikibase\Repo\Tests\NewStatement;
+
+class AskOut2Populator {
+
+ public function populate( Lexeme $lexeme ) {
+ $defaultSense = $this->buildDefaultSense();
+
+ $lexeme->setForms( [] );
+ $lexeme->setSenses( [ $defaultSense ] );
+ }
+
+ /**
+ * @return \Wikibase\Lexeme\DataModel\Sense
+ */
+ private function buildDefaultSense() {
+ return NewSense::havingId( 'S5' )
+ ->withGloss( 'en', 'To request a romantic date' )
+ ->withStatement(
+ NewStatement::forProperty(
Id::P_GRAMMATICAL_FRAME )
+ ->withValue( 'to <ask> $somebody out' )
+ ->withSomeGuid()
+ )
+ ->build();
+ }
+
+}
diff --git a/src/DemoData/AskOut3Populator.php
b/src/DemoData/AskOut3Populator.php
new file mode 100644
index 0000000..afd8062
--- /dev/null
+++ b/src/DemoData/AskOut3Populator.php
@@ -0,0 +1,26 @@
+<?php
+
+namespace Wikibase\Lexeme\DemoData;
+
+use Wikibase\Lexeme\DataModel\Lexeme;
+use Wikibase\Lexeme\Tests\DataModel\NewSense;
+
+class AskOut3Populator {
+
+ public function populate( Lexeme $lexeme ) {
+ $defaultSense = $this->buildDefaultSense();
+
+ $lexeme->setForms( [] );
+ $lexeme->setSenses( [ $defaultSense ] );
+ }
+
+ /**
+ * @return \Wikibase\Lexeme\DataModel\Sense
+ */
+ private function buildDefaultSense() {
+ return NewSense::havingId( 'S1' )
+ ->withGloss( 'en', 'To request a romantic date' )
+ ->build();
+ }
+
+}
diff --git a/src/DemoData/HardLexemePopulator.php
b/src/DemoData/HardLexemePopulator.php
new file mode 100644
index 0000000..5581663
--- /dev/null
+++ b/src/DemoData/HardLexemePopulator.php
@@ -0,0 +1,141 @@
+<?php
+
+namespace Wikibase\Lexeme\DemoData;
+
+use Wikibase\DataModel\Entity\ItemId;
+use Wikibase\Lexeme\DataModel\Lexeme;
+use Wikibase\Lexeme\Tests\DataModel\NewForm;
+use Wikibase\Lexeme\Tests\DataModel\NewSense;
+use Wikibase\Repo\Tests\NewStatement;
+
+class HardLexemePopulator {
+
+ public function populate( Lexeme $lexeme ) {
+ $hardForm = $this->buildHardForm();
+ $harderForm = $this->buildHarderForm();
+
+ $presentingDifficultySense =
$this->buildPresentingDifficultySense();
+ $resistingDeformationSense =
$this->buildResistingDeformationSense();
+
+ $lexeme->setForms( [ $hardForm, $harderForm ] );
+ $lexeme->setSenses( [ $presentingDifficultySense,
$resistingDeformationSense ] );
+ }
+
+ /**
+ * @return \Wikibase\Lexeme\DataModel\Form
+ */
+ private function buildHardForm() {
+ return NewForm::havingId( 'F1' )
+ ->andRepresentation( 'en', 'hard' )
+ ->andGrammaticalFeature( Id::Q_NORMATIVE )
+ ->andStatement(
+ NewStatement::forProperty(
Id::P_IPA_PRONUNCIATION )
+ ->withValue( '/hɑːd/' )
+ ->withQualifier( Id::P_REGION, new
ItemId( Id::Q_SCOTLAND ) )
+ ->withSomeGuid()
+ )->andStatement(
+ NewStatement::forProperty(
Id::P_IPA_PRONUNCIATION )
+ ->withValue( '/hɑɹd/' )
+ ->withQualifier(
+ Id::P_REGION,
+ new ItemId(
Id::Q_UNITED_STATES_OF_AMERICA )
+ )->withSomeGuid()
+ )->andStatement(
+ NewStatement::forProperty(
Id::P_PRONUNCIATION_AUDIO )
+ ->withValue( 'hard.ogg' )
+ ->withQualifier(
+ Id::P_REGION,
+ new ItemId(
Id::Q_UNITED_STATES_OF_AMERICA )
+ )->withSomeGuid()
+ )->andStatement(
+ NewStatement::forProperty( Id::P_RHYME )
+ ->withValue( Id::LF_CARD )
+ ->withSomeGuid()
+ )->andStatement(
+ NewStatement::forProperty( Id::P_RHYME )
+ ->withValue( Id::LF_BARD )
+ ->withSomeGuid()
+ )->build();
+ }
+
+ /**
+ * @return \Wikibase\Lexeme\DataModel\Form
+ */
+ private function buildHarderForm() {
+ return NewForm::havingId( 'F2' )
+ ->andRepresentation( 'en', 'harder' )
+ ->andGrammaticalFeature( Id::Q_COMPARATIVE )
+ ->build();
+ }
+
+ /**
+ * @return \Wikibase\Lexeme\DataModel\Sense
+ */
+ private function buildPresentingDifficultySense() {
+ return NewSense::havingId( 'S1' )
+ ->withGloss( 'en', 'presenting difficulty' )
+ ->withGloss( 'de', 'Schwierig oder kompliziert' )
+ ->withStatement(
+ NewStatement::forProperty( Id::P_SYNONYM )
+ ->withValue( Id::LS_DIFFICULT )
+ ->withSomeGuid()
+ )
+ ->withStatement(
+ NewStatement::forProperty( Id::P_REGISTER )
+ ->withValue( new ItemId(
Id::Q_COLLOQUIALISM ) )
+ ->withSomeGuid()
+ )
+ ->withStatement(
+ NewStatement::forProperty( Id::P_TRANSLATION )
+ ->withValue( Id::LS_SCHWIERIG )
+ ->withSomeGuid()
+ )
+ ->withStatement(
+ NewStatement::forProperty( Id::P_TRANSLATION )
+ ->withValue( Id::LS_DUR )
+ ->withSomeGuid()
+ )
+ ->withStatement(
+ NewStatement::forProperty( Id::P_ANTONYM )
+ ->withValue( Id::LS_EASY )
+ ->withSomeGuid()
+ )
+ ->withStatement(
+ NewStatement::forProperty( Id::P_ANTONYM )
+ ->withValue( Id::LS_SIMPLE )
+ ->withSomeGuid()
+ )
+ ->build();
+ }
+
+ /**
+ * @return \Wikibase\Lexeme\DataModel\Sense
+ */
+ private function buildResistingDeformationSense() {
+ return NewSense::havingId( 'S2' )
+ ->withGloss( 'en', 'resisting deformation' )
+ ->withGloss( 'de', 'schwer verformbar' )
+ ->withStatement(
+ NewStatement::forProperty( Id::P_EVOKES )
+ ->withValue( new ItemId(
Id::Q_ELASTICITY ) )
+ ->withSomeGuid()
+ )
+ ->withStatement(
+ NewStatement::forProperty( Id::P_EVOKES )
+ ->withValue( new ItemId(
Id::Q_DUCTILITY ) )
+ ->withSomeGuid()
+ )
+ ->withStatement(
+ NewStatement::forProperty( Id::P_EVOKES )
+ ->withValue( new ItemId( Id::Q_HARDNESS
) )
+ ->withSomeGuid()
+ )
+ ->withStatement(
+ NewStatement::forProperty( Id::P_ANTONYM )
+ ->withValue( Id::LS_SOFT )
+ ->withSomeGuid()
+ )
+ ->build();
+ }
+
+}
diff --git a/src/DemoData/Id.php b/src/DemoData/Id.php
new file mode 100644
index 0000000..b4b3b0f
--- /dev/null
+++ b/src/DemoData/Id.php
@@ -0,0 +1,80 @@
+<?php
+
+namespace Wikibase\Lexeme\DemoData;
+
+class Id {
+
+ const L_HARD = 'L13';
+ const L_HEARD = 'L14';
+ const L_LEITER = 'L15';
+ const L_LEITERIN = 'L16';
+ const L_ASK_1 = 'L17';
+ const L_ASK_2 = 'L18';
+ const L_ASK_OUT = 'L19';
+
+ const LF_CARD = 'L456-F4';
+ const LF_BARD = 'L888-F1';
+
+ const LS_DIFFICULT = 'L3627-S4';
+ const LS_SCHWIERIG = 'L283-S2';
+ const LS_DUR = 'L465-S1';
+ const LS_EASY = 'L801-S1';
+ const LS_SIMPLE = 'L802-S1';
+ const LS_SOFT = 'L803-S1';
+ const LS_LEADER = 'L15-S1';
+
+ const P_LANGUAGE_CODE = 'P2';
+ const P_INSTANCE_OF = 'P3';
+ const P_LEXEME_PROPERTY = 'P4';
+ const P_HOMOPHONE = 'P6';
+ const P_TRANSLATES_TO = 'P7';
+ const P_DERIVED_FROM = 'P9';
+ const P_IPA_PRONUNCIATION = 'P10';
+ const P_REGION = 'P11';
+ const P_PRONUNCIATION_AUDIO = 'P12';
+ const P_REGISTER = 'P13';
+ const P_EVOKES = 'P14';
+ const P_MORPHOLOGY = 'P15';
+ const P_GRAMMATICAL_GENDER = 'P16';
+ const P_GENDERED_FORM = 'P17';
+ const P_SYLLABIFICATION = 'P18';
+ const P_GRAMMATICAL_FRAME = 'P19';
+ const P_DENOTES = 'P26';
+
+ // Form type
+ const P_RHYME = 'P20';
+ //Sense type
+ const P_SYNONYM = 'P21';
+ const P_TRANSLATION = 'P22';
+ const P_ANTONYM = 'P24';
+ const P_REFERS_TO_SENSE = 'P25';
+
+ const Q_CONDUCTOR = 'Q33';
+ const Q_LEADER = 'Q32';
+ const Q_VERBAL_PHRASE = 'Q31';
+ const Q_FEMALE = 'Q30';
+ const Q_GENITIVE = 'Q29';
+ const Q_SINGULAR = 'Q28';
+ const Q_NOMINATIVE = 'Q27';
+ const Q_MALE = 'Q26';
+ const Q_GERMAN_DECLINATION_W1 = 'Q25';
+ const Q_NORMATIVE = 'Q24';
+ const Q_HARDNESS = 'Q22';
+ const Q_DUCTILITY = 'Q21';
+ const Q_ELASTICITY = 'Q20';
+ const Q_COLLOQUIALISM = 'Q19';
+ const Q_COMPARATIVE = 'Q18';
+ const Q_UNITED_STATES_OF_AMERICA = 'Q17';
+ const Q_SCOTLAND = 'Q16';
+ const Q_OLDENGLISH = 'Q15';
+ const Q_ADJECTIVE = 'Q14';
+ const Q_FORM_ITEM = 'Q9';
+ const Q_NOUN = 'Q8';
+ const Q_GERMAN = 'Q7';
+ const Q_LEXICAL_CATEGORY = 'Q6';
+ const Q_LANGUAGE = 'Q5';
+ const Q_ENGLISH_LANGUAGE = 'Q4';
+ const Q_ENGLISH = 'Q3';
+ const Q_VERB = 'Q2';
+
+}
diff --git a/src/DemoData/LeiterLexemePopulator.php
b/src/DemoData/LeiterLexemePopulator.php
new file mode 100644
index 0000000..3eceef9
--- /dev/null
+++ b/src/DemoData/LeiterLexemePopulator.php
@@ -0,0 +1,99 @@
+<?php
+
+namespace Wikibase\Lexeme\DemoData;
+
+use Wikibase\DataModel\Entity\ItemId;
+use Wikibase\Lexeme\DataModel\Lexeme;
+use Wikibase\Lexeme\Tests\DataModel\NewForm;
+use Wikibase\Lexeme\Tests\DataModel\NewSense;
+use Wikibase\Repo\Tests\NewStatement;
+
+class LeiterLexemePopulator {
+
+ public function populate( Lexeme $lexeme ) {
+ $leiterForm = $this->buildLeiterForm();
+ $leitersForm = $this->buildLeitersForm();
+ $leiterinForm = $this->buildLeiterinForm();
+
+ $leaderSense = $this->buildLeaderSense();
+ $electricalConductorSense =
$this->buildElectricalConductorSense();
+
+ $lexeme->setForms( [ $leiterForm, $leitersForm, $leiterinForm ]
);
+ $lexeme->setSenses( [ $leaderSense, $electricalConductorSense ]
);
+ }
+
+ /**
+ * @return \Wikibase\Lexeme\DataModel\Form
+ */
+ private function buildLeiterForm() {
+ return NewForm::havingId( 'F1' )
+ ->andRepresentation( 'de', 'Leiter' )
+ ->andGrammaticalFeature( Id::Q_NOMINATIVE )
+ ->andGrammaticalFeature( Id::Q_SINGULAR )
+ ->andStatement(
+ NewStatement::forProperty(
Id::P_IPA_PRONUNCIATION )
+ ->withValue( '/ˈlaɪ̯tɐ/' )
+ ->withSomeGuid()
+ )->andStatement(
+ NewStatement::forProperty(
Id::P_SYLLABIFICATION )
+ ->withValue( 'Lei-ter' )
+ ->withSomeGuid()
+ )->build();
+ }
+
+ /**
+ * @return \Wikibase\Lexeme\DataModel\Form
+ */
+ private function buildLeitersForm() {
+ return NewForm::havingId( 'F2' )
+ ->andRepresentation( 'de', 'Leiters' )
+ ->andGrammaticalFeature( Id::Q_GENITIVE )
+ ->andGrammaticalFeature( Id::Q_SINGULAR )
+ ->build();
+ }
+
+ private function buildLeiterinForm() {
+ return NewForm::havingId( 'F3' )
+ ->andRepresentation( 'de', 'Leiterin' )
+ ->andGrammaticalFeature( Id::Q_NOMINATIVE )
+ ->andGrammaticalFeature( Id::Q_SINGULAR )
+ ->andGrammaticalFeature( Id::Q_FEMALE )
+ ->andStatement(
+ NewStatement::forProperty(
Id::P_REFERS_TO_SENSE )
+ ->withValue( Id::LS_LEADER )
+ ->withSomeGuid()
+ )
+ ->build();
+ }
+
+ /**
+ * @return \Wikibase\Lexeme\DataModel\Sense
+ */
+ private function buildLeaderSense() {
+ return NewSense::havingId( 'S1' )
+ ->withGloss( 'de', 'Führungsperson' )
+ ->withGloss( 'en', 'leader' )
+ ->withStatement(
+ NewStatement::forProperty( Id::P_DENOTES )
+ ->withValue( new ItemId( Id::Q_LEADER )
)
+ ->withSomeGuid()
+ )
+ ->build();
+ }
+
+ /**
+ * @return \Wikibase\Lexeme\DataModel\Sense
+ */
+ private function buildElectricalConductorSense() {
+ return NewSense::havingId( 'S2' )
+ ->withGloss( 'de', 'elektrischer Leiter' )
+ ->withGloss( 'en', 'electrical conductor' )
+ ->withStatement(
+ NewStatement::forProperty( Id::P_DENOTES )
+ ->withValue( new ItemId(
Id::Q_CONDUCTOR ) )
+ ->withSomeGuid()
+ )
+ ->build();
+ }
+
+}
--
To view, visit https://gerrit.wikimedia.org/r/384539
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I28e18a1c07135a2c85906d7ad2d09f460e0059c6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseLexeme
Gerrit-Branch: master
Gerrit-Owner: WMDE-leszek <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits