mirror of
https://github.com/heyarne/berliner-winter.git
synced 2026-05-06 19:23:39 +02:00
Add category to the database
This commit is contained in:
parent
24ffdeb1ec
commit
b229e1a6c4
2 changed files with 12 additions and 4 deletions
|
|
@ -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)
|
||||||
|
|
|
||||||
|
|
@ -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])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue