Arquisoft / wiq_en1b

wiq_en1b
https://youtu.be/r2XqDUHj3zU
0 stars 1 forks source link

Possibly internationalization related problem #58

Closed ErdemYabaci closed 4 months ago

ErdemYabaci commented 5 months ago

I was sometimes getting this error while the languageCode was "es". It might be a fluke but issue solved itself when I removed the lines where languageCode = "es" was used.

Error:

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "org.wikidata.wdtk.datamodel.interfaces.MonolingualTextValue.getText()" because "mtv" is null
        at main.java.questionGenerator.generator.AbstractGenerator.getName(AbstractGenerator.java:79)
        at main.java.questionGenerator.generator.RightAnswerIsEntity.getRightAnswer(RightAnswerIsEntity.java:30)
        at main.java.questionGenerator.generator.RightAnswerIsEntity.getAnswer(RightAnswerIsEntity.java:58)
        at main.java.questionGenerator.generator.specificGenerators.CapitalGenerator.getWrongAnswers(CapitalGenerator.java:32)
        at main.java.questionGenerator.generator.AbstractGenerator.generate(AbstractGenerator.java:69)
        at main.java.questionGenerator.QuestionGenerator.generateQuestion(QuestionGenerator.java:31)
        at main.java.Main.run(Main.java:37)
        at main.java.Main.main(Main.java:17)
UO289845 commented 4 months ago

The error seems to be caused by one of the entites chosen for the distractors, which apparently lacks a Spanish text. I'll have to check them manually to see which one it is and replace it by another.

UO289845 commented 4 months ago

Ok so as it turns out is way more complex than I thought. The entity that gives up the problem is Q17 (Japan), but not because Tokyo does not have a value in Spanish, but because is not selecting Tokyo as the capital. Is selecting Shigaraki Palace (Q262438), which technically speaking it seems to have been correct (around the year 744). This is because is picking up the first result in the capital, which is not necesarily the correct one.

Now I'll try to came up with an algorithm to ensure it picks the correct capital.

UO289845 commented 4 months ago

So the idea is the following: When looking for the capital, instead of picking just the first one, it'll take all of them, and it'll process all of them (by making a request to Wikidata) until it finds the one without the End Time property (P582), since only the current capital does not have that property.

As you've probably realizaed, this is highly inneficient, since now to generate the question of a capital of a place, it'll have to make at least eight request to wikidata (one per each place plus another one for the capital), and that's only if said places have only one capital entity in their property capital or if they have the current one first, in any other case, it'll be bigger. So now the complexity of generating this question is O(n) instead of O(1).

UO289845 commented 4 months ago

Is finally solved and in the Question_Generation_General branch