Commit ebbeb060 authored by Florian Schäfer's avatar Florian Schäfer

Fix wrong usage of ListUtil.processInBatches()

Inside the `processBatch` function only refer to the batch collection, not the whole collection that should be processed.
parent 0b374eb4
...@@ -388,19 +388,19 @@ public final class WikipediaApp { ...@@ -388,19 +388,19 @@ public final class WikipediaApp {
final String url = "https://www.wikidata.org/w/api.php" + final String url = "https://www.wikidata.org/w/api.php" +
"?action=wbgetentities" + "?action=wbgetentities" +
"&props=labels|descriptions" + "&props=labels|descriptions" +
"&ids=" + entries.stream().map(x -> x.article).collect(Collectors.joining("|")) + "&ids=" + batch.stream().map(x -> x.article).collect(Collectors.joining("|")) +
"&format=xml"; "&format=xml";
try (InputStream in = connect(url).getContent()) { try (InputStream in = connect(url).getContent()) {
final Document xml = newDocumentBuilder().parse(in); final Document xml = newDocumentBuilder().parse(in);
for (final WikipediaEntry entry : entries) { for (final WikipediaEntry batchEntry : batch) {
final Node entity = X_PATH.evaluateNode("//entity[@id='" + entry.article + "']", xml); final Node entity = X_PATH.evaluateNode("//entity[@id='" + batchEntry.article + "']", xml);
if (entity == null) { if (entity == null) {
continue; continue;
} }
result.add(new WikidataEntry( result.add(new WikidataEntry(
entry.article, batchEntry.article,
getFirstField(languages, "label", entity), getFirstField(languages, "label", entity),
entry.coordinate, batchEntry.coordinate,
getFirstField(languages, "description", entity) getFirstField(languages, "description", entity)
)); ));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment