Repository: Wikidata/Wikidata-Toolkit
Pull request #587 (2021-05-15 05:37:28)

Allows lexeme lemma list to be empty

codecov[bot]: # [Codecov](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/587?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata) Report
> Merging [#587](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/587?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata) (f0deb19) into [master](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/commit/d325f8dab02031fea294437fe4e9a2fe75fc433b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata) (d325f8d) will **decrease** coverage by `0.14%`.
> The diff coverage is `50.00%`.

[![Impacted file tree graph](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/587/graphs/tree.svg?width=650&height=150&src=pr&token=QtTNJdTAbO&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata)](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/587?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata)

```diff
@@             Coverage Diff              @@
##             master     #587      +/-   ##
============================================
- Coverage     81.03%   80.89%   -0.15%     
  Complexity     2087     2087              
============================================
  Files           149      149              
  Lines          7278     7265      -13     
  Branches        895      889       -6     
============================================
- Hits           5898     5877      -21     
- Misses         1111     1120       +9     
+ Partials        269      268       -1     
```


| [Impacted Files](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/587?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata) | Coverage Δ | Complexity Δ | |
|---|---|---|---|
| [...k/datamodel/implementation/LexemeDocumentImpl.java](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/587/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata#diff-d2R0ay1kYXRhbW9kZWwvc3JjL21haW4vamF2YS9vcmcvd2lraWRhdGEvd2R0ay9kYXRhbW9kZWwvaW1wbGVtZW50YXRpb24vTGV4ZW1lRG9jdW1lbnRJbXBsLmphdmE=) | `91.75% <50.00%> (+0.49%)` | `42.00 <0.00> (+1.00)` | |
| [...wikidata/wdtk/dumpfiles/JsonDumpFileProcessor.java](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/587/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata#diff-d2R0ay1kdW1wZmlsZXMvc3JjL21haW4vamF2YS9vcmcvd2lraWRhdGEvd2R0ay9kdW1wZmlsZXMvSnNvbkR1bXBGaWxlUHJvY2Vzc29yLmphdmE=) | `42.42% <0.00%> (-13.64%)` | `7.00% <0.00%> (-1.00%)` | |
| [.../wikidata/wdtk/dumpfiles/EntityTimerProcessor.java](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/587/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata#diff-d2R0ay1kdW1wZmlsZXMvc3JjL21haW4vamF2YS9vcmcvd2lraWRhdGEvd2R0ay9kdW1wZmlsZXMvRW50aXR5VGltZXJQcm9jZXNzb3IuamF2YQ==) | `72.09% <0.00%> (-1.25%)` | `11.00% <0.00%> (ø%)` | |
| [...kidata/wdtk/rdf/values/QuantityValueConverter.java](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/587/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata#diff-d2R0ay1yZGYvc3JjL21haW4vamF2YS9vcmcvd2lraWRhdGEvd2R0ay9yZGYvdmFsdWVzL1F1YW50aXR5VmFsdWVDb252ZXJ0ZXIuamF2YQ==) | `71.42% <0.00%> (-0.99%)` | `5.00% <0.00%> (ø%)` | |
| [...a/wdtk/datamodel/interfaces/StatementDocument.java](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/587/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata#diff-d2R0ay1kYXRhbW9kZWwvc3JjL21haW4vamF2YS9vcmcvd2lraWRhdGEvd2R0ay9kYXRhbW9kZWwvaW50ZXJmYWNlcy9TdGF0ZW1lbnREb2N1bWVudC5qYXZh) | `71.23% <0.00%> (-0.77%)` | `45.00% <0.00%> (ø%)` | |
| [...a/wdtk/datamodel/implementation/ValueSnakImpl.java](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/587/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata#diff-d2R0ay1kYXRhbW9kZWwvc3JjL21haW4vamF2YS9vcmcvd2lraWRhdGEvd2R0ay9kYXRhbW9kZWwvaW1wbGVtZW50YXRpb24vVmFsdWVTbmFrSW1wbC5qYXZh) | `85.71% <0.00%> (-0.40%)` | `16.00% <0.00%> (ø%)` | |
| [...idata/wdtk/dumpfiles/DumpProcessingController.java](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/587/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata#diff-d2R0ay1kdW1wZmlsZXMvc3JjL21haW4vamF2YS9vcmcvd2lraWRhdGEvd2R0ay9kdW1wZmlsZXMvRHVtcFByb2Nlc3NpbmdDb250cm9sbGVyLmphdmE=) | `65.60% <0.00%> (-0.22%)` | `32.00% <0.00%> (ø%)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/587?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/587?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata). Last update [d325f8d...f0deb19](https://codecov.io/gh/Wikidata/Wikidata-Toolkit/pull/587?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Wikidata).


Patch:
diff --git a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/LexemeDocumentImpl.java b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/LexemeDocumentImpl.java
index 9d7ede5e..902fbb93 100644
--- a/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/LexemeDocumentImpl.java
+++ b/wdtk-datamodel/src/main/java/org/wikidata/wdtk/datamodel/implementation/LexemeDocumentImpl.java
@@ -91,11 +91,7 @@ public class LexemeDocumentImpl extends StatementDocumentImpl implements LexemeD
 		this.lexicalCategory = lexicalCategory;
 		Validate.notNull(language, "Lexeme language should not be null");
 		this.language = language;
-		Validate.notNull(lemmas, "Lexeme lemmas should not be null");
-		if(lemmas.isEmpty()) {
-			throw new IllegalArgumentException("Lexemes should have at least one lemma");
-		}
-		this.lemmas = constructTermMap(lemmas);
+		this.lemmas = (lemmas == null || lemmas.isEmpty()) ? Collections.emptyMap() : constructTermMap(lemmas);
 		this.forms = (forms == null) ? Collections.emptyList() : forms;
 		this.senses = (senses == null) ? Collections.emptyList() : senses;
 
@@ -123,11 +119,7 @@ public class LexemeDocumentImpl extends StatementDocumentImpl implements LexemeD
 		this.lexicalCategory = new ItemIdValueImpl(lexicalCategory, siteIri);
 		Validate.notNull(language, "Lexeme language should not be null");
 		this.language = new ItemIdValueImpl(language, siteIri);
-		Validate.notNull(lemmas, "Lexeme lemmas should not be null");
-		if(lemmas.isEmpty()) {
-			throw new IllegalArgumentException("Lexemes should have at least one lemma");
-		}
-		this.lemmas = lemmas;
+		this.lemmas = (lemmas == null) ? Collections.emptyMap() : lemmas;
 		this.forms = (forms == null) ? Collections.emptyList() : forms;
 		this.senses = (senses == null) ? Collections.emptyList() : senses;
 


Test patch:
diff --git a/wdtk-datamodel/src/test/java/org/wikidata/wdtk/datamodel/implementation/LexemeDocumentImplTest.java b/wdtk-datamodel/src/test/java/org/wikidata/wdtk/datamodel/implementation/LexemeDocumentImplTest.java
index 07e82f95..dfe456d9 100644
--- a/wdtk-datamodel/src/test/java/org/wikidata/wdtk/datamodel/implementation/LexemeDocumentImplTest.java
+++ b/wdtk-datamodel/src/test/java/org/wikidata/wdtk/datamodel/implementation/LexemeDocumentImplTest.java
@@ -171,13 +171,13 @@ public class LexemeDocumentImplTest {
 	}
 
 	@Test
-	public void lemmasNotNull() {
-		assertThrows(NullPointerException.class, () -> new LexemeDocumentImpl(lid, lexCat, language, null, statementGroups, forms, senses,  1234));
+	public void lemmasNull() {
+		assertEquals(Collections.emptyMap(), new LexemeDocumentImpl(lid, lexCat, language, null, statementGroups, forms, senses,  1234).getLemmas());
 	}
 
 	@Test
-	public void lemmasNotEmpty() {
-		assertThrows(IllegalArgumentException.class, () -> new LexemeDocumentImpl(lid, lexCat, language, Collections.emptyList(), statementGroups, forms, senses,  1234));
+	public void lemmasEmpty() {
+		assertEquals(Collections.emptyMap(), new LexemeDocumentImpl(lid, lexCat, language, Collections.emptyList(), statementGroups, forms, senses,  1234).getLemmas());
 	}
 
 	@Test