Changeset 33066 in osm for applications/editors/josm/plugins/wikipedia
- Timestamp:
- 2016-11-17T08:29:38+01:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/wikipedia
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wikipedia/src/org/wikipedia/WikipediaApp.java
r32892 r33066 18 18 import java.util.Objects; 19 19 import java.util.TreeMap; 20 import java.util.TreeSet; 20 21 import java.util.regex.Pattern; 21 22 import java.util.stream.Collectors; … … 194 195 public static Map<String, String> getWikidataForArticles(String wikipediaLang, List<String> articles) { 195 196 if (articles.size() > 50) { 196 return partitionList(articles, 50).stream() 197 final List<String> withoutDuplicates = new ArrayList<>(new TreeSet<>(articles)); 198 return partitionList(withoutDuplicates, 50).stream() 197 199 .flatMap(chunk -> getWikidataForArticles(wikipediaLang, chunk).entrySet().stream()) 198 200 .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); -
applications/editors/josm/plugins/wikipedia/test/unit/org/wikipedia/WikipediaAppTest.java
r32892 r33066 8 8 import org.wikipedia.data.WikipediaEntry; 9 9 10 import java.util.ArrayList; 10 11 import java.util.Arrays; 11 12 import java.util.Collection; 13 import java.util.Collections; 12 14 import java.util.List; 13 15 import java.util.Locale; 14 16 import java.util.Map; 17 import java.util.stream.Collectors; 18 import java.util.stream.IntStream; 19 import java.util.stream.Stream; 15 20 16 21 import static org.hamcrest.CoreMatchers.hasItem; … … 115 120 116 121 @Test 122 public void testTicket13991() throws Exception { 123 final Map<String, String> map = WikipediaApp.getWikidataForArticles("en", 124 Stream.iterate("London", x -> x).limit(100).collect(Collectors.toList())); 125 assertThat(map, is(Collections.singletonMap("London", "Q84"))); 126 } 127 128 @Test 117 129 public void testGetLabelForWikidata() throws Exception { 118 130 assertThat(WikipediaApp.getLabelForWikidata("Q1741", Locale.GERMAN), is("Wien"));
Note:
See TracChangeset
for help on using the changeset viewer.