mirror of
https://github.com/heyarne/berliner-winter.git
synced 2026-05-06 19:23:39 +02:00
Improve urlencoding of location query
This commit is contained in:
parent
41f2afcc12
commit
13ac77b575
1 changed files with 5 additions and 14 deletions
19
analyze.py
19
analyze.py
|
|
@ -1,8 +1,7 @@
|
||||||
<<<<<<< HEAD
|
|
||||||
import requests, json
|
import requests, json
|
||||||
=======
|
from urllib.parse import urlencode
|
||||||
import re
|
|
||||||
import string
|
import re, string
|
||||||
from nltk.tag.stanford import POSTagger
|
from nltk.tag.stanford import POSTagger
|
||||||
|
|
||||||
tagger = POSTagger('./stanford-postagger-full-2014-10-26/models/german-fast.tagger',
|
tagger = POSTagger('./stanford-postagger-full-2014-10-26/models/german-fast.tagger',
|
||||||
|
|
@ -76,14 +75,6 @@ def improve_potential_places(pos_tuples):
|
||||||
better_tuples.append(cleaner_list)
|
better_tuples.append(cleaner_list)
|
||||||
|
|
||||||
return better_tuples
|
return better_tuples
|
||||||
>>>>>>> place_extraction
|
|
||||||
|
|
||||||
def get_district(article_headline):
|
|
||||||
"""
|
|
||||||
Returns a geo-coded version of a district an article is about, based on its
|
|
||||||
headline.
|
|
||||||
"""
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get_categories(article_body):
|
def get_categories(article_body):
|
||||||
"""
|
"""
|
||||||
|
|
@ -105,8 +96,8 @@ def get_categories(article_body):
|
||||||
return found_categories or ['other']
|
return found_categories or ['other']
|
||||||
|
|
||||||
def get_geoloc(query):
|
def get_geoloc(query):
|
||||||
query.replace(" ", "%20")
|
encoded_query = urlencode(query + ", Berlin")
|
||||||
url = "http://nominatim.openstreetmap.org/search?q=" + query + "%20Berlin" + "&countrycodes=de&format=json&limit=1"
|
url = "http://nominatim.openstreetmap.org/search?q=" + encoded_query + " + "&countrycodes=de&format=json&limit=1"
|
||||||
r = requests.get(url)
|
r = requests.get(url)
|
||||||
|
|
||||||
return(r.json()[0]["lat"], r.json()[0]["lon"])
|
return(r.json()[0]["lat"], r.json()[0]["lon"])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue