TomTom normalization

This commit is contained in:
Juan Ignacio Sánchez Lara
2018-07-11 09:30:28 +02:00
parent 825e3b7ee8
commit 0b2ee85c11
2 changed files with 21 additions and 8 deletions

View File

@@ -4,6 +4,7 @@
import json
import requests
from uritemplate import URITemplate
from math import tanh
from cartodb_services.metrics import Traceable
from cartodb_services.tools.exceptions import ServiceException
from cartodb_services.tools.qps import qps_retry
@@ -20,6 +21,7 @@ ENTRY_LON = 'lon'
ENTRY_LAT = 'lat'
EMPTY_RESPONSE = [[], {}]
SCORE_NORMALIZATION_FACTOR = 0.15
class TomTomGeocoder(Traceable):
'''
@@ -132,5 +134,8 @@ class TomTomGeocoder(Traceable):
def _extract_metadata_from_result(self, result):
return {
'relevance': result['score'] # TODO: normalize
'relevance': self._normalize_score(result['score'])
}
def _normalize_score(self, score):
return tanh(score * SCORE_NORMALIZATION_FACTOR)