diff --git a/analyze.py b/analyze.py index 0f37d88..e3a3fe1 100644 --- a/analyze.py +++ b/analyze.py @@ -93,7 +93,7 @@ def get_categories(article_body): } found_categories = [bad_words[key] for key in bad_words if key in article_body.lower()] - return found_categories or ['other'] + return found_categories def get_geoloc(query): confidence_map = { @@ -104,8 +104,9 @@ def get_geoloc(query): } params = { - "address": query + ", Berlin", - "components": "country:DE" + "address": query, + "components": "country:DE|administrative_area:Berlin", + "sensor": False } url = "http://maps.googleapis.com/maps/api/geocode/json?" + urlencode(params) diff --git a/models.py b/models.py index 9a2c85f..2e9b0c2 100644 --- a/models.py +++ b/models.py @@ -26,7 +26,14 @@ class Location(BaseModel): match = CharField() article = ForeignKeyField(Article) +class Category(BaseModel): + """ + Describes the category of an incident (e.g. sexism, racism, antisemitism etc) + """ + name = CharField() + article = ForeignKeyField(Article) + # Set up the tables def create_tables(): db.connect() - db.create_tables([Article, Location]) + db.create_tables([Article, Location, Category])