Switch Commons categories to the end of the query to prevent cases with >1 cat from messing up wikipedia and commons articles

This commit is contained in:
misaochan 2018-03-18 20:44:49 +10:00
parent b600f51564
commit a2db562476
2 changed files with 4 additions and 10 deletions

View file

@ -100,12 +100,6 @@ public class NearbyPlaces {
continue;
}
// Fields: ["Point(153.073 -27.6111)"^^<http://www.opengis.net/ont/geosparql#wktLiteral>, <http://www.wikidata.org/entity/Q7271010>, "Queensland State Archives"@en, <http://www.wikidata.org/entity/Q327333>, "government agency"@en, , , Images from the Queensland State Archives, <https://en.wikipedia.org/wiki/Queensland_State_Archives>, <https://commons.wikimedia.org/wiki/Category:Images_from_the_Queensland_State_Archives>
// Produces: 02-11 21:32:45.015: V/NearbyPlaces(9300): Name: Queensland State Archives, type: government agency, category: Images from the Queensland State Archives, wikipediaSitelink: <https://en.wikipedia.org/wiki/Queensland_State_Archives>, commonsSitelink: <https://commons.wikimedia.org/wiki/Category:Images_from_the_Queensland_State_Archives>
//TODO: What about items with more than 1 Commons category??? Might need to rearrange categories to the end of the string
String[] fields = line.split("\t");
Timber.v("Fields: " + Arrays.toString(fields));
String point = fields[0];
@ -113,9 +107,9 @@ public class NearbyPlaces {
String name = Utils.stripLocalizedString(fields[2]);
String type = Utils.stripLocalizedString(fields[4]);
String icon = fields[5];
String category = Utils.stripLocalizedString(fields[7]);
String wikipediaSitelink = Utils.stripLocalizedString(fields[8]);
String commonsSitelink = Utils.stripLocalizedString(fields[9]);
String wikipediaSitelink = Utils.stripLocalizedString(fields[7]);
String commonsSitelink = Utils.stripLocalizedString(fields[8]);
String category = Utils.stripLocalizedString(fields[9]);
Timber.v("Name: " + name + ", type: " + type + ", category: " + category + ", wikipediaSitelink: " + wikipediaSitelink + ", commonsSitelink: " + commonsSitelink);

View file

@ -6,9 +6,9 @@ SELECT
(SAMPLE(COALESCE(?class_label_preferred_language, ?class_label_any_language, "?")) as ?class_label)
(SAMPLE(COALESCE(?icon0, ?icon1)) as ?icon)
(SAMPLE(COALESCE(?emoji0, ?emoji1)) as ?emoji)
(SAMPLE(?Commons_category) as ?Commons_category)
?wikipediaArticle
?commonsArticle
(SAMPLE(?Commons_category) as ?Commons_category)
WHERE {
# Around given location...
SERVICE wikibase:around {