self.tips = []
self.shown_tips = []
self.route = [current_coordinates]
+ self.score = 0
def move(self, direction, value=move_distance):
if direction == 'north':
return None
return None
+
districts_tips = {
'кировский': ' назван в честь Сергея Мироновича, фамилия которого послужила названием еще и для города',
'ленинский': ' назвали в честь Ильича. Все знают Ильича ☭',
'железнодорожный': ' наверняка расположил внутри себя вокзал, ну или паровозное депо'
}
+
def create_district_tip(district_name):
for district_key, district_tip in districts_tips.items():
if district_key in district_name.lower():
return _enable_cors
+def count_score(game):
+ dist = distance(game.current_coordinates, game.answer_coordinates)
+
+ return 100_000_000 / (1 + dist)
+
+
@get('/api/games')
@enable_cors
def get_games():
games.values()]
}
+
def handle_post_game(city_id):
game_id = str(uuid.uuid4())
if city_id not in cities:
"max_lon": max_lon
}
+
@post('/api/games')
@enable_cors
def post_game_without_city():
return handle_post_game('Екатеринбург')
+
@post('/api/games/<city>')
@enable_cors
def post_game(city):
game = games[game_id]
+ if not direction:
+ return bottle.HTTPResponse(status=400, body='direction is required')
+
+ game.move(direction)
+
game.tips = []
add_tips(game)
game.is_finished = True
game.answer_coordinates = answer_coordinates
game.distance = d
+ game.score = count_score(game)
return {
"right_coordinates": game.current_coordinates,
"distance": d,
"address": get_text_by_coordinates(game.current_coordinates),
- "route": game.route
+ "route": game.route,
+ "score": game.score
}
return result.strip()
-def stemming(word):
- return stemmer.stemWord(word)
-
-def text_stemming(text):
+def stemming(text):
normilized_text = normalize(text)
return ' '.join(stemmer.stemWords(normilized_text.split()))
+
+if __name__ == "__main__":
+ print(stemming('Спланой мост'))