]> git.xn--bdkaa.com Git - where-are-you.py.git/commitdiff
Improve memorial tips, fix wiki parsing
authorzharkovstas <zharkovstas@skbkontur.ru>
Sat, 18 May 2019 20:35:46 +0000 (01:35 +0500)
committerzharkovstas <zharkovstas@skbkontur.ru>
Sat, 18 May 2019 20:36:00 +0000 (01:36 +0500)
app.py
osm/osm.py
street_predictor.py

diff --git a/app.py b/app.py
index 25c209af548cddeb2af8a4c9e78a5c70bff01522..d5e61b5ec5b71cd942431903453e12b9fdde74dd 100644 (file)
--- a/app.py
+++ b/app.py
@@ -64,7 +64,8 @@ def add_tips(game):
             game.tips.append(f'Мимо как раз проезжает полупустой {v["name"]}. Можно успеть')
 
     for s in near_objects['sightseeings']:
-        game.tips.append(f'Кстати, недалеко интересный туристический объект: ' + s["name"])
+        type = convert_sightseeing_type(s['type'])
+        game.tips.append(f'Кстати, недалеко ' + (type if type else 'интересный туристический объект') + ': ' + s["name"])
 
     shuffle(game.tips)
 
@@ -92,6 +93,25 @@ def convert_direction(direction):
     return ''
 
 
+def convert_sightseeing_type(type):
+    if type == 'memorial':
+        return 'памятник'
+    if type == 'attraction':
+        return None
+    if type == 'artwork':
+        return None
+    if type == 'resort':
+        return None
+    if type == 'viewpoint':
+        return None
+    if type == 'museum':
+        return None
+    if type == 'yes':
+        return None
+    if type == 'building':
+        return None
+    return None
+
 def show_tips(game, count):
     not_shown_tips = [tip for tip in game.tips if tip not in game.shown_tips]
 
index 3ca52ede2aabf381186a558d969525029cac5698..3a7d440fbfd2ed1ea4389c8ade45ff604e6eeeaa 100644 (file)
@@ -109,7 +109,7 @@ def describe_objects(min_lat, min_lon, max_lat, max_lon):
        'name': re.split(r'\.', x['data']['tag']['name'].replace(':', '.'))[0]} for x in filter_vehicles(objects)
     ]
     sightseeings = [
-      {'name': x['data']['tag']['name']} for x in filter_sightseeings(objects)
+      {'name': x['data']['tag']['name'], 'type': x['data']['tag']['tourism'] if 'tourism' in x['data']['tag'] else x['data']['tag']['historic']} for x in filter_sightseeings(objects)
     ]
     districts = [
       {'name': x['data']['tag']['name']} for x in filter_districts(objects)
index 328ba21f637f335b27b62b0f4cf3ee029c80e80d..844146c7a840a17898c57da095f74326a9f9c390 100644 (file)
@@ -12,7 +12,8 @@ def parse_summary(query='str'):
 
     try:
         summary = w.summary(query)
-        full_description = re.split(r'\) —', summary)[1]
+
+        full_description = re.split(r'\) —', summary)[-1]
         description = re.split(r'\.', full_description)[0]
 
         cache[query] = (True, description.strip())
@@ -24,4 +25,4 @@ def parse_summary(query='str'):
 
 
 if __name__ == '__main__':
-    print(parse_summary('Ð\91ебелÑ\8f'))
+    print(parse_summary('СеÑ\80ова'))