Add category to the database

This commit is contained in:
Arne Schlüter 2015-01-18 11:56:25 +01:00
commit b229e1a6c4
2 changed files with 12 additions and 4 deletions

View file

@ -93,7 +93,7 @@ def get_categories(article_body):
} }
found_categories = [bad_words[key] for key in bad_words found_categories = [bad_words[key] for key in bad_words
if key in article_body.lower()] if key in article_body.lower()]
return found_categories or ['other'] return found_categories
def get_geoloc(query): def get_geoloc(query):
confidence_map = { confidence_map = {
@ -104,8 +104,9 @@ def get_geoloc(query):
} }
params = { params = {
"address": query + ", Berlin", "address": query,
"components": "country:DE" "components": "country:DE|administrative_area:Berlin",
"sensor": False
} }
url = "http://maps.googleapis.com/maps/api/geocode/json?" + urlencode(params) url = "http://maps.googleapis.com/maps/api/geocode/json?" + urlencode(params)

View file

@ -26,7 +26,14 @@ class Location(BaseModel):
match = CharField() match = CharField()
article = ForeignKeyField(Article) 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 # Set up the tables
def create_tables(): def create_tables():
db.connect() db.connect()
db.create_tables([Article, Location]) db.create_tables([Article, Location, Category])