News Semantic Search /

from google.appengine.ext import db
from django.utils.html import strip_tags
import re
from google.appengine.ext import search 

class Entity(search.SearchableModel):
    TYPES = ['Person', 'Company', 'Product', 'Country', 'City']
    type = db.StringProperty(choices=set(TYPES))
    url = db.LinkProperty()
    name = db.StringProperty()
    extra_info = db.TextProperty()

class News(db.Model):
    url = db.LinkProperty()
    body = db.TextProperty()
    title = db.StringProperty()
    thumbnail = db.LinkProperty()
    category = db.StringProperty()
    date = db.DateTimeProperty(auto_now_add=True)

class Result(db.Model):
    news = db.ReferenceProperty(News)
    related_entity = db.ReferenceProperty(Entity)
    prefix = db.StringProperty()
    suffix = db.StringProperty()
    detection = db.StringProperty()
    relevance = db.FloatProperty()
    created = db.DateTimeProperty(auto_now_add=True)
    extra_info = db.TextProperty()
    def formated_detection(self):
        text = strip_tags(self.detection)
        return text.replace('[', '<span class="prefix-suffix">').replace(']', '</span>')

class NewsCategory(db.Model):
    url = db.LinkProperty()
    news = db.ReferenceProperty(News)
    category = db.StringProperty()
    relevance = db.FloatProperty()
    extra_info = db.TextProperty()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.