From 84c7fd425b47342ce8363951bfda682828a9b9ec Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 4 Jun 2020 15:55:46 +0200 Subject: [PATCH] Fix tests --- .../osmand/search/core/SearchCoreFactory.java | 3 +- .../net/osmand/search/core/SearchPhrase.java | 8 +- .../src/test/resources/search/bank_abcd.json | 37 ++++---- .../test/resources/search/burger_king.json | 85 +++++-------------- .../test/resources/search/double_parking.json | 70 +++++++++++---- .../test/resources/search/poi_biergarten.json | 70 ++++++++++++--- .../test/resources/search/spring_street.json | 3 - 7 files changed, 156 insertions(+), 120 deletions(-) diff --git a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java index da260b1493..33214cabf6 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchCoreFactory.java @@ -746,7 +746,8 @@ public class SearchCoreFactory { } } else { - Map> poiTypes = getPoiTypeResults(nm, true); + boolean includeAdditional = !phrase.hasMoreThanOneUnknownSearchWord(); + Map> poiTypes = getPoiTypeResults(nm, includeAdditional); for (Entry> pt : poiTypes.entrySet()) { boolean match = !phrase.isFirstUnknownSearchWordComplete(); if (!match) { diff --git a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java index e9d34bd255..b7050cd943 100644 --- a/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java +++ b/OsmAnd-java/src/main/java/net/osmand/search/core/SearchPhrase.java @@ -202,7 +202,7 @@ public class SearchPhrase { sp.words = foundWords; sp.fullTextSearchPhrase = fullText; sp.unknownSearchPhrase = textToSearch; - + sp.lastUnknownSearchWordComplete = isTextComplete(fullText) ; if (!reg.matcher(textToSearch).find()) { sp.firstUnknownSearchWord = sp.unknownSearchPhrase.trim(); } else { @@ -211,7 +211,9 @@ public class SearchPhrase { boolean first = true; for (int i = 0; i < ws.length ; i++) { String wd = ws[i].trim(); - if (wd.length() > 0 && !conjunctions.contains(wd.toLowerCase())) { + boolean conjunction = conjunctions.contains(wd.toLowerCase()); + boolean lastAndIncomplete = i == ws.length - 1 && !sp.lastUnknownSearchWordComplete; + if (wd.length() > 0 && (!conjunction || lastAndIncomplete)) { if (first) { sp.firstUnknownSearchWord = wd; first = false; @@ -221,7 +223,7 @@ public class SearchPhrase { } } } - sp.lastUnknownSearchWordComplete = isTextComplete(fullText) ; + return sp; } diff --git a/OsmAnd-java/src/test/resources/search/bank_abcd.json b/OsmAnd-java/src/test/resources/search/bank_abcd.json index 86aaae239e..75710cc36c 100644 --- a/OsmAnd-java/src/test/resources/search/bank_abcd.json +++ b/OsmAnd-java/src/test/resources/search/bank_abcd.json @@ -11,25 +11,24 @@ }, "phrase": "Bank dr", "results": [ - "Bank (Finance)", - "Hohe-Bank-Weg, Königswartha - Rakecy", - "Dresdner Bank", - "Ostsächsische Sparkasse Dresden", - "Ostsächsische Sparkasse Dresden", - "Filiale Dresden Technische Universität", - "Ostsächsische Sparkasse Dresden", - "Volksbank Raiffeisenbank Dresden", - "Ostsächsische Sparkasse Dresden Zwst. Strehlen", - "Ostsächsische Sparkasse Dresden", - "Ostsächsische Sparkasse Dresden", - "Dresdner Volksbank Raiffeisenbank", - "Ostsächsische Sparkasse Filiale Dresden Wilder Mann", - "Ostsächsische Sparkasse Dresden", - "Ostsächsische Sparkasse Dresden", - "Ostsächsische Sparkasse Dresden", - "Ostsächsische Sparkasse Dresden", - "Ostsächsische Sparkasse Dresden", - "Dresdner Volksbank Raiffeisenbank eG" + "Bank (Finance) [[1, POI_TYPE, 1.000, 0.00 km]]", + "Dresdner Bank [[2, POI, 2.000, 0.10 km]]", + "Ostsächsische Sparkasse Dresden [[2, POI, 2.000, 1.46 km]]", + "Ostsächsische Sparkasse Dresden [[2, POI, 2.000, 2.15 km]]", + "Filiale Dresden Technische Universität [[2, POI, 2.000, 2.61 km]]", + "Ostsächsische Sparkasse Dresden [[2, POI, 2.000, 2.68 km]]", + "Volksbank Raiffeisenbank Dresden [[2, POI, 2.000, 2.77 km]]", + "Ostsächsische Sparkasse Dresden Zwst. Strehlen [[2, POI, 2.000, 2.86 km]]", + "Ostsächsische Sparkasse Dresden [[2, POI, 2.000, 3.42 km]]", + "Ostsächsische Sparkasse Dresden [[2, POI, 2.000, 3.74 km]]", + "Dresdner Volksbank Raiffeisenbank [[2, POI, 2.000, 4.72 km]]", + "Ostsächsische Sparkasse Filiale Dresden Wilder Mann [[2, POI, 2.000, 5.06 km]]", + "Ostsächsische Sparkasse Dresden [[2, POI, 2.000, 7.42 km]]", + "Ostsächsische Sparkasse Dresden [[2, POI, 2.000, 7.44 km]]", + "Ostsächsische Sparkasse Dresden [[2, POI, 2.000, 7.57 km]]", + "Ostsächsische Sparkasse Dresden [[2, POI, 2.000, 8.06 km]]", + "Ostsächsische Sparkasse Dresden [[2, POI, 2.000, 8.83 km]]", + "Dresdner Volksbank Raiffeisenbank eG [[2, POI, 2.000, 8.97 km]]" ], "amenities": [ { diff --git a/OsmAnd-java/src/test/resources/search/burger_king.json b/OsmAnd-java/src/test/resources/search/burger_king.json index 75fdcadb36..3108612856 100644 --- a/OsmAnd-java/src/test/resources/search/burger_king.json +++ b/OsmAnd-java/src/test/resources/search/burger_king.json @@ -11,73 +11,26 @@ }, "phrase": "Burger King", "results": [ - "Burger (Cafe / Cafe and restaurant) [[1, POI_TYPE, 1.000, 0.00 km]]", - "Burger (Pub / Food) [[1, POI_TYPE, 1.000, 0.00 km]]", - "Burger (Bar / Food) [[1, POI_TYPE, 1.000, 0.00 km]]", - "Burger (Restaurant / Cafe and restaurant) [[1, POI_TYPE, 1.000, 0.00 km]]", - "Burger (Biergarten / Food) [[1, POI_TYPE, 1.000, 0.00 km]]", - "Burger (Fast food / Food) [[1, POI_TYPE, 1.000, 0.00 km]]", "Burger King Thiendorf [[2, POI, 2.000, 46.35 km]]", - "Burger King [[2, POI, 2.000, 46.75 km]]", - "Burger King [[2, POI, 2.000, 57.61 km]]", - "Burger King [[2, POI, 2.000, 58.23 km]]", - "Burger King [[2, POI, 2.000, 59.20 km]]", - "Burger King [[2, POI, 2.000, 66.93 km]]", - "Burger King Riesa [[2, POI, 2.000, 78.15 km]]", - "Burger King [[2, POI, 2.000, 118.29 km]]", - "Bürger King Chemnitz [[2, POI, 2.000, 121.13 km]]", - "Burger King Chemnitz [[2, POI, 2.000, 123.17 km]]", - "Burger King [[2, POI, 2.000, 135.11 km]]", - "Burger King [[2, POI, 2.000, 139.54 km]]", - "Burger King [[2, POI, 2.000, 139.98 km]]", - "Burger King [[2, POI, 2.000, 140.17 km]]", - "Burger King Glauchau [[2, POI, 2.000, 142.15 km]]", - "Burger King [[2, POI, 2.000, 144.43 km]]", - "Burger King [[2, POI, 2.000, 146.38 km]]", - "Burger King [[2, POI, 2.000, 147.72 km]]", - "Burger King [[2, POI, 2.000, 148.27 km]]", - "Burger King [[2, POI, 2.000, 151.57 km]]", - "Burger Straße 2, Lohsa - Łaz [[1, STREET, 3.000, 6.55 km]]", - "Burger Straße, Lohsa - Łaz [[1, STREET, 3.000, 6.74 km]]", - "Burger Straße 2 [[1, POI, 2.000, 6.56 km]]", - "Beat’n’Burger [[1, POI, 2.000, 56.07 km]]", - "Burgerclub 13 [[1, POI, 2.000, 56.14 km]]", - "Burgermeister [[1, POI, 2.000, 56.18 km]]", - "Burgerheart [[1, POI, 2.000, 56.28 km]]", - "burgerei [[1, POI, 2.000, 58.04 km]]", - "Rock Burger [[1, POI, 2.000, 58.62 km]]", - "Burgerlich [[1, POI, 2.000, 58.73 km]]", - "Bürger Augenoptik [[1, POI, 2.000, 60.75 km]]", - "Burger-Werk [[1, POI, 2.000, 65.07 km]]", - "Bürger- und Vereinshaus [[1, POI, 2.000, 76.72 km]]", - "Burger Cafe Kultur [[1, POI, 2.000, 92.76 km]]", - "Dr. med. Ulrich Bürger [[1, POI, 2.000, 94.32 km]]", - "Bürger-Schützen-Gilde 1470 Wurzen e.V. [[1, POI, 2.000, 115.91 km]]", - "SUMO Burger [[1, POI, 2.000, 117.31 km]]", - "Photovoltaikanlage Freibad Bürger Energie Drebach eG [[1, POI, 2.000, 122.52 km]]", - "ALFS burger & pizza [[1, POI, 2.000, 126.09 km]]", - "Bürger- und Vereinshaus [[1, POI, 2.000, 129.35 km]]", - "Bürger- und Vereinshaus Rittergut [[1, POI, 2.000, 131.71 km]]", - "Bürger-Schützengesellschaft 1857 Taucha e.V. [[1, POI, 2.000, 133.21 km]]", - "Meyer Burger (Germany) AG [[1, POI, 2.000, 135.57 km]]", - "Bürger- und Familienpark Oelsnitz [[1, POI, 2.000, 138.38 km]]", - "Bürger- und Berggasthaus Scheibenberg [[1, POI, 2.000, 138.63 km]]", - "Max-Bürger-Forschungszentrum [[1, POI, 2.000, 138.92 km]]", - "Peter Pane Burgergrill & Bar [[1, POI, 2.000, 139.96 km]]", - "Prime Burger [[1, POI, 2.000, 140.14 km]]", - "Bistro Burger [[1, POI, 2.000, 140.46 km]]", - "Burgerheart [[1, POI, 2.000, 140.47 km]]", - "Burger Like [[1, POI, 2.000, 140.77 km]]", - "burgerme [[1, POI, 2.000, 141.03 km]]", - "Bistro Burger & Co [[1, POI, 2.000, 141.52 km]]", - "Burger-Amt Adler [[1, POI, 2.000, 143.11 km]]", - "Burger Amt #2 [[1, POI, 2.000, 143.51 km]]", - "Parfümerie Burger [[1, POI, 2.000, 151.50 km]]", - "Parfümerie Burger [[1, POI, 2.000, 153.16 km]]", - "Bürger-Begegnungszentrum [[1, POI, 2.000, 178.53 km]]", - "Burger 25 [[1, POI, 2.000, 186.78 km]]", - "Merkur [[0, POI, 2.000, 58.62 km]]", - "Bahnhof Kurort Kipsdorf [[0, POI, 2.000, 80.96 km]]" + "Burger King [[2, POI, 2.000, 46.75 km]]", + "Burger King [[2, POI, 2.000, 57.61 km]]", + "Burger King [[2, POI, 2.000, 58.23 km]]", + "Burger King [[2, POI, 2.000, 59.20 km]]", + "Burger King [[2, POI, 2.000, 66.93 km]]", + "Burger King Riesa [[2, POI, 2.000, 78.15 km]]", + "Burger King [[2, POI, 2.000, 118.29 km]]", + "Bürger King Chemnitz [[2, POI, 2.000, 121.13 km]]", + "Burger King Chemnitz [[2, POI, 2.000, 123.17 km]]", + "Burger King [[2, POI, 2.000, 135.11 km]]", + "Burger King [[2, POI, 2.000, 139.54 km]]", + "Burger King [[2, POI, 2.000, 139.98 km]]", + "Burger King [[2, POI, 2.000, 140.17 km]]", + "Burger King Glauchau [[2, POI, 2.000, 142.15 km]]", + "Burger King [[2, POI, 2.000, 144.43 km]]", + "Burger King [[2, POI, 2.000, 146.38 km]]", + "Burger King [[2, POI, 2.000, 147.72 km]]", + "Burger King [[2, POI, 2.000, 148.27 km]]", + "Burger King [[2, POI, 2.000, 151.57 km]]" ], "amenities": [ { diff --git a/OsmAnd-java/src/test/resources/search/double_parking.json b/OsmAnd-java/src/test/resources/search/double_parking.json index 46abccb8d1..c3812aae31 100644 --- a/OsmAnd-java/src/test/resources/search/double_parking.json +++ b/OsmAnd-java/src/test/resources/search/double_parking.json @@ -9,24 +9,60 @@ "emptyQueryAllowed": false, "sortByName": false }, - "phrase": "parking", + "phrase": "parking ", "results": [ - "Parking (Personal transport)", - "Parking entrance (Personal transport)", - "Parking fee (Charging station / Transportation)", - "Parking fee: no (Charging station / Transportation)", - "Parking fee: yes (Charging station / Transportation)", - "Parking lot (Fire hydrant / Emergency infrastructure)", - "Parking space (Personal transport)", - "Parking tickets (Vending machine / Store)", - "Parking tickets (Vending machine / Store)", - "Parking time limit (Parking / Personal transport)", - "Bicycle parking (Bicycle transport)", - "Motorcycle parking (Personal transport)", - "Parking", - "Parking", - "Parking", - "Parking" + "Parking (Personal transport) [[1, POI_TYPE, 1.000, 0.00 km]]", + "для посетителей [[0, POI, 2.000, 0.03 km]]", + "Parking [[0, POI, 2.000, 0.05 km]]", + "Parking [[0, POI, 2.000, 0.11 km]]", + "Parking [[0, POI, 2.000, 0.16 km]]", + "Parking [[0, POI, 2.000, 0.17 km]]", + "Parking [[0, POI, 2.000, 0.23 km]]", + "Parking [[0, POI, 2.000, 0.35 km]]", + "Parking [[0, POI, 2.000, 0.40 km]]", + "Parking [[0, POI, 2.000, 0.48 km]]", + "Parking [[0, POI, 2.000, 0.49 km]]", + "Parking [[0, POI, 2.000, 0.55 km]]", + "Автостоянка №1 [[0, POI, 2.000, 0.56 km]]", + "Parking [[0, POI, 2.000, 0.58 km]]", + "Parking [[0, POI, 2.000, 0.61 km]]", + "Parking [[0, POI, 2.000, 0.72 km]]", + "Parking [[0, POI, 2.000, 0.81 km]]", + "Parking [[0, POI, 2.000, 0.81 km]]", + "Parking [[0, POI, 2.000, 0.85 km]]", + "для клиентов [[0, POI, 2.000, 0.89 km]]", + "Parking [[0, POI, 2.000, 0.93 km]]", + "Parking [[0, POI, 2.000, 0.94 km]]", + "Заинская ГРЭС [[0, POI, 2.000, 1.01 km]]", + "Parking [[0, POI, 2.000, 1.02 km]]", + "Южная [[0, POI, 2.000, 1.03 km]]", + "Parking [[0, POI, 2.000, 1.06 km]]", + "Parking [[0, POI, 2.000, 1.09 km]]", + "Parking [[0, POI, 2.000, 1.10 km]]", + "Служебная [[0, POI, 2.000, 1.14 km]]", + "Parking [[0, POI, 2.000, 1.20 km]]", + "Parking [[0, POI, 2.000, 1.21 km]]", + "Parking [[0, POI, 2.000, 1.36 km]]", + "Parking [[0, POI, 2.000, 1.44 km]]", + "Три тополя [[0, POI, 2.000, 1.47 km]]", + "Parking [[0, POI, 2.000, 1.53 km]]", + "Parking [[0, POI, 2.000, 1.56 km]]", + "Parking [[0, POI, 2.000, 1.62 km]]", + "Parking [[0, POI, 2.000, 1.85 km]]", + "Штрафстоянка (Эвакуатор) [[0, POI, 2.000, 2.03 km]]", + "Parking [[0, POI, 2.000, 2.05 km]]", + "для регистрации в ГИБДД [[0, POI, 2.000, 2.06 km]]", + "Parking [[0, POI, 2.000, 2.06 km]]", + "Parking [[0, POI, 2.000, 2.07 km]]", + "для техосмотра [[0, POI, 2.000, 2.09 km]]", + "Parking [[0, POI, 2.000, 2.18 km]]", + "Parking [[0, POI, 2.000, 2.55 km]]", + "Parking [[0, POI, 2.000, 3.40 km]]", + "Parking [[0, POI, 2.000, 3.41 km]]", + "Parking [[0, POI, 2.000, 3.41 km]]", + "Parking [[0, POI, 2.000, 3.45 km]]", + "Parking [[0, POI, 2.000, 4.29 km]]", + "Parking [[0, POI, 2.000, 6.71 km]]" ], "amenities": [ { diff --git a/OsmAnd-java/src/test/resources/search/poi_biergarten.json b/OsmAnd-java/src/test/resources/search/poi_biergarten.json index 362e58f4d7..63c19b794f 100644 --- a/OsmAnd-java/src/test/resources/search/poi_biergarten.json +++ b/OsmAnd-java/src/test/resources/search/poi_biergarten.json @@ -9,18 +9,66 @@ "emptyQueryAllowed": false, "sortByName": false }, - "phrase": "Biergarten", + "phrase": "Biergarten ", "results": [ - "Biergarten (Food)", - "Biergarten Italienisches Dörfchen", - "Biergarten Narrenhäus'l", - "Biergarten Elbsegler", - "Biergarten Elbsegler", - "Biergarten", - "Biergarten", - "Biergarten", - "Biergarten", - "Biergarten" + "Biergarten (Food) [[1, POI_TYPE, 1.000, 0.00 km]]", + "Biergarten Italienisches Dörfchen [[1, POI, 2.000, 0.55 km]]", + "Biergarten Narrenhäus'l [[1, POI, 2.000, 0.84 km]]", + "Biergarten Elbsegler [[1, POI, 2.000, 0.89 km]]", + "Biergarten Elbsegler [[1, POI, 2.000, 0.90 km]]", + "Körnergarten [[1, POI, 2.000, 5.18 km]]", + "Biergarten Goldener Anker [[1, POI, 2.000, 9.78 km]]", + "Palais Bistro [[0, POI, 2.000, 0.29 km]]", + "Augustus Garten am Narrenhäusl [[0, POI, 2.000, 0.88 km]]", + "Zum Schießhaus [[0, POI, 2.000, 0.96 km]]", + "Biergarten [[0, POI, 2.000, 1.24 km]]", + "Wachstube [[0, POI, 2.000, 1.24 km]]", + "Torwirtschaft [[0, POI, 2.000, 1.27 km]]", + "Altes Wettbüro [[0, POI, 2.000, 1.77 km]]", + "Bottoms Up [[0, POI, 2.000, 2.16 km]]", + "Louisengarten [[0, POI, 2.000, 2.20 km]]", + "Biergarten [[0, POI, 2.000, 2.28 km]]", + "Fährgarten Johannstadt [[0, POI, 2.000, 2.42 km]]", + "Carolaschlösschen [[0, POI, 2.000, 2.53 km]]", + "Alt-Dresden [[0, POI, 2.000, 2.75 km]]", + "Biergarten [[0, POI, 2.000, 2.90 km]]", + "Café & Restaurant Saite [[0, POI, 2.000, 3.09 km]]", + "Brauhaus am Waldschlößchen [[0, POI, 2.000, 3.45 km]]", + "Brauhaus Watzke [[0, POI, 2.000, 3.51 km]]", + "el Horst [[0, POI, 2.000, 3.67 km]]", + "Biergarten [[0, POI, 2.000, 3.74 km]]", + "Spitzwegerich [[0, POI, 2.000, 3.81 km]]", + "Biergarten [[0, POI, 2.000, 3.88 km]]", + "Biergarten [[0, POI, 2.000, 4.46 km]]", + "Trobischhof [[0, POI, 2.000, 4.48 km]]", + "Biergarten [[0, POI, 2.000, 4.80 km]]", + "Biergarten [[0, POI, 2.000, 4.91 km]]", + "Schillergarten [[0, POI, 2.000, 4.97 km]]", + "Biergarten [[0, POI, 2.000, 5.11 km]]", + "Biergarten [[0, POI, 2.000, 5.13 km]]", + "Demnitz Elbegarten [[0, POI, 2.000, 5.16 km]]", + "Körnergarten [[0, POI, 2.000, 5.18 km]]", + "Biergarten [[0, POI, 2.000, 5.31 km]]", + "Trachauer Sommergarten [[0, POI, 2.000, 5.31 km]]", + "Biergarten [[0, POI, 2.000, 5.91 km]]", + "Biergarten [[0, POI, 2.000, 6.12 km]]", + "Biergarten [[0, POI, 2.000, 6.26 km]]", + "Biergarten [[0, POI, 2.000, 6.42 km]]", + "Biergarten [[0, POI, 2.000, 6.88 km]]", + "Biergarten [[0, POI, 2.000, 7.11 km]]", + "Straußenwirtschaft Weingut Pesterwitz [[0, POI, 2.000, 7.14 km]]", + "Klotzscher Sommerwirtschaft [[0, POI, 2.000, 7.16 km]]", + "Biergarten [[0, POI, 2.000, 7.17 km]]", + "Zacke [[0, POI, 2.000, 8.20 km]]", + "Weingut Seifert [[0, POI, 2.000, 8.50 km]]", + "Biergarten [[0, POI, 2.000, 8.82 km]]", + "Biergarten [[0, POI, 2.000, 9.11 km]]", + "Biergarten [[0, POI, 2.000, 9.23 km]]", + "Landgut Hofewiese [[0, POI, 2.000, 9.40 km]]", + "Biergarten Goldener Anker [[0, POI, 2.000, 9.78 km]]", + "Biergarten [[0, POI, 2.000, 10.00 km]]", + "Biergarten [[0, POI, 2.000, 10.22 km]]", + "Besenwirtschaft Steinrücken [[0, POI, 2.000, 10.85 km]]" ], "amenities": [ { diff --git a/OsmAnd-java/src/test/resources/search/spring_street.json b/OsmAnd-java/src/test/resources/search/spring_street.json index ae94086499..d489ddc6d2 100644 --- a/OsmAnd-java/src/test/resources/search/spring_street.json +++ b/OsmAnd-java/src/test/resources/search/spring_street.json @@ -12,9 +12,6 @@ "phrase": "spring street", "results": [ "Spring (Natural) [[1, POI_TYPE, 1.000, 0.00 km]]", - "Spring (Spring / Natural) [[1, POI_TYPE, 1.000, 0.00 km]]", - "Spring (Ice rink / Sport) [[1, POI_TYPE, 1.000, 0.00 km]]", - "Spring (Bridge / Transport construction) [[1, POI_TYPE, 1.000, 0.00 km]]", "Spring Street, South Nyack [[2, STREET, 3.000, 10.57 km]]", "Spring Street, Tomkins Cove [[2, STREET, 3.000, 16.77 km]]", "Spring Street, Southfields [[2, STREET, 3.000, 18.10 km]]",