Spaces:
Running
Running
Update services/location_service.py
Browse files
services/location_service.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
# import locationtagger
|
2 |
-
from
|
3 |
from geopy.geocoders import Nominatim
|
4 |
from geopy.exc import GeocoderTimedOut, GeocoderUnavailable
|
5 |
from models.location_models import LocationData, Coordinates, ErrorResponse
|
@@ -26,7 +26,7 @@ class LocationService:
|
|
26 |
|
27 |
|
28 |
@staticmethod
|
29 |
-
def get_coordinates(data:dict) -> Coordinates | ErrorResponse:
|
30 |
print("Inside get coordinates")
|
31 |
print(data)
|
32 |
try:
|
@@ -40,7 +40,7 @@ class LocationService:
|
|
40 |
|
41 |
if location:
|
42 |
# Assuming `app.nlp` is already initialized elsewhere and accessible
|
43 |
-
ner_results = app.nlp(location)
|
44 |
|
45 |
# Extract city, state, and country using the logic from extract_location_entities
|
46 |
location_entities = LocationService.extract_location_entities(ner_results)
|
|
|
1 |
# import locationtagger
|
2 |
+
from fastapi import FastAPI
|
3 |
from geopy.geocoders import Nominatim
|
4 |
from geopy.exc import GeocoderTimedOut, GeocoderUnavailable
|
5 |
from models.location_models import LocationData, Coordinates, ErrorResponse
|
|
|
26 |
|
27 |
|
28 |
@staticmethod
|
29 |
+
def get_coordinates(data:dict,app:FastAPI) -> Coordinates | ErrorResponse:
|
30 |
print("Inside get coordinates")
|
31 |
print(data)
|
32 |
try:
|
|
|
40 |
|
41 |
if location:
|
42 |
# Assuming `app.nlp` is already initialized elsewhere and accessible
|
43 |
+
ner_results = app.state.nlp(location)
|
44 |
|
45 |
# Extract city, state, and country using the logic from extract_location_entities
|
46 |
location_entities = LocationService.extract_location_entities(ner_results)
|